Re: char/varchar conversions - Mailing list pgsql-general

From Tom Lane
Subject Re: char/varchar conversions
Date
Msg-id 13426.974305180@sss.pgh.pa.us
Whole thread Raw
In response to char/varchar conversions  (Peter Haworth <pmh@edison.ioppublishing.com>)
Responses Re: char/varchar conversions  (Peter Haworth <pmh@edison.ioppublishing.com>)
List pgsql-general
Peter Haworth <pmh@edison.ioppublishing.com> writes:
> I'm having trouble getting Postgres 6.5.3 to do what I want. The
> problem seems to be fixed in version 7, but I could really do with a
> workaround for 6.5.3, since I'm stuck with that for the time being.

> journals2=> select * from vc where v::char(9)=c;
> ERROR:    Unable to identify an operator '=' for types 'varchar' and 'bpchar'
>     You will have to retype this query using an explicit cast

I think you need to upgrade to 7.0, or else re-make your table so that
you don't need to compare char and varchar.  Broken handling of casts
between binary-compatible types is one of the 6.5 shortcomings that
we fixed in 7.0.

I suppose if you were really desperate, this would work:

create function equal(bpchar,bpchar) returns bool as
'select $1 = $2' language 'sql';

and then
    SELECT ... WHERE equal(v,c);

but performance would be horrid.

            regards, tom lane

pgsql-general by date:

Previous
From: Jeff Eckermann
Date:
Subject: String substitution with "translate" function
Next
From: Lamar Owen
Date:
Subject: Re: Strange problem upgrading to 7.0.3x