Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 678629FBE3A for ; Thu, 24 May 2007 08:54:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 22903-01 for ; Thu, 24 May 2007 08:54:50 -0300 (ADT) X-Greylist: delayed 00:33:54.581446 by SQLgrey-1.7.5 Received: from mail.venda.com (mail.venda.com [195.99.220.5]) by postgresql.org (Postfix) with SMTP id 21D399FBE02 for ; Thu, 24 May 2007 08:54:49 -0300 (ADT) Received: from [10.101.2.205] ([10.101.2.205]) by mail.venda.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 24 May 2007 12:57:16 +0100 In-Reply-To: References: <3D2864D1-BF64-4609-B307-1C70A4FE503F@bobtfish.net> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=UTF-8; delsp=yes; format=flowed Message-Id: <72573535-0946-45DE-B5E4-E57236965B0E@bobtfish.net> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: quoted-printable From: Tomas Doran Subject: Re: Potential bug in postgres 8.2.4 Date: Thu, 24 May 2007 12:54:48 +0100 To: =?UTF-8?Q?Marcin_St=C4=99pnicki?= X-Mailer: Apple Mail (2.752.2) X-OriginalArrivalTime: 24 May 2007 11:57:16.0211 (UTC) FILETIME=[AC56E830:01C79DFA] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/167 X-Sequence-Number: 28447 On 24 May 2007, at 12:34, Marcin St=C4=99pnicki wrote: > Dnia Thu, 24 May 2007 12:20:54 +0100, Tomas Doran napisa=C5=82(a): > >> CREATE TABLE testtable ( >> col1 char(1), >> data text >> ); >> >> INSERT INTO testtable (col1, data) VALUES ('1', 'foobar'); INSERT =20 >> INTO >> testtable (col1, data) VALUES ('2', 'foobarbaz'); >> >> The following queries all work: >> INSERT INTO testtable (col1, data) VALUES (3::int, 'foobarbazquux'); >> SELECT * FROM testtable WHERE col1 =3D 3::int; SELECT * FROM =20 >> testtable WHERE >> col1 IN (1); SELECT * FROM testtable WHERE col1 IN (1::int); >> >> However these querys fail on 8.2.4, but work correctly on 8.1: =20 >> SELECT * >> FROM testtable WHERE col1 IN (1::int, 2::int); SELECT * FROM =20 >> testtable >> WHERE col1 IN (1, 2); >> >> I could understand if the behavior was the same for single element IN >> clauses, and multiple element IN clauses - however as their =20 >> behavior is >> different, and it used to work in 8.1.... > > I'm not sure if I understand you correctly, but it seems that you are > comparing apples to oranges here (integer and character values). Yep, totally - it's not nice, but we need to do it at $ork for =20 hysterical raisins.. In the short term, adding the appropriate cast (in our code) isn't an =20= option... If I can do something to make it work in the postgres backend, then =20 that'd be acceptable, and I'm investigating that.. > I am a > big fan of weakly typed languages like Python myself, but this =20 > situation > is different. I'd say that PostgreSQL 8.1 did a cast somewhere =20 > "behind the > scenes" but personally I think it is a bad idea. Consider: > > SELECT * FROM testtable WHERE col1::int IN (1, 2); > > instead. Yes, indeed - however I think it's a bug as 'SELECT * FROM testtable =20 WHERE col1 IN (1)' DOES work, but 'SELECT * FROM testtable WHERE col1 =20= IN (1, 2)' does NOT work.. This is, at the very least, is a glaring inconsistency around how IN =20 clauses are handled in different situations. If this was a deliberate tightning of the behavior, is there a =20 changelog entry/link to come docs about when this change happened =20 that anyone can point me to? Cheers Tom