Re: char/varchar conversions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Haworth <pmh(at)edison(dot)ioppublishing(dot)com>
Cc: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: char/varchar conversions
Date: 2000-11-15 16:19:40
Message-ID: 13426.974305180@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Peter Haworth <pmh(at)edison(dot)ioppublishing(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2000-11-15 16:44:25 Re: no history in psql on OpenBSD
Previous Message Lamar Owen 2000-11-15 16:17:34 Re: Strange problem upgrading to 7.0.3x