- /* Forget about the parent of another subquery */
- if (root != current_hint_state->current_root)
- current_hint_state->parent_relid = 0;
-
- /* Find the parent for this relation other than the registered parent */
- foreach (l, root->append_rel_list)
+ /*
+ * Forget about the parent of another subquery, but don't forget if the
+ * inhTargetkind of the root is not INHKIND_NONE, which signals the root
+ * contains only appendrel members. See inheritance_planner for details.
+ *
+ * (PG12.0) 428b260f87 added one more planning cycle for updates on
+ * partitioned tables and hints set up in the cycle are overriden by the
+ * second cycle. Since I didn't find no apparent distinction between the
+ * PlannerRoot of the cycle and that of ordinary CMD_SELECT, pg_hint_plan
+ * accepts both cycles and the later one wins. In the second cycle root
+ * doesn't have inheritance information at all so use the parent_relid set
+ * in the first cycle.
+ */
+ if (root->inhTargetKind == INHKIND_NONE)