Re: creating CHECK constraints as NOT VALID

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: creating CHECK constraints as NOT VALID
Date: 2011-06-15 19:21:09
Message-ID: 1308165565-sup-8531@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Excerpts from Tom Lane's message of mié jun 15 14:49:04 -0400 2011:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > Excerpts from Robert Haas's message of mié jun 15 12:53:59 -0400 2011:
> >> On Wed, Jun 15, 2011 at 12:24 PM, Alvaro Herrera
> >> <alvherre(at)commandprompt(dot)com> wrote:
> >>> Hmm, I think this means we need to send a sinval message to invalidate
> >>> cached plans when a constraint is validated. I'll see about this.
>
> >> I feel like that really ought to be happening automatically, as a
> >> result of committing the transaction that did the system catalog
> >> modification. It seems pretty strange if it isn't.
>
> > The catalog change takes place in pg_constraint, so I'm not sure that
> > it'd cause the sort of event we need. I'm testing whether adding a call
> > to CacheInvalidateRelcache in the appropriate place works.
>
> Currently, only updates in pg_class, pg_attribute, and pg_index cause
> automatic relcache invalidations --- see the logic in
> PrepareForTupleInvalidation. If you want to force replanning after an
> update elsewhere, you need to call CacheInvalidateRelcache. I've
> occasionally thought about extending the number of cases that get
> handled automatically by PrepareForTupleInvalidation, but not gotten off
> my duff to change it. I doubt that we want to make that routine know
> about *every* possible case, so it's a matter of tradeoffs ...

I think pg_trigger is closer to needing a new case in
PrepareForTupleInvalidation than pg_constraint, at this point --
triggers seem to be involved rather more with CacheInvalidateRelcache
(and close relatives) calls than constraints.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2011-06-15 19:29:57 Re: Strict Set Returning Functions
Previous Message Martin Pihlak 2011-06-15 19:20:34 Re: libpq SSL with non-blocking sockets