Search Postgresql Archives

Re: constraints on composite types

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

 



Richard Huxton <dev@xxxxxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[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