リビジョン | be1a756dc318ac8f39f67716c0be3a765834bdb3 (tree) |
---|---|
日時 | 2017-02-07 12:55:54 |
作者 | Kyotaro Horiguchi <horiguchi.kyotaro@lab....> |
コミッター | Kyotaro Horiguchi |
Rename current_hint to current_hint_state
The name current_hint is quite confusing so change the name to less
confusing one.
@@ -127,9 +127,9 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2) | ||
127 | 127 | RowsHint *domultiply = NULL; |
128 | 128 | |
129 | 129 | /* Search for applicable rows hint for this join node */ |
130 | - for (i = 0; i < current_hint->num_hints[HINT_TYPE_ROWS]; i++) | |
130 | + for (i = 0; i < current_hint_state->num_hints[HINT_TYPE_ROWS]; i++) | |
131 | 131 | { |
132 | - rows_hint = current_hint->rows_hints[i]; | |
132 | + rows_hint = current_hint_state->rows_hints[i]; | |
133 | 133 | |
134 | 134 | /* |
135 | 135 | * Skip this rows_hint if it is invalid from the first or it |
@@ -488,11 +488,12 @@ static get_relation_info_hook_type prev_get_relation_info = NULL; | ||
488 | 488 | static join_search_hook_type prev_join_search = NULL; |
489 | 489 | |
490 | 490 | /* Hold reference to currently active hint */ |
491 | -static HintState *current_hint = NULL; | |
491 | +static HintState *current_hint_state = NULL; | |
492 | 492 | |
493 | 493 | /* |
494 | 494 | * List of hint contexts. We treat the head of the list as the Top of the |
495 | - * context stack, so current_hint always points the first element of this list. | |
495 | + * context stack, so current_hint_state always points the first element of this | |
496 | + * list. | |
496 | 497 | */ |
497 | 498 | static List *HintStateStack = NIL; |
498 | 499 |
@@ -2286,7 +2287,7 @@ set_scan_config_options(unsigned char enforce_mask, GucContext context) | ||
2286 | 2287 | ) |
2287 | 2288 | mask = enforce_mask; |
2288 | 2289 | else |
2289 | - mask = enforce_mask & current_hint->init_scan_mask; | |
2290 | + mask = enforce_mask & current_hint_state->init_scan_mask; | |
2290 | 2291 | |
2291 | 2292 | SET_CONFIG_OPTION("enable_seqscan", ENABLE_SEQSCAN); |
2292 | 2293 | SET_CONFIG_OPTION("enable_indexscan", ENABLE_INDEXSCAN); |
@@ -2304,7 +2305,7 @@ set_join_config_options(unsigned char enforce_mask, GucContext context) | ||
2304 | 2305 | enforce_mask == ENABLE_HASHJOIN) |
2305 | 2306 | mask = enforce_mask; |
2306 | 2307 | else |
2307 | - mask = enforce_mask & current_hint->init_join_mask; | |
2308 | + mask = enforce_mask & current_hint_state->init_join_mask; | |
2308 | 2309 | |
2309 | 2310 | SET_CONFIG_OPTION("enable_nestloop", ENABLE_NESTLOOP); |
2310 | 2311 | SET_CONFIG_OPTION("enable_mergejoin", ENABLE_MERGEJOIN); |
@@ -2448,7 +2449,7 @@ push_hint(HintState *hstate) | ||
2448 | 2449 | HintStateStack = lcons(hstate, HintStateStack); |
2449 | 2450 | |
2450 | 2451 | /* Pushed hint is the one which should be used hereafter. */ |
2451 | - current_hint = hstate; | |
2452 | + current_hint_state = hstate; | |
2452 | 2453 | } |
2453 | 2454 | |
2454 | 2455 | /* Pop a hint from hint stack. Popped hint is automatically discarded. */ |
@@ -2460,15 +2461,15 @@ pop_hint(void) | ||
2460 | 2461 | elog(ERROR, "hint stack is empty"); |
2461 | 2462 | |
2462 | 2463 | /* |
2463 | - * Take a hint at the head from the list, and free it. Switch current_hint | |
2464 | - * to point new head (NULL if the list is empty). | |
2464 | + * Take a hint at the head from the list, and free it. Switch | |
2465 | + * current_hint_state to point new head (NULL if the list is empty). | |
2465 | 2466 | */ |
2466 | 2467 | HintStateStack = list_delete_first(HintStateStack); |
2467 | - HintStateDelete(current_hint); | |
2468 | + HintStateDelete(current_hint_state); | |
2468 | 2469 | if(HintStateStack == NIL) |
2469 | - current_hint = NULL; | |
2470 | + current_hint_state = NULL; | |
2470 | 2471 | else |
2471 | - current_hint = (HintState *) lfirst(list_head(HintStateStack)); | |
2472 | + current_hint_state = (HintState *) lfirst(list_head(HintStateStack)); | |
2472 | 2473 | } |
2473 | 2474 | |
2474 | 2475 | static PlannedStmt * |
@@ -2493,7 +2494,7 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) | ||
2493 | 2494 | /* |
2494 | 2495 | * Use standard planner if pg_hint_plan is disabled or current nesting |
2495 | 2496 | * depth is nesting depth of SPI calls. Other hook functions try to change |
2496 | - * plan with current_hint if any, so set it to NULL. | |
2497 | + * plan with current_hint_state if any, so set it to NULL. | |
2497 | 2498 | */ |
2498 | 2499 | if (!pg_hint_plan_enable_hint || hint_inhibit_level > 0) |
2499 | 2500 | { |
@@ -2589,8 +2590,8 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) | ||
2589 | 2590 | |
2590 | 2591 | /* |
2591 | 2592 | * Use standard planner if the statement has not valid hint. Other hook |
2592 | - * functions try to change plan with current_hint if any, so set it to | |
2593 | - * NULL. | |
2593 | + * functions try to change plan with current_hint_state if any, so set it | |
2594 | + * to NULL. | |
2594 | 2595 | */ |
2595 | 2596 | if (!hstate) |
2596 | 2597 | goto standard_planner_proc; |
@@ -2601,26 +2602,28 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) | ||
2601 | 2602 | push_hint(hstate); |
2602 | 2603 | |
2603 | 2604 | /* Set GUC parameters which are specified with Set hint. */ |
2604 | - save_nestlevel = set_config_options(current_hint->set_hints, | |
2605 | - current_hint->num_hints[HINT_TYPE_SET], | |
2606 | - current_hint->context); | |
2607 | - | |
2605 | + save_nestlevel = | |
2606 | + set_config_options(current_hint_state->set_hints, | |
2607 | + current_hint_state->num_hints[HINT_TYPE_SET], | |
2608 | + current_hint_state->context); | |
2609 | + | |
2610 | + /* save current status to current_hint_state */ | |
2608 | 2611 | if (enable_seqscan) |
2609 | - current_hint->init_scan_mask |= ENABLE_SEQSCAN; | |
2612 | + current_hint_state->init_scan_mask |= ENABLE_SEQSCAN; | |
2610 | 2613 | if (enable_indexscan) |
2611 | - current_hint->init_scan_mask |= ENABLE_INDEXSCAN; | |
2614 | + current_hint_state->init_scan_mask |= ENABLE_INDEXSCAN; | |
2612 | 2615 | if (enable_bitmapscan) |
2613 | - current_hint->init_scan_mask |= ENABLE_BITMAPSCAN; | |
2616 | + current_hint_state->init_scan_mask |= ENABLE_BITMAPSCAN; | |
2614 | 2617 | if (enable_tidscan) |
2615 | - current_hint->init_scan_mask |= ENABLE_TIDSCAN; | |
2618 | + current_hint_state->init_scan_mask |= ENABLE_TIDSCAN; | |
2616 | 2619 | if (enable_indexonlyscan) |
2617 | - current_hint->init_scan_mask |= ENABLE_INDEXONLYSCAN; | |
2620 | + current_hint_state->init_scan_mask |= ENABLE_INDEXONLYSCAN; | |
2618 | 2621 | if (enable_nestloop) |
2619 | - current_hint->init_join_mask |= ENABLE_NESTLOOP; | |
2622 | + current_hint_state->init_join_mask |= ENABLE_NESTLOOP; | |
2620 | 2623 | if (enable_mergejoin) |
2621 | - current_hint->init_join_mask |= ENABLE_MERGEJOIN; | |
2624 | + current_hint_state->init_join_mask |= ENABLE_MERGEJOIN; | |
2622 | 2625 | if (enable_hashjoin) |
2623 | - current_hint->init_join_mask |= ENABLE_HASHJOIN; | |
2626 | + current_hint_state->init_join_mask |= ENABLE_HASHJOIN; | |
2624 | 2627 | |
2625 | 2628 | if (debug_level > 1) |
2626 | 2629 | { |
@@ -2632,8 +2635,8 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) | ||
2632 | 2635 | } |
2633 | 2636 | |
2634 | 2637 | /* |
2635 | - * Use PG_TRY mechanism to recover GUC parameters and current_hint to the | |
2636 | - * state when this planner started when error occurred in planner. | |
2638 | + * Use PG_TRY mechanism to recover GUC parameters and current_hint_state to | |
2639 | + * the state when this planner started when error occurred in planner. | |
2637 | 2640 | */ |
2638 | 2641 | PG_TRY(); |
2639 | 2642 | { |
@@ -2656,9 +2659,9 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) | ||
2656 | 2659 | |
2657 | 2660 | /* Print hint in debug mode. */ |
2658 | 2661 | if (debug_level == 1) |
2659 | - HintStateDump(current_hint); | |
2662 | + HintStateDump(current_hint_state); | |
2660 | 2663 | else if (debug_level > 1) |
2661 | - HintStateDump2(current_hint); | |
2664 | + HintStateDump2(current_hint_state); | |
2662 | 2665 | |
2663 | 2666 | /* |
2664 | 2667 | * Rollback changes of GUC parameters, and pop current hint context from |
@@ -2678,7 +2681,7 @@ standard_planner_proc: | ||
2678 | 2681 | qnostr, msgstr))); |
2679 | 2682 | hidestmt = true; |
2680 | 2683 | } |
2681 | - current_hint = NULL; | |
2684 | + current_hint_state = NULL; | |
2682 | 2685 | if (prev_planner) |
2683 | 2686 | return (*prev_planner) (parse, cursorOptions, boundParams); |
2684 | 2687 | else |
@@ -2709,9 +2712,9 @@ find_scan_hint(PlannerInfo *root, Index relid, RelOptInfo *rel) | ||
2709 | 2712 | return NULL; |
2710 | 2713 | |
2711 | 2714 | /* Find scan method hint, which matches given names, from the list. */ |
2712 | - for (i = 0; i < current_hint->num_hints[HINT_TYPE_SCAN_METHOD]; i++) | |
2715 | + for (i = 0; i < current_hint_state->num_hints[HINT_TYPE_SCAN_METHOD]; i++) | |
2713 | 2716 | { |
2714 | - ScanMethodHint *hint = current_hint->scan_hints[i]; | |
2717 | + ScanMethodHint *hint = current_hint_state->scan_hints[i]; | |
2715 | 2718 | |
2716 | 2719 | /* We ignore disabled hints. */ |
2717 | 2720 | if (!hint_state_enabled(hint)) |
@@ -2821,11 +2824,11 @@ delete_indexes(ScanMethodHint *hint, RelOptInfo *rel, Oid relationObjectId) | ||
2821 | 2824 | |
2822 | 2825 | /* |
2823 | 2826 | * to make the index a candidate when definition of this index is |
2824 | - * matched with the index's definition of current_hint. | |
2827 | + * matched with the index's definition of current_hint_state. | |
2825 | 2828 | */ |
2826 | 2829 | if (OidIsValid(relationObjectId) && !use_index) |
2827 | 2830 | { |
2828 | - foreach(l, current_hint->parent_index_infos) | |
2831 | + foreach(l, current_hint_state->parent_index_infos) | |
2829 | 2832 | { |
2830 | 2833 | int i; |
2831 | 2834 | HeapTuple ht_idx; |
@@ -3103,7 +3106,7 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3103 | 3106 | * Do nothing if we don't have a valid hint in this context or current |
3104 | 3107 | * nesting depth is at SPI calls. |
3105 | 3108 | */ |
3106 | - if (!current_hint || hint_inhibit_level > 0) | |
3109 | + if (!current_hint_state || hint_inhibit_level > 0) | |
3107 | 3110 | { |
3108 | 3111 | if (debug_level > 1) |
3109 | 3112 | ereport(pg_hint_plan_message_level, |
@@ -3113,7 +3116,8 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3113 | 3116 | " current_hint=%p, hint_inhibit_level=%d", |
3114 | 3117 | qnostr, relationObjectId, |
3115 | 3118 | get_rel_name(relationObjectId), |
3116 | - inhparent, current_hint, hint_inhibit_level))); | |
3119 | + inhparent, current_hint_state, | |
3120 | + hint_inhibit_level))); | |
3117 | 3121 | return; |
3118 | 3122 | } |
3119 | 3123 |
@@ -3131,10 +3135,10 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3131 | 3135 | (errhidestmt(true), |
3132 | 3136 | errmsg ("pg_hint_plan%s: get_relation_info" |
3133 | 3137 | " skipping inh parent: relation=%u(%s), inhparent=%d," |
3134 | - " current_hint=%p, hint_inhibit_level=%d", | |
3138 | + " current_hint_state=%p, hint_inhibit_level=%d", | |
3135 | 3139 | qnostr, relationObjectId, |
3136 | 3140 | get_rel_name(relationObjectId), |
3137 | - inhparent, current_hint, hint_inhibit_level))); | |
3141 | + inhparent, current_hint_state, hint_inhibit_level))); | |
3138 | 3142 | return; |
3139 | 3143 | } |
3140 | 3144 |
@@ -3145,7 +3149,7 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3145 | 3149 | |
3146 | 3150 | if (appinfo->child_relid == rel->relid) |
3147 | 3151 | { |
3148 | - if (current_hint->parent_relid != appinfo->parent_relid) | |
3152 | + if (current_hint_state->parent_relid != appinfo->parent_relid) | |
3149 | 3153 | new_parent_relid = appinfo->parent_relid; |
3150 | 3154 | break; |
3151 | 3155 | } |
@@ -3153,9 +3157,9 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3153 | 3157 | |
3154 | 3158 | if (!l) |
3155 | 3159 | { |
3156 | - /* This relation doesn't have a parent. Cancel current_hint. */ | |
3157 | - current_hint->parent_relid = 0; | |
3158 | - current_hint->parent_hint = NULL; | |
3160 | + /* This relation doesn't have a parent. Cancel current_hint_state. */ | |
3161 | + current_hint_state->parent_relid = 0; | |
3162 | + current_hint_state->parent_hint = NULL; | |
3159 | 3163 | } |
3160 | 3164 | |
3161 | 3165 | if (new_parent_relid > 0) |
@@ -3165,22 +3169,22 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3165 | 3169 | * Remember it, apply the scan mask of it and then resolve the index |
3166 | 3170 | * restriction in order to be used by its children. |
3167 | 3171 | */ |
3168 | - int scanmask = current_hint->init_scan_mask; | |
3172 | + int scanmask = current_hint_state->init_scan_mask; | |
3169 | 3173 | ScanMethodHint *parent_hint; |
3170 | 3174 | |
3171 | - current_hint->parent_relid = new_parent_relid; | |
3175 | + current_hint_state->parent_relid = new_parent_relid; | |
3172 | 3176 | |
3173 | 3177 | /* |
3174 | 3178 | * Get and apply the hint for the new parent relation. It should be an |
3175 | 3179 | * ordinary relation so calling find_scan_hint with rel == NULL is |
3176 | 3180 | * safe. |
3177 | 3181 | */ |
3178 | - current_hint->parent_hint = parent_hint = | |
3179 | - find_scan_hint(root, current_hint->parent_relid, NULL); | |
3182 | + current_hint_state->parent_hint = parent_hint = | |
3183 | + find_scan_hint(root, current_hint_state->parent_relid, NULL); | |
3180 | 3184 | |
3181 | 3185 | if (parent_hint) |
3182 | 3186 | { |
3183 | - scanmask = current_hint->parent_hint->enforce_mask; | |
3187 | + scanmask = current_hint_state->parent_hint->enforce_mask; | |
3184 | 3188 | parent_hint->base.state = HINT_STATE_USED; |
3185 | 3189 | |
3186 | 3190 | /* Resolve index name mask (if any) using the parent. */ |
@@ -3190,7 +3194,7 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3190 | 3194 | Relation parent_rel; |
3191 | 3195 | |
3192 | 3196 | parentrel_oid = |
3193 | - root->simple_rte_array[current_hint->parent_relid]->relid; | |
3197 | + root->simple_rte_array[current_hint_state->parent_relid]->relid; | |
3194 | 3198 | parent_rel = heap_open(parentrel_oid, NoLock); |
3195 | 3199 | |
3196 | 3200 | /* Search the parent relation for indexes match the hint spec */ |
@@ -3211,19 +3215,19 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3211 | 3215 | |
3212 | 3216 | parent_index_info = |
3213 | 3217 | get_parent_index_info(indexoid, parentrel_oid); |
3214 | - current_hint->parent_index_infos = | |
3215 | - lappend(current_hint->parent_index_infos, parent_index_info); | |
3218 | + current_hint_state->parent_index_infos = | |
3219 | + lappend(current_hint_state->parent_index_infos, parent_index_info); | |
3216 | 3220 | } |
3217 | 3221 | heap_close(parent_rel, NoLock); |
3218 | 3222 | } |
3219 | 3223 | } |
3220 | 3224 | |
3221 | - set_scan_config_options(scanmask, current_hint->context); | |
3225 | + set_scan_config_options(scanmask, current_hint_state->context); | |
3222 | 3226 | } |
3223 | 3227 | |
3224 | - if (current_hint->parent_hint != 0) | |
3228 | + if (current_hint_state->parent_hint != 0) | |
3225 | 3229 | { |
3226 | - delete_indexes(current_hint->parent_hint, rel, | |
3230 | + delete_indexes(current_hint_state->parent_hint, rel, | |
3227 | 3231 | relationObjectId); |
3228 | 3232 | |
3229 | 3233 | /* Scan fixation status is the same to the parent. */ |
@@ -3232,18 +3236,19 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3232 | 3236 | (errhidestmt(true), |
3233 | 3237 | errmsg("pg_hint_plan%s: get_relation_info:" |
3234 | 3238 | " index deletion by parent hint: " |
3235 | - "relation=%u(%s), inhparent=%d, current_hint=%p," | |
3239 | + "relation=%u(%s), inhparent=%d, current_hint_state=%p," | |
3236 | 3240 | " hint_inhibit_level=%d", |
3237 | 3241 | qnostr, relationObjectId, |
3238 | 3242 | get_rel_name(relationObjectId), |
3239 | - inhparent, current_hint, hint_inhibit_level))); | |
3243 | + inhparent, current_hint_state, hint_inhibit_level))); | |
3240 | 3244 | return; |
3241 | 3245 | } |
3242 | 3246 | |
3243 | 3247 | /* This table doesn't have a parent hint. Apply its own hint if any. */ |
3244 | 3248 | if ((hint = find_scan_hint(root, rel->relid, rel)) != NULL) |
3245 | 3249 | { |
3246 | - set_scan_config_options(hint->enforce_mask, current_hint->context); | |
3250 | + set_scan_config_options(hint->enforce_mask, | |
3251 | + current_hint_state->context); | |
3247 | 3252 | hint->base.state = HINT_STATE_USED; |
3248 | 3253 | |
3249 | 3254 | delete_indexes(hint, rel, InvalidOid); |
@@ -3257,7 +3262,7 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3257 | 3262 | " hint_inhibit_level=%d, scanmask=0x%x", |
3258 | 3263 | qnostr, relationObjectId, |
3259 | 3264 | get_rel_name(relationObjectId), |
3260 | - inhparent, current_hint, hint_inhibit_level, | |
3265 | + inhparent, current_hint_state, hint_inhibit_level, | |
3261 | 3266 | hint->enforce_mask))); |
3262 | 3267 | } |
3263 | 3268 | else |
@@ -3271,10 +3276,10 @@ pg_hint_plan_get_relation_info(PlannerInfo *root, Oid relationObjectId, | ||
3271 | 3276 | " hint_inhibit_level=%d, scanmask=0x%x", |
3272 | 3277 | qnostr, relationObjectId, |
3273 | 3278 | get_rel_name(relationObjectId), |
3274 | - inhparent, current_hint, hint_inhibit_level, | |
3275 | - current_hint->init_scan_mask))); | |
3276 | - set_scan_config_options(current_hint->init_scan_mask, | |
3277 | - current_hint->context); | |
3279 | + inhparent, current_hint_state, hint_inhibit_level, | |
3280 | + current_hint_state->init_scan_mask))); | |
3281 | + set_scan_config_options(current_hint_state->init_scan_mask, | |
3282 | + current_hint_state->context); | |
3278 | 3283 | } |
3279 | 3284 | return; |
3280 | 3285 | } |
@@ -3346,7 +3351,7 @@ find_join_hint(Relids joinrelids) | ||
3346 | 3351 | List *join_hint; |
3347 | 3352 | ListCell *l; |
3348 | 3353 | |
3349 | - join_hint = current_hint->join_hint_level[bms_num_members(joinrelids)]; | |
3354 | + join_hint = current_hint_state->join_hint_level[bms_num_members(joinrelids)]; | |
3350 | 3355 | |
3351 | 3356 | foreach(l, join_hint) |
3352 | 3357 | { |
@@ -3715,7 +3720,7 @@ transform_join_hints(HintState *hstate, PlannerInfo *root, int nbaserel, | ||
3715 | 3720 | |
3716 | 3721 | if (hint_state_enabled(lhint)) |
3717 | 3722 | { |
3718 | - set_join_config_options(DISABLE_ALL_JOIN, current_hint->context); | |
3723 | + set_join_config_options(DISABLE_ALL_JOIN, current_hint_state->context); | |
3719 | 3724 | return true; |
3720 | 3725 | } |
3721 | 3726 | return false; |
@@ -3752,6 +3757,10 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) | ||
3752 | 3757 | create_tidscan_paths(root, rel); |
3753 | 3758 | } |
3754 | 3759 | |
3760 | +/* | |
3761 | + * Clear exiting access paths and create new ones applying hints. | |
3762 | + * This does the similar to set_rel_pathlist | |
3763 | + */ | |
3755 | 3764 | static void |
3756 | 3765 | rebuild_scan_path(HintState *hstate, PlannerInfo *root, int level, |
3757 | 3766 | List *initial_rels) |
@@ -3834,7 +3843,8 @@ make_join_rel_wrapper(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2) | ||
3834 | 3843 | { |
3835 | 3844 | save_nestlevel = NewGUCNestLevel(); |
3836 | 3845 | |
3837 | - set_join_config_options(hint->enforce_mask, current_hint->context); | |
3846 | + set_join_config_options(hint->enforce_mask, | |
3847 | + current_hint_state->context); | |
3838 | 3848 | |
3839 | 3849 | rel = pg_hint_plan_make_join_rel(root, rel1, rel2); |
3840 | 3850 | hint->base.state = HINT_STATE_USED; |
@@ -3869,7 +3879,8 @@ add_paths_to_joinrel_wrapper(PlannerInfo *root, | ||
3869 | 3879 | |
3870 | 3880 | if ((scan_hint = find_scan_hint(root, innerrel->relid, innerrel)) != NULL) |
3871 | 3881 | { |
3872 | - set_scan_config_options(scan_hint->enforce_mask, current_hint->context); | |
3882 | + set_scan_config_options(scan_hint->enforce_mask, | |
3883 | + current_hint_state->context); | |
3873 | 3884 | scan_hint->base.state = HINT_STATE_USED; |
3874 | 3885 | } |
3875 | 3886 |
@@ -3885,7 +3896,7 @@ add_paths_to_joinrel_wrapper(PlannerInfo *root, | ||
3885 | 3896 | { |
3886 | 3897 | |
3887 | 3898 | set_join_config_options(join_hint->enforce_mask, |
3888 | - current_hint->context); | |
3899 | + current_hint_state->context); | |
3889 | 3900 | |
3890 | 3901 | add_paths_to_joinrel(root, joinrel, outerrel, innerrel, jointype, |
3891 | 3902 | sjinfo, restrictlist); |
@@ -3893,7 +3904,8 @@ add_paths_to_joinrel_wrapper(PlannerInfo *root, | ||
3893 | 3904 | } |
3894 | 3905 | else |
3895 | 3906 | { |
3896 | - set_join_config_options(DISABLE_ALL_JOIN, current_hint->context); | |
3907 | + set_join_config_options(DISABLE_ALL_JOIN, | |
3908 | + current_hint_state->context); | |
3897 | 3909 | add_paths_to_joinrel(root, joinrel, outerrel, innerrel, jointype, |
3898 | 3910 | sjinfo, restrictlist); |
3899 | 3911 | } |
@@ -3908,8 +3920,8 @@ add_paths_to_joinrel_wrapper(PlannerInfo *root, | ||
3908 | 3920 | sjinfo, restrictlist); |
3909 | 3921 | |
3910 | 3922 | if (scan_hint != NULL) |
3911 | - set_scan_config_options(current_hint->init_scan_mask, | |
3912 | - current_hint->context); | |
3923 | + set_scan_config_options(current_hint_state->init_scan_mask, | |
3924 | + current_hint_state->context); | |
3913 | 3925 | } |
3914 | 3926 | |
3915 | 3927 | static int |
@@ -3951,7 +3963,7 @@ pg_hint_plan_join_search(PlannerInfo *root, int levels_needed, | ||
3951 | 3963 | * valid hint is supplied or current nesting depth is nesting depth of SPI |
3952 | 3964 | * calls. |
3953 | 3965 | */ |
3954 | - if (!current_hint || hint_inhibit_level > 0) | |
3966 | + if (!current_hint_state || hint_inhibit_level > 0) | |
3955 | 3967 | { |
3956 | 3968 | if (prev_join_search) |
3957 | 3969 | return (*prev_join_search) (root, levels_needed, initial_rels); |
@@ -3961,8 +3973,8 @@ pg_hint_plan_join_search(PlannerInfo *root, int levels_needed, | ||
3961 | 3973 | return standard_join_search(root, levels_needed, initial_rels); |
3962 | 3974 | } |
3963 | 3975 | |
3964 | - /* We apply scan method hint rebuild scan path. */ | |
3965 | - rebuild_scan_path(current_hint, root, levels_needed, initial_rels); | |
3976 | + /* apply scan method hint rebuild scan path. */ | |
3977 | + rebuild_scan_path(current_hint_state, root, levels_needed, initial_rels); | |
3966 | 3978 | |
3967 | 3979 | /* |
3968 | 3980 | * In the case using GEQO, only scan method hints and Set hints have |
@@ -3972,29 +3984,31 @@ pg_hint_plan_join_search(PlannerInfo *root, int levels_needed, | ||
3972 | 3984 | return geqo(root, levels_needed, initial_rels); |
3973 | 3985 | |
3974 | 3986 | nbaserel = get_num_baserels(initial_rels); |
3975 | - current_hint->join_hint_level = palloc0(sizeof(List *) * (nbaserel + 1)); | |
3987 | + current_hint_state->join_hint_level = | |
3988 | + palloc0(sizeof(List *) * (nbaserel + 1)); | |
3976 | 3989 | join_method_hints = palloc0(sizeof(JoinMethodHint *) * (nbaserel + 1)); |
3977 | 3990 | |
3978 | - leading_hint_enable = transform_join_hints(current_hint, root, nbaserel, | |
3991 | + leading_hint_enable = transform_join_hints(current_hint_state, | |
3992 | + root, nbaserel, | |
3979 | 3993 | initial_rels, join_method_hints); |
3980 | 3994 | |
3981 | 3995 | rel = pg_hint_plan_standard_join_search(root, levels_needed, initial_rels); |
3982 | 3996 | |
3983 | 3997 | for (i = 2; i <= nbaserel; i++) |
3984 | 3998 | { |
3985 | - list_free(current_hint->join_hint_level[i]); | |
3999 | + list_free(current_hint_state->join_hint_level[i]); | |
3986 | 4000 | |
3987 | 4001 | /* free Leading hint only */ |
3988 | 4002 | if (join_method_hints[i] != NULL && |
3989 | 4003 | join_method_hints[i]->enforce_mask == ENABLE_ALL_JOIN) |
3990 | 4004 | JoinMethodHintDelete(join_method_hints[i]); |
3991 | 4005 | } |
3992 | - pfree(current_hint->join_hint_level); | |
4006 | + pfree(current_hint_state->join_hint_level); | |
3993 | 4007 | pfree(join_method_hints); |
3994 | 4008 | |
3995 | 4009 | if (leading_hint_enable) |
3996 | - set_join_config_options(current_hint->init_join_mask, | |
3997 | - current_hint->context); | |
4010 | + set_join_config_options(current_hint_state->init_join_mask, | |
4011 | + current_hint_state->context); | |
3998 | 4012 | |
3999 | 4013 | return rel; |
4000 | 4014 | } |