Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 4414F9FB876 for ; Thu, 24 May 2007 08:34:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 89492-06 for ; Thu, 24 May 2007 08:34:19 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id DC0079FB6B2 for ; Thu, 24 May 2007 08:34:23 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1HrBaD-00041n-4B for pgsql-sql@postgresql.org; Thu, 24 May 2007 13:34:17 +0200 Received: from pc035-72.amg.gda.pl ([153.19.72.35]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 May 2007 13:34:17 +0200 Received: from mstepnicki by pc035-72.amg.gda.pl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 24 May 2007 13:34:17 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: =?iso-8859-2?q?Marcin_St=EApnicki?= Subject: Re: Potential bug in postgres 8.2.4 Date: Thu, 24 May 2007 13:34:03 +0200 Organization: Linux.PL Lines: 39 Message-ID: References: <3D2864D1-BF64-4609-B307-1C70A4FE503F@bobtfish.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pc035-72.amg.gda.pl User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux)) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/165 X-Sequence-Number: 28445 Dnia Thu, 24 May 2007 12:20:54 +0100, Tomas Doran napisał(a): > CREATE TABLE testtable ( > col1 char(1), > data text > ); > > INSERT INTO testtable (col1, data) VALUES ('1', 'foobar'); INSERT 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 = 3::int; SELECT * FROM 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: SELECT * > FROM testtable WHERE col1 IN (1::int, 2::int); SELECT * FROM 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 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). I am a big fan of weakly typed languages like Python myself, but this situation is different. I'd say that PostgreSQL 8.1 did a cast somewhere "behind the scenes" but personally I think it is a bad idea. Consider: SELECT * FROM testtable WHERE col1::int IN (1, 2); instead. -- | And Do What You Will be the challenge | http://apcoln.linuxpl.org | So be it in love that harms none | http://biznes.linux.pl | For this is the only commandment. | http://www.juanperon.info `---* JID: Aragorn_Vime@jabber.org *---' http://www.naszedzieci.org