• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision96a53290f63b65449e48225db7256c1fee5ed79f (tree)
Time2020-07-14 17:30:56
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
@@ -9135,3 +9135,34 @@ error hint:
91359135 ----+-----
91369136 (0 rows)
91379137
9138+-- all hint types together
9139+/*+ SeqScan(t1) MergeJoin(t1 t2) Leading(t1 t2) Rows(t1 t2 +10) Parallel(t1 8 hard) Set(random_page_cost 2.0)*/
9140+EXPLAIN (costs off) SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);
9141+DEBUG: adjusted rows 1000 to 1010
9142+DEBUG: pg_hint_plan:
9143+used hint:
9144+SeqScan(t1)
9145+MergeJoin(t1 t2)
9146+Leading(t1 t2)
9147+Set(random_page_cost 2.0)
9148+Rows(t1 t2 +10)
9149+Parallel(t1 8 hard)
9150+not used hint:
9151+duplication hint:
9152+error hint:
9153+
9154+ QUERY PLAN
9155+-------------------------------------------------
9156+ Nested Loop
9157+ -> Merge Join
9158+ Merge Cond: (t2.id = t1.id)
9159+ -> Index Scan using t2_pkey on t2
9160+ -> Sort
9161+ Sort Key: t1.id
9162+ -> Gather
9163+ Workers Planned: 8
9164+ -> Parallel Seq Scan on t1
9165+ -> Index Scan using t3_pkey on t3
9166+ Index Cond: (id = t1.id)
9167+(11 rows)
9168+
--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -2083,7 +2083,7 @@ create_hintstate(Query *parse, const char *hints)
20832083 hstate->num_hints[HINT_TYPE_LEADING]);
20842084 hstate->rows_hints = (RowsHint **) (hstate->set_hints +
20852085 hstate->num_hints[HINT_TYPE_SET]);
2086- hstate->parallel_hints = (ParallelHint **) (hstate->set_hints +
2086+ hstate->parallel_hints = (ParallelHint **) (hstate->rows_hints +
20872087 hstate->num_hints[HINT_TYPE_ROWS]);
20882088
20892089 return hstate;
--- a/sql/pg_hint_plan.sql
+++ b/sql/pg_hint_plan.sql
@@ -1141,3 +1141,6 @@ set pg_hint_plan.parse_messages to 'NOTICE';
11411141 /*+ SeqScan( */ SELECT 1;
11421142 /*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
11431143
1144+-- all hint types together
1145+/*+ SeqScan(t1) MergeJoin(t1 t2) Leading(t1 t2) Rows(t1 t2 +10) Parallel(t1 8 hard) Set(random_page_cost 2.0)*/
1146+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