Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf026c16

Browse files
committed
Fix MERGE's test for unreachable WHEN clauses.
The former code would only detect an unreachable WHEN clause if it hadan AND condition. Fix, so that unreachable unconditional WHEN clausesare also detected.Back-patch to v15, where MERGE was added.Discussion:https://postgr.es/m/CAEZATCVQ=7E2z4cSBB49jjeGGsB6WeoYQY32NDeSvcHiLUZ=ow@mail.gmail.com
1 parentd952373 commitf026c16

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

‎src/backend/parser/parse_merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
155155
/*
156156
* Check for unreachable WHEN clauses
157157
*/
158-
if (mergeWhenClause->condition==NULL)
159-
is_terminal[when_type]= true;
160-
elseif (is_terminal[when_type])
158+
if (is_terminal[when_type])
161159
ereport(ERROR,
162160
(errcode(ERRCODE_SYNTAX_ERROR),
163161
errmsg("unreachable WHEN clause specified after unconditional WHEN clause")));
162+
if (mergeWhenClause->condition==NULL)
163+
is_terminal[when_type]= true;
164164
}
165165

166166
/*

‎src/test/regress/expected/merge.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ USING source AS s
659659
ON t.tid = s.sid
660660
WHEN MATCHED THEN /* Terminal WHEN clause for MATCHED */
661661
DELETE
662-
WHEN MATCHEDAND s.delta > 0THEN
662+
WHEN MATCHED THEN
663663
UPDATE SET balance = t.balance - s.delta;
664664
ERROR: unreachable WHEN clause specified after unconditional WHEN clause
665665
ROLLBACK;

‎src/test/regress/sql/merge.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ USING source AS s
438438
ONt.tid=s.sid
439439
WHEN MATCHED THEN/* Terminal WHEN clause for MATCHED*/
440440
DELETE
441-
WHEN MATCHEDANDs.delta>0THEN
441+
WHEN MATCHED THEN
442442
UPDATESET balance=t.balance-s.delta;
443443
ROLLBACK;
444444

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp