Re: Potential bug in postgres 8.2.4 - Mailing list pgsql-sql

From Marcin Stępnicki
Subject Re: Potential bug in postgres 8.2.4
Date
Msg-id pan.2007.05.24.11.34.03.780983@gmail.com
Whole thread Raw
In response to Potential bug in postgres 8.2.4  (Tomas Doran <bobtfish@bobtfish.net>)
Responses Re: Potential bug in postgres 8.2.4  (Tomas Doran <bobtfish@bobtfish.net>)
List pgsql-sql
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 




pgsql-sql by date:

Previous
From: Tomas Doran
Date:
Subject: Potential bug in postgres 8.2.4
Next
From: Peter Eisentraut
Date:
Subject: Re: Potential bug in postgres 8.2.4