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

From Peter Haworth
Subject Re: char/varchar conversions
Date
Msg-id 200011151708.eAFH8Ss16443@mail.postgresql.org
Whole thread Raw
In response to Re: char/varchar conversions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Wed, 15 Nov 2000 11:19:40 -0500, Tom Lane said:
> 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 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.

No kidding. My actual comparison is a join between two tables. This function
compares pretty badly with my current workaround of adding another join
through a table with char and varchar versions of the field in question, which
I thought was going to be really bad. (Fortunately, the range of values is
pretty small and static).

I've got different types because one table describes journals - the field is
char(9) for ISSNs, and the other describes subscriptions - the field is
varchar(9) to hold ISSNs and packages, which all have IDs less than 9
characters.

>  I think you need to upgrade to 7.0

I agree, and I'm sure it'll happen eventually...

--
    Peter Haworth    pmh@edison.ioppublishing.com
"Perhaps I'm missing the gene for making enemies." -- Larry Wall



pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: no history in psql on OpenBSD
Next
From: Rich Shepard
Date:
Subject: Re: Strange problem upgrading to 7.0.3x