Re: creating CHECK constraints as NOT VALID

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: creating CHECK constraints as NOT VALID
Date: 2011-06-13 22:08:12
Message-ID: 1308002739-sup-1280@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Excerpts from Dean Rasheed's message of sáb jun 11 09:32:15 -0400 2011:
> On 1 June 2011 23:47, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> >
> > Here's a complete patch with all this stuff, plus doc additions and
> > simple regression tests for the new ALTER DOMAIN commands.
> >
> >    Enable CHECK constraints to be declared NOT VALID
> >
> >    This means that they can initially be added to a large existing table
> >    without checking its initial contents, but new tuples must comply to
> >    them; a separate pass invoked by ALTER TABLE / VALIDATE can verify
> >    existing data and ensure it complies with the constraint, at which point
> >    it is marked validated and becomes a normal part of the table ecosystem.
> >
>
> I think that you also need to update the constraint exclusion code
> (get_relation_constraints() or nearby), otherwise the planner might
> exclude a relation on the basis of a CHECK constraint that is not
> currently VALID.

Ouch, yeah, thanks for pointing that out. Fortunately the patch to fix
this is quite simple. I don't have it handy right now but I'll post it
soon.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2011-06-13 22:11:54 Re: creating CHECK constraints as NOT VALID
Previous Message Alvaro Herrera 2011-06-13 22:00:02 Re: wrong message on REASSIGN OWNED