Michael Glaesemann <[EMAIL PROTECTED]> 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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to