Re: Forcefully adding a CHECK constrained

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: "Catalin(ux) M(dot) BOIE" <catab(at)embedromix(dot)ro>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Forcefully adding a CHECK constrained
Date: 2012-05-28 08:11:23
Message-ID: CABRT9RCFrGANgdJ=Mfd5jB9d6LzdECdKxhyntKJWJds4He-Z_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 15, 2012 at 12:52 PM, Catalin(ux) M. BOIE
<catab(at)embedromix(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Anthony Bull 2012-05-28 09:11:01 PostgreSQL disk space reclaiming
Previous Message Catalin M. Boie (ux) 2012-05-28 06:13:36 Re: [GENERAL] Forcefully adding a CHECK constrained