Re: constraints on composite types

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: constraints on composite types
Дата
Msg-id 10476.1126276798@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: constraints on composite types  (Richard Huxton <dev@archonet.com>)
Ответы Re: constraints on composite types  (Richard Huxton <dev@archonet.com>)
Re: constraints on composite types  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general
Richard Huxton <dev@archonet.com> writes:
> You might get somewhere with:

> CREATE OR REPLACE FUNCTION testfunc(ct) RETURNS int AS
> 'SELECT $1.foo;'
> LANGUAGE SQL IMMUTABLE;

> CREATE UNIQUE INDEX t1_b_uniq ON t1 (testfunc(b));

The point is that "attr.foo" is an expression, not a column name, and
the SQL spec allows UNIQUE and PRIMARY KEY only on bare column names.
I don't believe you need the function -- this should be enough:

CREATE UNIQUE INDEX t1_b_uniq ON t1 ((attr.foo));

            regards, tom lane

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

Предыдущее
От: Matt Miller
Дата:
Сообщение: Re: Route Miles
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: RAID0 and pg_xlog