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

From Marti Raudsepp
Subject Re: Forcefully adding a CHECK constrained
Date
Msg-id CABRT9RCFrGANgdJ=Mfd5jB9d6LzdECdKxhyntKJWJds4He-Z_g@mail.gmail.com
Whole thread Raw
In response to Forcefully adding a CHECK constrained  ("Catalin(ux) M. BOIE" <catab@embedromix.ro>)
List pgsql-general
On Tue, May 15, 2012 at 12:52 PM, Catalin(ux) M. BOIE
<catab@embedromix.ro> wrote:
> The old_stats is so big that I cannot afford to add a check constraint.
> But, I know that all values of the itime field are before 2012_04, so, would
> be great if I could run something like:

If you Really Really need it and if you're feeling adventurous, you
can attempt to create the constraint on another table and then
"rename" the constraint definition in pg_constraint and pg_depend
catalogs. But doing this WILL VOID YOUR WARRANTY! :)

It's fairly complicated, you have to take care to get every bit of
information right. In particular, if there are any deleted columns in
the old_stats table, the attribute numbers will not match, which can
cause errors or segfaults. Double check from pg_attribute.

And certainly do it in a test environment first; make sure with
pg_dump and restore that it understands the constraint correctly.

Regards,
Marti

pgsql-general by date:

Previous
From: "Catalin(ux) M. Boie"
Date:
Subject: Re: [GENERAL] Forcefully adding a CHECK constrained
Next
From: Anthony Bull
Date:
Subject: PostgreSQL reclaiming table space