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
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
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
Tom Lane wrote:
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
On Fri, Sep 09, 2005 at 10:39:58AM -0400, Tom Lane wrote:
I don't believe you need the function -- this should be enough:
CREATE UNIQUE INDEX t1_b_uniq ON t1 ((attr.foo));
I was expecting that to work too, but it doesn't:
ERROR: relation attr does not exist
--
Michael Fuhr
# [EMAIL PROTECTED] / 2005-09-09 09:10:30 -0600:
On Fri, Sep 09, 2005 at 10:39:58AM -0400, Tom Lane wrote:
I don't believe you need the function -- this should be enough:
CREATE UNIQUE INDEX t1_b_uniq ON t1 ((attr.foo));
I was expecting that to work too, but it doesn't:
ERROR:
Richard Huxton dev@archonet.com writes:
Tom Lane wrote:
I don't believe you need the function -- this should be enough:
CREATE UNIQUE INDEX t1_b_uniq ON t1 ((attr.foo));
I got: Relation attr does not exist (on 8.1 beta)
Sorry, make that
CREATE UNIQUE INDEX t1_b_uniq ON t1 (((attr).foo));
On Fri, Sep 09, 2005 at 05:20:58PM +0200, Roman Neuhauser wrote:
# [EMAIL PROTECTED] / 2005-09-09 09:10:30 -0600:
On Fri, Sep 09, 2005 at 10:39:58AM -0400, Tom Lane wrote:
I don't believe you need the function -- this should be enough:
CREATE UNIQUE INDEX t1_b_uniq ON t1 ((attr.foo));