Re: Help with array constraints

Поиск
Список
Период
Сортировка
От Jason Hihn
Тема Re: Help with array constraints
Дата
Msg-id NGBBLHANMLKMHPDGJGAPKEGICGAA.jhihn@paytimepayroll.com
обсуждение исходный текст
Ответ на Re: Help with array constraints  (Antti Haapala <antti.haapala@iki.fi>)
Список pgsql-general
...
> There's no way to compare character string (char(1)) and character string
> array (char(1)[3]) with '=' operator. PostgreSQL uses triggers to
> implement foreign key constraints. Trigger creation fails because the type
> of _test.id doesn't match that of test.letter.
>
> > I want ALL the letter field values to be checked against what is in the
> > _test table id field when a row is inserted. For example, 'a' and 'b' is
> > in the _test table now, if I insert an 'a' or 'b' into test, it will
> > succeed. If I insert a 'c' or 'd' it should fail.
>
> Split your fixed sized array to separate table columns and make them
> foreign keys and it will work.

Not acceptable, or I would have done it. ;-) My alternative is to break it
out into tables, but since each record has several arrays per, that means
there's many, many little tables (with key data) that I'd have to make and
maintain.

> And probably you don't want to use char(1), because it uses at least 5
> bytes of storage for each single character.

Well then what should I use? "char" is an internal type, and it is not
specified if it is approved for use outside the internal uses...

Has no one written a generic trigger to do this? Also could be implemented
is trigger based array bounding if the bounds can be known to the trigger.


В списке pgsql-general по дате отправления:

Предыдущее
От: Ulli Mueckstein
Дата:
Сообщение: call analyze from stored procedure in C
Следующее
От: "Tony Harper"
Дата:
Сообщение: RelationBuildDesc Notice (corrupt DB?)