• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision05d59100f97804d0fe24c67900959fcc989c08a8 (tree)
Time2020-07-14 17:35:23
AuthorDaniil Anisimov <anisimow.d@gmai...>
CommiterKyotaro Horiguchi

Log Message

Fix segfault when use Set, Rows and Parallel hints together

Change Summary

Incremental Difference

--- a/expected/pg_hint_plan.out
+++ b/expected/pg_hint_plan.out
@@ -9085,3 +9085,34 @@ error hint:
90859085 ----+-----
90869086 (0 rows)
90879087
9088+-- all hint types together
9089+/*+ SeqScan(t1) MergeJoin(t1 t2) Leading(t1 t2) Rows(t1 t2 +10) Parallel(t1 8 hard) Set(random_page_cost 2.0)*/
9090+EXPLAIN (costs off) SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);
9091+DEBUG: adjusted rows 1000 to 1010
9092+DEBUG: pg_hint_plan:
9093+used hint:
9094+SeqScan(t1)
9095+MergeJoin(t1 t2)
9096+Leading(t1 t2)
9097+Set(random_page_cost 2.0)
9098+Rows(t1 t2 +10)
9099+Parallel(t1 8 hard)
9100+not used hint:
9101+duplication hint:
9102+error hint:
9103+
9104+ QUERY PLAN
9105+-------------------------------------------------
9106+ Nested Loop
9107+ -> Merge Join
9108+ Merge Cond: (t2.id = t1.id)
9109+ -> Index Scan using t2_pkey on t2
9110+ -> Sort
9111+ Sort Key: t1.id
9112+ -> Gather
9113+ Workers Planned: 8
9114+ -> Parallel Seq Scan on t1
9115+ -> Index Scan using t3_pkey on t3
9116+ Index Cond: (id = t1.id)
9117+(11 rows)
9118+
--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -2079,7 +2079,7 @@ create_hintstate(Query *parse, const char *hints)
20792079 hstate->num_hints[HINT_TYPE_LEADING]);
20802080 hstate->rows_hints = (RowsHint **) (hstate->set_hints +
20812081 hstate->num_hints[HINT_TYPE_SET]);
2082- hstate->parallel_hints = (ParallelHint **) (hstate->set_hints +
2082+ hstate->parallel_hints = (ParallelHint **) (hstate->rows_hints +
20832083 hstate->num_hints[HINT_TYPE_ROWS]);
20842084
20852085 return hstate;
--- a/sql/pg_hint_plan.sql
+++ b/sql/pg_hint_plan.sql
@@ -1138,3 +1138,6 @@ set pg_hint_plan.parse_messages to 'NOTICE';
11381138 /*+ SeqScan( */ SELECT 1;
11391139 /*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
11401140
1141+-- all hint types together
1142+/*+ SeqScan(t1) MergeJoin(t1 t2) Leading(t1 t2) Rows(t1 t2 +10) Parallel(t1 8 hard) Set(random_page_cost 2.0)*/
1143+EXPLAIN (costs off) SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);
Show on old repository browser