From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
---|---|
To: | dbaston(at)gmail(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #10201: Invalid input accepted with IN expression |
Date: | 2014-05-02 20:05:55 |
Message-ID: | 20140502200555.GD12715@awork2.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hi,
On 2014-05-02 20:01:27 +0000, dbaston(at)gmail(dot)com wrote:
> If two items in an IN expression are separated by a newline instead of a
> comma, those items will be ignored with no error.
>
> CREATE TABLE testing (id varchar(1));
> INSERT INTO testing VALUES ('1'), ('2'), ('3'), ('4'), ('5');
>
> -- Missing comma produces a syntax error
> SELECT * FROM testing WHERE id IN ('1' '2', '3');
>
> -- Unless there is a newline
> SELECT * FROM testing WHERE id IN ('1'
> '2', '3');
Check what
SELECT '1'
'2';
returns. Two string constants separated by a newline are essentially
concatenated. So, what the above means is: id IN ('12', '3')
Check:
http://www.postgresql.org/docs/current/interactive/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-05-02 20:07:09 | Re: BUG #10201: Invalid input accepted with IN expression |
Previous Message | dbaston | 2014-05-02 20:01:27 | BUG #10201: Invalid input accepted with IN expression |