IN clause behaving badly with missing comma and line break

From: Roman Cervenak <roman(at)cervenak(dot)info>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: IN clause behaving badly with missing comma and line break
Date: 2023-01-18 07:51:30
Message-ID: CAGjExY3rn0YEYnCiRkJ+R9czsmz6Fa4xkYaOaY35x6B-UC_53A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,
if you use IN() clause (I've tested in WHERE and CASE) and you forget comma
between values, it is syntax error (correct behaviour). But if there is
newline between those two values, suddenly it is not syntax error
(query will run successfully), and all values are simply ignored.

Examples:

WITH sample AS (SELECT 'c' AS t) SELECT CASE WHEN t IN ('a','b') THEN 1
WHEN t IN ('c'
'd') THEN 2 END FROM sample;

WITH sample AS (SELECT 'c' AS t)
SELECT * FROM sample WHERE t IN ('a'
'c');

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2023-01-18 08:06:57 Re: IN clause behaving badly with missing comma and line break
Previous Message Amit Kapila 2023-01-18 04:32:27 Re: DROP DATABASE deadlocks with logical replication worker in PG 15.1