Re: char/varchar conversions

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

On Wed, 15 Nov 2000 11:19:40 -0500, Tom Lane said:
> 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 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(at)edison(dot)ioppublishing(dot)com
"Perhaps I'm missing the gene for making enemies." -- Larry Wall

In response to

Browse pgsql-general by date

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