pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dmitriy Igrishin <dmitigr@gmail.com>
To: postgres list <pgsql-sql@postgresql.org>
Subject: Question about domains.
Date: Thu, 8 Jul 2010 17:27:24 +0400
Message-ID: <AANLkTimJ41uGheKYOX3xjuz_CdeLUdruizay6BP4jjZw@mail.gmail.com> (raw)

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

view thread (2+ messages)  latest in thread

Message-ID: <AANLkTimJ41uGheKYOX3xjuz_CdeLUdruizay6BP4jjZw@mail.gmail.com>
Permalink:  ../AANLkTimJ41uGheKYOX3xjuz_CdeLUdruizay6BP4jjZw@mail.gmail.com/
Also on:    postgresql.org/message-id/AANLkTimJ41uGheKYOX3xjuz_CdeLUdruizay6BP4jjZw@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dmitigr@gmail.com
  Subject: Re: Question about domains.
  In-Reply-To: <AANLkTimJ41uGheKYOX3xjuz_CdeLUdruizay6BP4jjZw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox