]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
pg_plan_advice: DO_NOT_SCAN is a simple tag, not a generic one.
authorRobert Haas <rhaas@postgresql.org>
Fri, 29 May 2026 17:51:09 +0000 (13:51 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 29 May 2026 17:51:09 +0000 (13:51 -0400)
Generic tags allow sublists, e.g. MERGE_JOIN((x y)), but simple
tags do not, e.g. SEQ_SCAN(x) is valid but SEQ_SCAN((x)) is not.
DO_NOT_SCAN was intended to be simple tag, but was accidentally
implemented as a generic one. This could result in assertion
failures. Repair.

Reported-by: Nikita Kalinin <n.kalinin@postgrespro.ru>
Analyzed-by: Tender Wang <tndrwang@gmail.com>
Analyzed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: http://postgr.es/m/19493-5878eac7a2525c23@postgresql.org

contrib/pg_plan_advice/expected/syntax.out
contrib/pg_plan_advice/pgpa_parser.y
contrib/pg_plan_advice/pgpa_scanner.l
contrib/pg_plan_advice/sql/syntax.sql

index c3f2cbd6dca84d009ab82c316642a32a641e14ff..c61fd73a38559644f0d37f1f3bcc4706d4adf13d 100644 (file)
@@ -126,6 +126,9 @@ DETAIL:  Could not parse advice: syntax error at or near "123"
 SET pg_plan_advice.advice = 'SEQ_SCAN((x))';
 ERROR:  invalid value for parameter "pg_plan_advice.advice": "SEQ_SCAN((x))"
 DETAIL:  Could not parse advice: syntax error at or near "("
+SET pg_plan_advice.advice = 'DO_NOT_SCAN((x))';
+ERROR:  invalid value for parameter "pg_plan_advice.advice": "DO_NOT_SCAN((x))"
+DETAIL:  Could not parse advice: syntax error at or near "("
 SET pg_plan_advice.advice = 'GATHER(((x)))';
 ERROR:  invalid value for parameter "pg_plan_advice.advice": "GATHER(((x)))"
 DETAIL:  Could not parse advice: syntax error at or near "("
index 598974d3f226d08197e190f23a20743816916a36..5811a6e5e56c51601bed263fd06b55298d6e01c9 100644 (file)
@@ -106,6 +106,8 @@ advice_item: TOK_TAG_JOIN_ORDER '(' join_order_target_list ')'
                        $$ = palloc0_object(pgpa_advice_item);
                        if (strcmp($1, "bitmap_heap_scan") == 0)
                                $$->tag = PGPA_TAG_BITMAP_HEAP_SCAN;
+                       else if (strcmp($1, "do_not_scan") == 0)
+                               $$->tag = PGPA_TAG_DO_NOT_SCAN;
                        else if (strcmp($1, "no_gather") == 0)
                                $$->tag = PGPA_TAG_NO_GATHER;
                        else if (strcmp($1, "seq_scan") == 0)
index 3b3be6eb7276b960af9e6791e605f367226eed65..e6d60f57e1e3ade589484bddaa050524203cf1a2 100644 (file)
@@ -128,7 +128,8 @@ xcinside            [^*/]+
                                        else if (tag == PGPA_TAG_SEQ_SCAN ||
                                                         tag == PGPA_TAG_TID_SCAN ||
                                                         tag == PGPA_TAG_BITMAP_HEAP_SCAN ||
-                                                        tag == PGPA_TAG_NO_GATHER)
+                                                        tag == PGPA_TAG_NO_GATHER ||
+                                                        tag == PGPA_TAG_DO_NOT_SCAN)
                                                return TOK_TAG_SIMPLE;
                                        else
                                                return TOK_TAG_GENERIC;
index f274fa4863657ddfbaaf3b697a0a2548a8ac9fb3..3f94b5f8bf3c6def6fb571e96368ab3b14b2fb05 100644 (file)
@@ -41,6 +41,7 @@ SET pg_plan_advice.advice = '123';
 -- except for JOIN_ORDER, allow at most one level of sublist. Hence, these
 -- examples should error out.
 SET pg_plan_advice.advice = 'SEQ_SCAN((x))';
+SET pg_plan_advice.advice = 'DO_NOT_SCAN((x))';
 SET pg_plan_advice.advice = 'GATHER(((x)))';
 
 -- Legal comments.