Postgres 6.3.2 varchar <--> int4 conversions - Mailing list pgsql-hackers

From Roland Roberts
Subject Postgres 6.3.2 varchar <--> int4 conversions
Date
Msg-id m3iuea1uzf.fsf@ptolemy.rlent.pnet
Whole thread Raw
List pgsql-hackers
-----BEGIN PGP SIGNED MESSAGE-----

I recently had a query fail with the following error:

 keystone=> select members.id, members.element, slips.sid, slips.problem
 keystone->   from slips, members
 keystone->  where members.element = slips.sid
 keystone->    and members.id = 'quickslips';
 ERROR:  There is no operator '=' for types 'varchar' and 'int4'
     You will either have to retype this query using an explicit cast,
     or you will have to define the operator using CREATE OPERATOR

casting the varchar column to int4 works, but if I try to cast the
int4 to varchar I get another error:

 keystone=> select members.id, members.element, slips.sid, slips.problem
 keystone->   from slips, members
 keystone->  where members.element = varchar(slips.sid)
 keystone->    and members.id = 'quickslips';
 ERROR:  parser: parse error at or near "slips"

I would expect that the int4 --> varchar conversion would be the
"safer" one to do.  By "safer" I mean that an int4 value should map to
a distinct varchar value whereas all non-numeric varchar values
generate an error in pg_atoi....

roland
- --
               PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                  Custom Software Solutions
roberts@panix.com                           101 West 15th St #4NN
rbroberts@acm.org                              New York, NY 10011

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBNp1N4uoW38lmvDvNAQG/PAQAr1eU8jG6lsfFACxb732mFA/rnxKkKIED
bn0t3AbAZMMyWe1GajQ5iEXz3ZrZmQGgGS05WMtLyo6HF/Zxvdj235qSJFVsucC3
nQR/knEO+we3/PUCiqKEPPZNkufCxhyFjFEctws1wcp5XDnrO3EiYTBC5vTUXNF1
1nW+k38StyU=
=gWkW
-----END PGP SIGNATURE-----

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] pg_dump again
Next
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] SUM() and GROUP BY