mirror of
https://github.com/postgres/postgres.git
synced 2025-07-17 06:41:09 +03:00
Fix MERGE's test for unreachable WHEN clauses.
The former code would only detect an unreachable WHEN clause if it had an AND condition. Fix, so that unreachable unconditional WHEN clauses are also detected. Back-patch to v15, where MERGE was added. Discussion: https://postgr.es/m/CAEZATCVQ=7E2z4cSBB49jjeGGsB6WeoYQY32NDeSvcHiLUZ=ow@mail.gmail.com
This commit is contained in:
@ -155,12 +155,12 @@ transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
|
||||
/*
|
||||
* Check for unreachable WHEN clauses
|
||||
*/
|
||||
if (mergeWhenClause->condition == NULL)
|
||||
is_terminal[when_type] = true;
|
||||
else if (is_terminal[when_type])
|
||||
if (is_terminal[when_type])
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("unreachable WHEN clause specified after unconditional WHEN clause")));
|
||||
if (mergeWhenClause->condition == NULL)
|
||||
is_terminal[when_type] = true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user