Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WgJic-0007iV-0q for pgsql-bugs@arkaria.postgresql.org; Fri, 02 May 2014 20:06:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WgJib-0002SR-D5 for pgsql-bugs@arkaria.postgresql.org; Fri, 02 May 2014 20:06:01 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WgJia-0002SL-Ng for pgsql-bugs@postgresql.org; Fri, 02 May 2014 20:06:00 +0000 Received: from mout.kundenserver.de ([212.227.126.131]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WgJiX-0004VO-Os for pgsql-bugs@postgresql.org; Fri, 02 May 2014 20:06:00 +0000 Received: from anarazel.de (p5DDC5406.dip0.t-ipconnect.de [93.220.84.6]) by mrelayeu.kundenserver.de (node=mreue005) with ESMTP (Nemesis) id 0M21V9-1Wz4gq3xrX-00ty37; Fri, 02 May 2014 22:05:56 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 4E538100A2A; Fri, 2 May 2014 22:05:55 +0200 (CEST) Date: Fri, 2 May 2014 22:05:55 +0200 From: Andres Freund To: dbaston@gmail.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #10201: Invalid input accepted with IN expression Message-ID: <20140502200555.GD12715@awork2.anarazel.de> References: <20140502200127.1403.20569@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140502200127.1403.20569@wrigleys.postgresql.org> X-Provags-ID: V02:K0:h8RaKTHnvio8KztXjpXWeqG6LjB2SiwfAkA0M9knPum 2tYQ+URp6IBxQMaAdDro1l8HRfYXfM1edIx+A0jKK5tn5ND/u7 JaWkWywQ2VK02FncdTS1QGIBxDmJZUSOnP2QD+wvsYRJufK+iA hF/hFcbGppd9oeV4KqJoSLpXij81mMT/OBOESRvVEg0r43U8an zhjileS0aTipbDQA7iKDFWat8MRzCBxR/2qT+Ry1KLURdI1D7B xmj7DZjdJM1kr7jiA4CYUQPODVgDeBjcXZMxQTCeNguMgmzSBf XDjo5y88SBLhLCJDk2gVaz740UMIdc+AP90CzwoSmRFCl79vqn +svf5S0WtR8Ue1HMmLzMrvad7lS4gfNfSEsxqloYX X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hi, On 2014-05-02 20:01:27 +0000, dbaston@gmail.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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs