Re: creating CHECK constraints as NOT VALID

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Thom Brown <thom(at)linux(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: creating CHECK constraints as NOT VALID
Date: 2011-06-01 17:53:12
Message-ID: 1306950569-sup-1858@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Excerpts from Thom Brown's message of mar may 31 20:18:18 -0400 2011:

> test=# CREATE DOMAIN things AS INT CHECK (VALUE > 5);
> CREATE DOMAIN
> test=# CREATE TABLE abc (id SERIAL, stuff things);
> NOTICE: CREATE TABLE will create implicit sequence "abc_id_seq" for
> serial column "abc.id"
> CREATE TABLE
> test=# INSERT INTO abc (stuff) VALUES (55);
> INSERT 0 1
> test=# ALTER DOMAIN things ADD CONSTRAINT meow CHECK (VALUE < 11) NOT VALID;
> ERROR: column "stuff" of table "abc" contains values that violate the
> new constraint
> STATEMENT: ALTER DOMAIN things ADD CONSTRAINT meow CHECK (VALUE < 11)
> NOT VALID;

Okay, fixed that and added ALTER DOMAIN VALIDATE CONSTRAINT too.
Thanks for the review.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment Content-Type Size
0001-Make-NOT-VALID-constraints-work-on-domains-too.patch application/octet-stream 8.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2011-06-01 17:57:32 Re: patch for new feature: Buffer Cache Hibernation
Previous Message Tom Lane 2011-06-01 17:21:03 Re: [BUGS] BUG #6034: pg_upgrade fails when it should not.