Re: Accessing composite type columns in indexes

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Accessing composite type columns in indexes
Дата
Msg-id 10962.1141446712@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Accessing composite type columns in indexes  (Michael Glaesemann <grzm@myrealbox.com>)
Список pgsql-general
Michael Glaesemann <grzm@myrealbox.com> writes:
> ... it appears that one can't directly access the columns of a
> composite type when creating an index, i.e., neither UNIQUE (foo.bar)
> nor UNIQUE ((foo).bar) work.

You need both, ie something like

create table foo (bar date_co_interval);
create unique index fooi on foo (((bar).from_date));

The outer set of parens is required for any index expression.  Basically
that's to fix a grammar conflict against the possible presence of an
index opclass, that is given

    create index fooi on foo (x ! y)

is that an infix operator expression "x ! y", or a postfix operator
expression "x !" followed by an opclass name?

The inner set of parens is because "a.b" is always interpreted as a
table and column name.  To refer to a column, and then qualify it with
a composite-type field, we require you to write "(b).c" or "(a.b).c".
It'd be legal to write the same index as
    create unique index fooi on foo (((foo.bar).from_date));

Make sense now?

            regards, tom lane

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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: record OID to table
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Accessing composite type columns in indexes