Search Postgresql Archives

Re: Accessing composite type columns in indexes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Glaesemann <grzm@xxxxxxxxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux