OSDN Git Service

Fix segfault when use Set, Rows and Parallel hints together
authorDaniil Anisimov <anisimow.d@gmail.com>
Mon, 16 Mar 2020 08:11:12 +0000 (15:11 +0700)
committerKyotaro Horiguchi <horikyota.ntt@gmail.com>
Tue, 14 Jul 2020 08:35:23 +0000 (17:35 +0900)
expected/pg_hint_plan.out
pg_hint_plan.c
sql/pg_hint_plan.sql

index aa1e7c2..1f29b25 100644 (file)
@@ -9085,3 +9085,34 @@ error hint:
 ----+-----
 (0 rows)
 
+-- all hint types together
+/*+ SeqScan(t1) MergeJoin(t1 t2) Leading(t1 t2) Rows(t1 t2 +10) Parallel(t1 8 hard) Set(random_page_cost 2.0)*/
+EXPLAIN (costs off) SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);
+DEBUG:  adjusted rows 1000 to 1010
+DEBUG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+MergeJoin(t1 t2)
+Leading(t1 t2)
+Set(random_page_cost 2.0)
+Rows(t1 t2 +10)
+Parallel(t1 8 hard)
+not used hint:
+duplication hint:
+error hint:
+
+                   QUERY PLAN                    
+-------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t2.id = t1.id)
+         ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t1.id
+               ->  Gather
+                     Workers Planned: 8
+                     ->  Parallel Seq Scan on t1
+   ->  Index Scan using t3_pkey on t3
+         Index Cond: (id = t1.id)
+(11 rows)
+
index 43ac931..e34bded 100644 (file)
@@ -2079,7 +2079,7 @@ create_hintstate(Query *parse, const char *hints)
                hstate->num_hints[HINT_TYPE_LEADING]);
        hstate->rows_hints = (RowsHint **) (hstate->set_hints +
                hstate->num_hints[HINT_TYPE_SET]);
-       hstate->parallel_hints = (ParallelHint **) (hstate->set_hints +
+       hstate->parallel_hints = (ParallelHint **) (hstate->rows_hints +
                hstate->num_hints[HINT_TYPE_ROWS]);
 
        return hstate;
index 85e37a3..7309e1e 100644 (file)
@@ -1138,3 +1138,6 @@ set pg_hint_plan.parse_messages to 'NOTICE';
 /*+ SeqScan( */ SELECT 1;
 /*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
 
+-- all hint types together
+/*+ SeqScan(t1) MergeJoin(t1 t2) Leading(t1 t2) Rows(t1 t2 +10) Parallel(t1 8 hard) Set(random_page_cost 2.0)*/
+EXPLAIN (costs off) SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);