Re: Case clause doesn't report syntactic error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Leo Volin <lvolin(at)intelligentaudit(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Case clause doesn't report syntactic error
Date: 2024-09-14 22:33:54
Message-ID: 700366.1726353234@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Leo Volin <lvolin(at)intelligentaudit(dot)com> writes:
> This generates no error:
> select case '4'::int when 1 then 1 when 4 then 11 else 2 end;
> (prints 11)
> It doesn't match the documented format:
> CASE WHEN condition THEN result
> [WHEN ...]
> [ELSE result]
> END

You need to read down a couple of paragraphs to where the
"simple" variant of CASE is explained [1]:

CASE expression
WHEN value THEN result
[WHEN ...]
[ELSE result]
END

Perhaps we should rearrange that page so both syntax variants
appear at the top; but it's not wrong.

regards, tom lane

[1] https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-CASE

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-09-15 22:17:33 BUG #18618: pg_upgrade from 14 to 15+ fails for unlogged table with identity column
Previous Message David G. Johnston 2024-09-14 22:26:07 Re: Case clause doesn't report syntactic error