Search Postgresql Archives

Re: constraints on composite types

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

 



Roman Neuhauser wrote:
This fails on 8.0.3 (syntax error at or near "." at character):

CREATE TYPE ct AS (
  foo INTEGER,
  bar INTEGER
);

CREATE TABLE t1 (
  attr ct,
  CONSTRAINT uq UNIQUE (attr.foo)
);

Should it be possible? From reading
http://www.postgresql.org/docs/current/static/rowtypes.html it looks
like almost everything else works.

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));

Seems to work on 8.1beta - haven't tried on version 8, but if the syntax is accepted I don't see why not.
--
  Richard Huxton
  Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[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