Re: constraints on composite types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: Roman Neuhauser <neuhauser(at)sigpipe(dot)cz>, pgsql-general(at)postgresql(dot)org
Subject: Re: constraints on composite types
Date: 2005-09-09 14:39:58
Message-ID: 10476.1126276798@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Huxton <dev(at)archonet(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matt Miller 2005-09-09 14:40:00 Re: Route Miles
Previous Message Michael Fuhr 2005-09-09 14:36:15 Re: Partial commit within the trasaction