1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

pg_plan_advice: Disallow empty sublists within JOIN_ORDER()

Commit 8c9c2e5c09 fixed a similar
issue for FOREIGN_JOIN(). Handle this case similar to the way that
commit handled that case.

Backpatch-through: 19
Discussion: https://postgr.es/m/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
This commit is contained in:
Robert Haas
2026-09-16 14:44:42 -04:00
parent fcc0e27f45
commit 5e595d659f
3 changed files with 17 additions and 0 deletions

View File

@@ -212,6 +212,13 @@ DETAIL: Could not parse advice: FOREIGN_JOIN targets must contain more than one
SET pg_plan_advice.advice = 'FOREIGN_JOIN(())';
ERROR: invalid value for parameter "pg_plan_advice.advice": "FOREIGN_JOIN(())"
DETAIL: Could not parse advice: FOREIGN_JOIN targets must contain more than one relation identifier at or near ")"
-- Join order requires at least one relation identifier.
SET pg_plan_advice.advice = 'JOIN_ORDER(())';
ERROR: invalid value for parameter "pg_plan_advice.advice": "JOIN_ORDER(())"
DETAIL: Could not parse advice: JOIN_ORDER targets must contain at least one relation identifier at or near ")"
SET pg_plan_advice.advice = 'JOIN_ORDER(a ({}))';
ERROR: invalid value for parameter "pg_plan_advice.advice": "JOIN_ORDER(a ({}))"
DETAIL: Could not parse advice: JOIN_ORDER targets must contain at least one relation identifier at or near "}"
-- Tag keywords used as alias names work fine, because the 'identifier'
-- nonterminal accepts all token types.
SET pg_plan_advice.advice = 'SEQ_SCAN(hash_join)';

View File

@@ -257,12 +257,18 @@ join_order_sublist:
$$ = palloc0_object(pgpa_advice_target);
$$->ttype = PGPA_TARGET_ORDERED_LIST;
$$->children = $2;
if ($2 == NIL)
pgpa_yyerror(result, parse_error_msg_p, yyscanner,
"JOIN_ORDER targets must contain at least one relation identifier");
}
| '{' simple_target_list '}'
{
$$ = palloc0_object(pgpa_advice_target);
$$->ttype = PGPA_TARGET_UNORDERED_LIST;
$$->children = $2;
if ($2 == NIL)
pgpa_yyerror(result, parse_error_msg_p, yyscanner,
"JOIN_ORDER targets must contain at least one relation identifier");
}
;

View File

@@ -75,6 +75,10 @@ SET pg_plan_advice.advice = 'FOREIGN_JOIN(a)';
SET pg_plan_advice.advice = 'FOREIGN_JOIN((a))';
SET pg_plan_advice.advice = 'FOREIGN_JOIN(())';
-- Join order requires at least one relation identifier.
SET pg_plan_advice.advice = 'JOIN_ORDER(())';
SET pg_plan_advice.advice = 'JOIN_ORDER(a ({}))';
-- Tag keywords used as alias names work fine, because the 'identifier'
-- nonterminal accepts all token types.
SET pg_plan_advice.advice = 'SEQ_SCAN(hash_join)';