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