Re: Problems with foreign key having different type

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Mirko Zeibig <mirko(at)picard(dot)inka(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problems with foreign key having different type
Date: 2001-01-24 18:39:24
Message-ID: Pine.BSF.4.21.0101241036450.57647-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brett W. McCoy 2001-01-24 18:57:19 Re: MySQL has transactions
Previous Message Bruce Momjian 2001-01-24 18:27:34 Re: Having a little trouble with TRIGGERS