Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 13C63632D4D for ; Thu, 8 Jul 2010 10:27:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 22701-06 for ; Thu, 8 Jul 2010 13:27:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id 1DC636324F6 for ; Thu, 8 Jul 2010 10:27:26 -0300 (ADT) Received: by fxm14 with SMTP id 14so401688fxm.19 for ; Thu, 08 Jul 2010 06:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=mCkSGxO58s4ltedhhMNSLH1f8UviqGE0FGmNfeTjLQ4=; b=mjOvtNLMvZf8/eIrGC5jSi2SqQdMbtpjjhqDcKjlWf3PPRUZA0qrAa4wliGc4k80x3 fmv3ZJj2lY1SqpxrdZ3mfNkLJBd8qK1jZeZ90ndwfR1NiUPOOlheLeOSLeSEiPV32S+E T2H2Ol4d7qXSHRFZxQiVUz5FzEuuFrXOYgY7I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=W6Znd5xQBmZQKpAr+R8dmSVltL1iz87EsXYqFxkfEmJDopKeG88GMJMKqt6q22j462 Hmaa70/1t/ZR8QpUL2DMQqSQ+Dmcv07cS4lPhiz2t6N1C6eIBp2v54TCOnTZyacahmoa KvpazM3HP/RylvjiEx3ac9naFwPq1PUZwZtdg= MIME-Version: 1.0 Received: by 10.103.171.4 with SMTP id y4mr1816275muo.61.1278595644494; Thu, 08 Jul 2010 06:27:24 -0700 (PDT) Received: by 10.103.137.9 with HTTP; Thu, 8 Jul 2010 06:27:24 -0700 (PDT) Date: Thu, 8 Jul 2010 17:27:24 +0400 Message-ID: Subject: Question about domains. From: Dmitriy Igrishin To: postgres list Content-Type: multipart/alternative; boundary=0016e649ceec3394f1048ae03fd4 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201007/46 X-Sequence-Number: 34359 --0016e649ceec3394f1048ae03fd4 Content-Type: text/plain; charset=ISO-8859-1 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 --0016e649ceec3394f1048ae03fd4 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 super= id AS integer;

CREATE TYPE idtype AS
(
=A0 id superid
);
CREATE TABLE mytab (id idtype NOT NULL);

ALTER DOMAIN superid AD= D CONSTRAINT superid_check CHECK (VALUE > 0);

ALTER DOMAIN superi= d DROP CONSTRAINT superid_check;

produces the following output:

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

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

Regards,
Dmitriy
--0016e649ceec3394f1048ae03fd4--