From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Glaesemann <grzm(at)myrealbox(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Accessing composite type columns in indexes |
Date: | 2006-03-04 04:31:52 |
Message-ID: | 10962.1141446712@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Michael Glaesemann <grzm(at)myrealbox(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2006-03-04 04:34:04 | Re: Accessing composite type columns in indexes |
Previous Message | Michael Fuhr | 2006-03-04 04:01:53 | Re: record OID to table |