Question about domains.

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: Question about domains.
Date: 2010-07-08 13:27:24
Message-ID: AANLkTimJ41uGheKYOX3xjuz_CdeLUdruizay6BP4jjZw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hey all,

Is there a way to add constraint to the domain that used by a composite type
that used by a table? E.g.:

CREATE DOMAIN superid AS integer;

CREATE TYPE idtype AS
(
id superid
);

CREATE TABLE mytab (id idtype NOT NULL);

ALTER DOMAIN superid ADD CONSTRAINT superid_check CHECK (VALUE > 0);

ALTER DOMAIN superid DROP CONSTRAINT superid_check;

produces the following output:

dmitigr=> CREATE DOMAIN
Time: 23,809 ms
dmitigr=> CREATE TYPE
Time: 44,875 ms
dmitigr=> CREATE TABLE
Time: 134,101 ms
dmitigr=> ERROR: cannot alter type "superid" because column "mytab"."id"
uses it
dmitigr=> ALTER DOMAIN
Time: 0,270 ms

As you can see, adding constraint to the domain produces an error, while
dropping
constraint is possible!
Any comments?

Regards,
Dmitriy

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Justin Graf 2010-07-08 14:52:11 Re: strangest thing happened
Previous Message silly sad 2010-07-08 08:47:47 Re: