Skip site navigation (1) Skip section navigation (2)

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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dawid Kuroczko" <qnex42(at)gmail(dot)com>
Cc: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: PostgreSQL 8.2 Bug in casting varchar to int in SELECT ... WHERE IN ( ... )
Date: 2007-10-20 03:05:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
"Dawid Kuroczko" <qnex42(at)gmail(dot)com> writes:
> What troubles me here is that surprise factor is unusally high here.
> While I understand mechanics why IN (1) works while IN (1,2) does not,
> I think random developers are going to be confused.

If you're not testing against 8.3 then this argument doesn't carry much
weight.  8.3 will reject *both* cases in the examples you've mentioned.

> PS: I wonder why explicitly using IN (ARRAY[...]) works.

Um, it does not work AFAICS:

regression=# select 'foo'::varchar in (array[1,2,3]);
ERROR:  operator does not exist: character varying = integer[]
LINE 1: select 'foo'::varchar in (array[1,2,3]);
HINT:  No operator matches the given name and argument type(s). You may need to add explicit type casts.

			regards, tom lane

In response to


pgsql-bugs by date

Next:From: Heikki LinnakangasDate: 2007-10-20 08:09:01
Subject: Re: BUG #3682: Incomplete database restore
Previous:From: Gary ChambersDate: 2007-10-20 03:04:27
Subject: BUG #3682: Incomplete database restore

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group