Re: PostgreSQL 8.2 Bug in casting varchar to int in SELECT ... WHERE IN ( ... )

From: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>
To: "Dawid Kuroczko" <qnex42(at)gmail(dot)com>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: PostgreSQL 8.2 Bug in casting varchar to int in SELECT ... WHERE IN ( ... )
Date: 2007-10-19 14:04:38
Message-ID: 4718B976.8060203@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Dawid Kuroczko wrote:
> Versions 8.0, 8.1 work fine, while version 8.2.5 (and earlier probably too):
>
> postgres=> CREATE TEMP TABLE test (id varchar(32));
> CREATE TABLE
> postgres=> INSERT INTO test SELECT * FROM generate_series(1,100);
> INSERT 0 100
> postgres=> SELECT * FROM test WHERE id IN (50);
> id
> ----
> 50
> (1 row)
>
> postgres=> SELECT * FROM test WHERE id IN (55,50);
> ERROR: IN types character varying and integer cannot be matched
>
> This works fine in version 8.0 and 8.1.

Note that neither SELECT will work on 8.3, because we no longer have an
implicit cast from integer to text. I suppose the above is an oversight
in how we handle IN-clauses (starting with 8.2 an IN-clause is
transformed into an "x = ANY (...)" expression), but I don't think it's
worth changing.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2007-10-19 14:31:04 Re: PostgreSQL 8.2 Bug in casting varchar to int in SELECT ... WHERE IN ( ... )
Previous Message Dawid Kuroczko 2007-10-19 13:32:03 PostgreSQL 8.2 Bug in casting varchar to int in SELECT ... WHERE IN ( ... )