Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1spbL7-002jz1-0t for pgsql-bugs@arkaria.postgresql.org; Sat, 14 Sep 2024 22:34:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1spbL6-005wX3-Ay for pgsql-bugs@arkaria.postgresql.org; Sat, 14 Sep 2024 22:34:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1spbL6-005wWv-2a for pgsql-bugs@lists.postgresql.org; Sat, 14 Sep 2024 22:34:00 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1spbL3-001BqQ-0X for pgsql-bugs@lists.postgresql.org; Sat, 14 Sep 2024 22:33:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 48EMXsRM700367; Sat, 14 Sep 2024 18:33:54 -0400 From: Tom Lane To: Leo Volin cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: Case clause doesn't report syntactic error In-reply-to: References: Comments: In-reply-to Leo Volin message dated "Sat, 14 Sep 2024 21:27:35 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <700365.1726353234.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 14 Sep 2024 18:33:54 -0400 Message-ID: <700366.1726353234@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Leo Volin 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#FUN= CTIONS-CASE