creating CHECK constraints as NOT VALID - Mailing list pgsql-hackers

From Alvaro Herrera
Subject creating CHECK constraints as NOT VALID
Date
Msg-id 1306857681-sup-6306@alvh.no-ip.org
Whole thread Raw
Responses Re: creating CHECK constraints as NOT VALID  (Jaime Casanova <jaime@2ndquadrant.com>)
Re: creating CHECK constraints as NOT VALID  (Robert Haas <robertmhaas@gmail.com>)
Re: creating CHECK constraints as NOT VALID  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Re: creating CHECK constraints as NOT VALID  (David Fetter <david@fetter.org>)
List pgsql-hackers
This patch allows you to initially declare a CHECK constraint as NOT
VALID, similar to what we already allow for foreign keys.  That is, you
create the constraint without scanning the table and after it is
committed, it is enforced for new rows; later, all rows are checked by
running ALTER TABLE VALIDATE CONSTRAINT, which doesn't need
AccessExclusive thus allowing for better concurrency.

The trickiest bit here was realizing that unlike FKs, check constraints
do inherit, and so needed special treatment for recursion.  Other than
that I think this was pretty straightforward.

I intend to attempt to apply this to NOT NULL constraints as well, once
the patch to add them to pg_constraint is in.

Thoughts?

This patch courtesy of Enova Financial.

-- 
Álvaro Herrera <alvherre@alvh.no-ip.org>


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Getting a bug tracker for the Postgres project
Next
From: Heikki Linnakangas
Date:
Subject: Re: Nested CASE-WHEN scoping