Re: Problems with foreign key having different type - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Problems with foreign key having different type
Date
Msg-id Pine.BSF.4.21.0101241036450.57647-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Problems with foreign key having different type  (Mirko Zeibig <mirko@picard.inka.de>)
List pgsql-general
> [snipped foreign keys set up across non-comparable types]
>
> This will not succeed:
> INSERT INTO lnk VALUES ('1', '/adm');
> ERROR:  Unable to identify an operator '=' for types 'bpchar' and 'varchar'
>         You will have to retype this query using an explicit cast
>
> I had a hard time to get rid of this, as I had created a trigger_on_delete
> for pge, which will prevent deletion of page 1! Before my lnk-Table had
> lnk_trg_id which would be a FK of pge.pge_id as well, after doing some drop
> and create, I was not able to delete anything from pge, as there seemed to
> remain references to the no-more existing lnk-table nonetheless.
>
> May constraint should check for the equal datatypes of both keys.

Yeah, I've been working on a patch for that, but every machine I install
the postgres source to work on seems to either crash or fall off the net.
What I've been planning to do is make sure that an = operator exists for
each pair of keys and not allow the constraint otherwise.  One possibility
to get you out of this might be to define an = operator for bpchar and
varchar.



pgsql-general by date:

Previous
From: Alfred Perlstein
Date:
Subject: Re: Speed of varchar vs. char in indices
Next
From: "Steve Wolfe"
Date:
Subject: Re: Re: VACUUM and 24/7 database operation