Re: How do I... - Mailing list pgsql-general

From Tom Lane
Subject Re: How do I...
Date
Msg-id 3243.986178125@sss.pgh.pa.us
Whole thread Raw
In response to Re: How do I...  (Paul Tomblin <ptomblin@xcski.com>)
List pgsql-general
Paul Tomblin <ptomblin@xcski.com> writes:
> How do I compare a char (bpchar?) to a varchar?  I tried using "=", and I
> got:

>     waypoint=> select b.id, a.icao,a.faa_host_id from dafif_arpt a, waypoint b
>     where b.id = a.icao;
>     ERROR:  Unable to identify an operator '=' for types 'varchar' and 'bpchar'
>             You will have to retype this query using an explicit cast

> Why isn't this working?

char and varchar are not directly comparable because they have different
ideas about whether trailing blanks are significant.  Postgres makes you
cast one or the other so that it knows which set of comparison rules to
apply.  Typically you probably want to cast the varchar side to char so
that trailing blanks are ignored.

> It doesn't work even if I try to cast the varchar to bpchar:

I believe you are also running into sundry bugs in 6.5's handling of
these casts.  Should be cleaned up in 7.0.*.

            regards, tom lane

pgsql-general by date:

Previous
From: Murakami
Date:
Subject: pg_ctl stop returns error
Next
From: Tom Lane
Date:
Subject: Re: pg_ctl stop returns error