Skip site navigation (1) Skip section navigation (2)

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 01:29:52
Message-ID: 1306891662-sup-7654@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-hackers
Excerpts from Thom Brown's message of mar may 31 20:18:18 -0400 2011:
> On 31 May 2011 18:43, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> >
> > Here it is -- as a context patch this time, as well.

> There is this scenario:
> 
> 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;

Oooh, I hadn't realized that I was opening the door for domains and
check constraints therein.  I'll have a look at this.

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

In response to

pgsql-hackers by date

Next:From: David FetterDate: 2011-06-01 01:42:08
Subject: Re: creating CHECK constraints as NOT VALID
Previous:From: Florian PflugDate: 2011-06-01 01:17:21
Subject: Another issue with invalid XML values

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group