Re: Argh! What's a 'bpchar'? (copy/serial issues...I think) - Mailing list pgsql-novice

From Tom Lane
Subject Re: Argh! What's a 'bpchar'? (copy/serial issues...I think)
Date
Msg-id 6312.979871228@sss.pgh.pa.us
Whole thread Raw
In response to Argh! What's a 'bpchar'? (copy/serial issues...I think)  (Ken Corey <ken@kencorey.com>)
List pgsql-novice
Ken Corey <ken@kencorey.com> writes:
> CREATE TABLE PLAYER
> (
>     PLAYER_ID   SERIAL,
>     PLAYER_NAME varchar(255) NOT NULL,
>     PLAYING_FOR varchar(255) NOT NULL,
>     CHEAT_FLAG  char(1)      NULL,
>     EMAIL       varchar(255) NULL,
>     --UNIQUE (PLAYER_NAME,PLAYING_FOR,EMAIL),
>     CONSTRAINT PK_PLAYER PRIMARY KEY (PLAYER_ID)
> )
> ;

> with this command:

> GRE=# copy player from '/tmp/player.txt' using delimiters ',';
> ERROR:  Unable to identify an operator '=' for types 'bpchar' and
> 'varchar'

"bpchar" is the internal type name for CHAR(n) (think "blank-padded
char").  It's unhappy because something is trying to compare a
char(n) field to a varchar(n) field --- we don't let you do that
because the semantics aren't well defined.  (One type thinks trailing
blanks are significant in a comparison, the other doesn't.)

As to what that something is, my guess is a foreign key constraint
that you didn't show us.  IIRC, 7.0 fails to check for comparable
datatypes when you define a foreign key, so you get the error at
runtime instead :-(.  Do you have another table that references this
one?

            regards, tom lane

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Re: Interval output format
Next
From: Peter Eisentraut
Date:
Subject: Re: Yikes! Bitten by line length?