• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision96588f8576a77b1a0d512f576bb31cada6e9184a (tree)
Time2019-10-29 18:47:17
AuthorKyotaro Horiguchi <horikyota.ntt@gmai...>
CommiterKyotaro Horiguchi

Log Message

Follow the change in PG12.

Commit 428b260f87 breaks the prior assumptions by adding one more
planning cycle for updates on partitioned tables. Follow the change.

Change Summary

Incremental Difference

--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -3732,32 +3732,50 @@ setup_hint_enforcement(PlannerInfo *root, RelOptInfo *rel,
37323732 return 0;
37333733 }
37343734
3735- /* Forget about the parent of another subquery */
3736- if (root != current_hint_state->current_root)
3737- current_hint_state->parent_relid = 0;
3738-
3739- /* Find the parent for this relation other than the registered parent */
3740- foreach (l, root->append_rel_list)
3735+ /*
3736+ * Forget about the parent of another subquery, but don't forget if the
3737+ * inhTargetkind of the root is not INHKIND_NONE, which signals the root
3738+ * contains only appendrel members. See inheritance_planner for details.
3739+ *
3740+ * (PG12.0) 428b260f87 added one more planning cycle for updates on
3741+ * partitioned tables and hints set up in the cycle are overriden by the
3742+ * second cycle. Since I didn't find no apparent distinction between the
3743+ * PlannerRoot of the cycle and that of ordinary CMD_SELECT, pg_hint_plan
3744+ * accepts both cycles and the later one wins. In the second cycle root
3745+ * doesn't have inheritance information at all so use the parent_relid set
3746+ * in the first cycle.
3747+ */
3748+ if (root->inhTargetKind == INHKIND_NONE)
37413749 {
3742- AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(l);
3750+ if (root != current_hint_state->current_root)
3751+ current_hint_state->parent_relid = 0;
37433752
3744- if (appinfo->child_relid == rel->relid)
3753+ /* Find the parent for this relation other than the registered parent */
3754+ foreach (l, root->append_rel_list)
37453755 {
3746- if (current_hint_state->parent_relid != appinfo->parent_relid)
3756+ AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(l);
3757+
3758+ if (appinfo->child_relid == rel->relid)
37473759 {
3748- new_parent_relid = appinfo->parent_relid;
3749- current_hint_state->current_root = root;
3760+ if (current_hint_state->parent_relid != appinfo->parent_relid)
3761+ {
3762+ new_parent_relid = appinfo->parent_relid;
3763+ current_hint_state->current_root = root;
3764+ }
3765+ break;
37503766 }
3751- break;
37523767 }
3753- }
37543768
3755- if (!l)
3756- {
3757- /* This relation doesn't have a parent. Cancel current_hint_state. */
3758- current_hint_state->parent_relid = 0;
3759- current_hint_state->parent_scan_hint = NULL;
3760- current_hint_state->parent_parallel_hint = NULL;
3769+ if (!l)
3770+ {
3771+ /*
3772+ * This relation doesn't have a parent. Cancel
3773+ * current_hint_state.
3774+ */
3775+ current_hint_state->parent_relid = 0;
3776+ current_hint_state->parent_scan_hint = NULL;
3777+ current_hint_state->parent_parallel_hint = NULL;
3778+ }
37613779 }
37623780
37633781 if (new_parent_relid > 0)
Show on old repository browser