Re: Problems with foreign key having different type

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Problems with foreign key having different type
Дата
Msg-id Pine.BSF.4.21.0101241036450.57647-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Problems with foreign key having different type  (Mirko Zeibig <mirko@picard.inka.de>)
Список 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 по дате отправления:

Предыдущее
От: Alfred Perlstein
Дата:
Сообщение: Re: Speed of varchar vs. char in indices
Следующее
От: "Steve Wolfe"
Дата:
Сообщение: Re: Re: VACUUM and 24/7 database operation