+static void
+pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId,
+ bool inhparent, RelOptInfo *rel)
+{
+ ScanMethodHint *hint;
+
+ if (prev_get_relation_info)
+ (*prev_get_relation_info) (root, relationObjectId, inhparent, rel);
+
+ /* Do nothing if we don't have valid hint in this context. */
+ if (!current_hint)
+ return;
+
+ if (inhparent)
+ {
+ /* store does relids of parent table. */
+ current_hint->parent_relid = rel->relid;
+ }
+ else if (current_hint->parent_relid != 0)
+ {
+ /*
+ * We use the same GUC parameter if this table is the child table of a
+ * table called pg_hint_plan_get_relation_info just before that.
+ */
+ ListCell *l;
+
+ /* append_rel_list contains all append rels; ignore others */
+ foreach(l, root->append_rel_list)
+ {
+ AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(l);
+
+ /* This rel is child table. */
+ if (appinfo->parent_relid == current_hint->parent_relid &&
+ appinfo->child_relid == rel->relid)
+ {
+ if (current_hint->parent_hint)
+ delete_indexes(current_hint->parent_hint, rel);
+
+ return;
+ }
+ }
+
+ /* This rel is not inherit table. */
+ current_hint->parent_relid = 0;
+ current_hint->parent_hint = NULL;
+ }
+
+ /*
+ * If scan method hint was given, reset GUC parameters which control
+ * planner behavior about choosing scan methods.
+ */
+ if ((hint = find_scan_hint(root, rel)) == NULL)
+ {
+ set_scan_config_options(current_hint->init_scan_mask,
+ current_hint->context);
+ return;
+ }
+ set_scan_config_options(hint->enforce_mask, current_hint->context);
+ hint->base.state = HINT_STATE_USED;
+ if (inhparent)
+ current_hint->parent_hint = hint;
+
+ delete_indexes(hint, rel);
+}
+