OSDN Git Service

Stabilize regression test.
[pghintplan/pg_hint_plan.git] / pg_hint_plan.c
index d9e5c62..a9075f4 100644 (file)
@@ -930,7 +930,7 @@ ParallelHintCreate(const char *hint_str, const char *keyword,
 {
        ParallelHint *hint;
 
-       hint = palloc(sizeof(ScanMethodHint));
+       hint = palloc(sizeof(ParallelHint));
        hint->base.hint_str = hint_str;
        hint->base.keyword = keyword;
        hint->base.hint_keyword = hint_keyword;
@@ -3010,7 +3010,8 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
         * Support for nested plpgsql functions. This is quite ugly but this is the
         * only point I could find where I can get the query string.
         */
-       if (plpgsql_recurse_level > 0)
+       if (plpgsql_recurse_level > 0 &&
+               error_context_stack && error_context_stack->arg)
        {
                MemoryContext oldcontext;
 
@@ -3078,19 +3079,19 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
        }
 
        /*
+        * The planner call below may replace current_hint_str. Store and restore
+        * it so that the subsequent planning in the upper level doesn't get
+        * confused.
+        */
+       recurse_level++;
+       prev_hint_str = current_hint_str;
+       
+       /*
         * Use PG_TRY mechanism to recover GUC parameters and current_hint_state to
         * the state when this planner started when error occurred in planner.
         */
        PG_TRY();
        {
-               /*
-                * The planner call below may replace current_hint_str. Store and
-                * restore it so that the subsequent planning in the upper level
-                * doesn't get confused.
-                */
-               recurse_level++;
-               prev_hint_str = current_hint_str;
-
                if (prev_planner)
                        result = (*prev_planner) (parse, cursorOptions, boundParams);
                else