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

minor bug in 7.0: casting

From: The Hermit Hacker <scrappy(at)hub(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: minor bug in 7.0: casting
Date: 2000-03-01 01:14:01
Message-ID: Pine.BSF.4.21.0002292112200.434-100000@thelab.hub.org (view raw or flat)
Thread:
Lists: pgsql-hackers
Another one here ...

=============
From: Don Baccus <dhogaza(at)pacifier(dot)com>

At 04:05 PM 2/29/00 -0400, you wrote:

>No, bug reports are most welcome, antagonistic comments aren't ... big
>difference ...

donb=# create table foo(c char(2), v varchar(2));
CREATE
donb=# select * from foo where c::varchar = v::varchar;
ERROR:  Unable to identify an operator '=' for types 'bpchar' and 'varchar'
        You will have to retype this query using an explicit cast
donb=# select * from foo where cast(c as varchar) = cast(v as varchar);
ERROR:  Unable to identify an operator '=' for types 'bpchar' and 'varchar'
        You will have to retype this query using an explicit cast
donb=# select * from foo where cast(c as text) = cast(v as text);
ERROR:  Unable to identify an operator '=' for types 'bpchar' and 'varchar'
        You will have to retype this query using an explicit cast

If conversion isn't going to be supported, the error message should
be improved (feel free to forward this to the appropriate person).

In this case, the working application actually fills both variables
(in practice, from different tables) with two-character state codes,
so the cast would work.  Should casts presume the user doesn't know
what they're doing?  I don't know.  I can fix this, of course, by
changing the data model I've inherited from Oracle to consistently
use either char(2) or varchar(2).




- Don Baccus, Portland OR <dhogaza(at)pacifier(dot)com>
  Nature photos, on-line guides, Pacific Northwest
  Rare Bird Alert Service and other goodies at
  http://donb.photo.net.
=====================


Responses

pgsql-hackers by date

Next:From: Hiroshi InoueDate: 2000-03-01 01:35:04
Subject: RE: [HACKERS] Cache query implemented
Previous:From: The Hermit HackerDate: 2000-03-01 01:11:45
Subject: Bug report for 7.0beta1 in 'CREATE FUNCTION...'

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