BUG #3518: ERROR: IN types character varying and integer cannot be matched

Started by Tomasz Kawczynskiover 18 years ago2 messagesbugs
Jump to latest
#1Tomasz Kawczynski
sober.pl@gmail.com

The following bug has been logged online:

Bug reference: 3518
Logged by: Tomasz Kawczynski
Email address: sober.pl@gmail.com
PostgreSQL version: 8.2.4
Operating system: Linux Gentoo
Description: ERROR: IN types character varying and integer cannot be
matched
Details:

Hello everyone,

After

SELECT * FROM s_skladnik WHERE kod IN (902,902)

kod character(3)

i get error message

ERROR: IN types character varying and integer cannot be matched

whitch is ok (ive read about this restriction in 8.2.x)

but why after

SELECT * FROM s_skladnik WHERE kod IN (902)
or
SELECT * FROM s_skladnik WHERE kod = 902

I dont get error but query gives me correct result ?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tomasz Kawczynski (#1)
Re: BUG #3518: ERROR: IN types character varying and integer cannot be matched

"Tomasz Kawczynski" <sober.pl@gmail.com> writes:

SELECT * FROM s_skladnik WHERE kod IN (902,902)
ERROR: IN types character varying and integer cannot be matched

whitch is ok (ive read about this restriction in 8.2.x)

but why after

SELECT * FROM s_skladnik WHERE kod IN (902)
or
SELECT * FROM s_skladnik WHERE kod = 902

I dont get error but query gives me correct result ?

This inconsistency will be gone in 8.3:

regression=# select * from t1 where kod = 902;
ERROR: operator does not exist: character varying = integer
LINE 1: select * from t1 where kod = 902;
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
regression=#

regards, tom lane