cannot cast bpchar and varchar

From: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: cannot cast bpchar and varchar
Date: 1999-02-10 02:43:39
Message-ID: 199902100243.LAA24610@srapc451.sra.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

It seems that casting varchar and bpchar does not work.

I create two tables.

create table main (id char(4), sub_id char(4), caption char(10));
create table sub (sub_id varchar(10), sub_caption varchar(10));

Then do a select.

select main.id, sub.sub_caption, main.caption from main, sub
where main.sub_id=sub.sub_id;

I get an error(this is normal, I guess).

ERROR: There is more than one possible operator '=' for types 'bpchar' and 'varchar'
You will have to retype this query using an explicit cast

So I try some castings.

test=> select main.id, sub.sub_caption, main.caption from main, sub where main.sub_id::varchar =sub.sub_id;
test=> ERROR: There is more than one possible operator '=' for types 'bpchar' and 'varchar'
You will have to retype this query using an explicit cast
test=> select main.id, sub.sub_caption, main.caption from main, sub where main.sub_id=sub.sub_id::bpchar;
ERROR: There is more than one possible operator '=' for types 'bpchar' and 'varchar'
You will have to retype this query using an explicit cast
test=> select main.id, sub.sub_caption, main.caption from main, sub where cast(main.sub_id as varchar) =sub.sub_id;
ERROR: There is more than one possible operator '=' for types 'bpchar' and 'varchar'
You will have to retype this query using an explicit cast
test=> select main.id, sub.sub_caption, main.caption from main, sub where main.sub_id=cast(sub.sub_id as bpchar);
ERROR: There is more than one possible operator '=' for types 'bpchar' and 'varchar'
You will have to retype this query using an explicit cast

Do we have a problem with casting? BTW, this is 6.4.2. I have not
tried current yet.
--
Tatsuo Ishii

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daryl W. Dunbar 1999-02-10 03:00:39 PostgreSQL and Solaris 7?
Previous Message Vadim Mikheev 1999-02-10 02:28:11 Re: [HACKERS] TIME QUALIFICATION