Re: Re: [GENERAL] Forcefully adding a CHECK constrained - Mailing list pgsql-general

From Tom Lane
Subject Re: Re: [GENERAL] Forcefully adding a CHECK constrained
Date
Msg-id 8014.1338224116@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] Forcefully adding a CHECK constrained  ("Catalin(ux) M. Boie" <catab@embedromix.ro>)
List pgsql-general
"=?utf-8?B?Q2F0YWxpbih1eCkgTS4gQm9pZQ==?=" <catab@embedromix.ro> writes:
> I hope I make myself clear now: I want a possibility to add a CHECK that will be used for partitioning without having
toread all data for validation. 

Basically, this is unlikely to be accepted, because it does not conform
with the project's worldview.

If you are intent on being smarter than the database is, you could
probably create a NOT VALID constraint and then manually poke the system
catalogs to mark it as valid.  Then, when (not if) you make a mistake,
you will have only yourself to blame.

A patch that would stand some chance of getting accepted would be one
that would act like CREATE INDEX CONCURRENTLY: create the constraint as
NOT VALID (so it's getting enforced against new rows), then in
background scan all the existing rows to make sure they meet the
constraint too, then finally mark the constraint VALID.  But we don't
consider that second step to be optional.

            regards, tom lane

pgsql-general by date:

Previous
From: Karl Denninger
Date:
Subject: Re: Attempting to do a rolling move to 9.2Beta (as a slave) fails
Next
From: Tom Lane
Date:
Subject: Re: PostgreSQL reclaiming table space