mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Fix empty FOREIGN_JOIN sublist validation
FOREIGN_JOIN target sublists must contain at least two relation identifiers. However, the parser checked only for sublists with exactly one identifier, so FOREIGN_JOIN(()) was accepted. Reject sublists with fewer than two relation identifiers, and add regression coverage. Author: Chao Li <lic@highgo.com> Discussion: http://postgr.es/m/BEDC04E0-6732-4310-95BA-6EC34BC1442C@gmail.com
This commit is contained in:
@@ -209,6 +209,9 @@ DETAIL: Could not parse advice: FOREIGN_JOIN targets must contain more than one
|
||||
SET pg_plan_advice.advice = 'FOREIGN_JOIN((a))';
|
||||
ERROR: invalid value for parameter "pg_plan_advice.advice": "FOREIGN_JOIN((a))"
|
||||
DETAIL: Could not parse advice: FOREIGN_JOIN targets must contain more than one relation identifier at or near ")"
|
||||
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 ")"
|
||||
-- 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)';
|
||||
|
||||
@@ -135,7 +135,7 @@ advice_item: TOK_TAG_JOIN_ORDER '(' join_order_target_list ')'
|
||||
foreach_ptr(pgpa_advice_target, target, $3)
|
||||
{
|
||||
if (target->ttype == PGPA_TARGET_IDENTIFIER ||
|
||||
list_length(target->children) == 1)
|
||||
list_length(target->children) < 2)
|
||||
pgpa_yyerror(result, parse_error_msg_p, yyscanner,
|
||||
"FOREIGN_JOIN targets must contain more than one relation identifier");
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ SET pg_plan_advice.advice = '/*/* stuff */*/';
|
||||
-- Foreign join requires multiple relation identifiers.
|
||||
SET pg_plan_advice.advice = 'FOREIGN_JOIN(a)';
|
||||
SET pg_plan_advice.advice = 'FOREIGN_JOIN((a))';
|
||||
SET pg_plan_advice.advice = 'FOREIGN_JOIN(())';
|
||||
|
||||
-- Tag keywords used as alias names work fine, because the 'identifier'
|
||||
-- nonterminal accepts all token types.
|
||||
|
||||
Reference in New Issue
Block a user