Re: IN clause behaving badly with missing comma and line break

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Roman Cervenak <roman(at)cervenak(dot)info>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: IN clause behaving badly with missing comma and line break
Date: 2023-01-18 08:06:57
Message-ID: CAApHDvrZKqZOMQYf=f5C5j3fP+Ls_3rY6=PZD8AcWZdf2byvWg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 18 Jan 2023 at 21:03, Roman Cervenak <roman(at)cervenak(dot)info> wrote:
> 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;

This is not a bug. See 4.1.2.1. String Constants in [1].

David

[1] https://www.postgresql.org/docs/current/sql-syntax-lexical.html

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Kapila 2023-01-18 10:10:07 Re: Logical Replica ReorderBuffer Size Accounting Issues
Previous Message Roman Cervenak 2023-01-18 07:51:30 IN clause behaving badly with missing comma and line break