Re: constraints on composite types - Mailing list pgsql-general

From Tom Lane
Subject Re: constraints on composite types
Date
Msg-id 10476.1126276798@sss.pgh.pa.us
Whole thread Raw
In response to Re: constraints on composite types  (Richard Huxton <dev@archonet.com>)
Responses Re: constraints on composite types
Re: constraints on composite types
List pgsql-general
Richard Huxton <dev@archonet.com> 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

pgsql-general by date:

Previous
From: Matt Miller
Date:
Subject: Re: Route Miles
Next
From: Scott Marlowe
Date:
Subject: Re: RAID0 and pg_xlog