cannot cast bpchar and varchar - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject cannot cast bpchar and varchar
Date
Msg-id 199902100243.LAA24610@srapc451.sra.co.jp
Whole thread Raw
List 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, subwhere 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
usingan 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
thisquery 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
usingan 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
usingan 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
usingan explicit cast
 

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


pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Keywords
Next
From: "Daryl W. Dunbar"
Date:
Subject: PostgreSQL and Solaris 7?