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

Postgres 6.3.2 varchar <--> int4 conversions

From: Roland Roberts <roberts(at)panix(dot)com>
To: pgsql-bugs(at)postgreSQL(dot)org, hackers(at)postgreSQL(dot)org
Subject: Postgres 6.3.2 varchar <--> int4 conversions
Date: 1999-01-14 01:52:36
Message-ID: m3iuea1uzf.fsf@ptolemy.rlent.pnet (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-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(at)panix(dot)com                           101 West 15th St #4NN
rbroberts(at)acm(dot)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

Next:From: Thomas G. LockhartDate: 1999-01-14 06:11:02
Subject: Re: [HACKERS] SUM() and GROUP BY
Previous:From: Tom LaneDate: 1999-01-14 00:22:46
Subject: Re: [HACKERS] pg_dump again

pgsql-bugs by date

Next:From: Javier KohenDate: 1999-01-14 09:32:18
Subject: create view foo as select avg(x), avg(y) from bar; "ERROR: attribute 'avg' duplicated" BUG or FEATURE?
Previous:From: Unprivileged userDate: 1999-01-12 02:37:11
Subject: General Bug Report: Incorrect subtraction - rounding error - should NOT round!

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