pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Stark <stark@mit.edu>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: atrigent@ccs.neu.edu
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6612: Functions can be called inside CHECK statements
Date: Wed, 25 Apr 2012 12:23:15 -0400
Message-ID: <7395.1335370995@sss.pgh.pa.us> (raw)
In-Reply-To: <CAM-w4HPq43NnPSE+7H1GwCZGzxCmd3Kwj_RzFZDn3UQsveHxow@mail.gmail.com>
References: <E1SMzX4-0004Is-FF@wrigleys.postgresql.org>
	<CAM-w4HMCCRD3SOKkdoRO0WHK6Vm5bYp-X_3gvtOxaU592+514g@mail.gmail.com>
	<4F97CCB80200002500047332@gw.wicourts.gov>
	<CAM-w4HPq43NnPSE+7H1GwCZGzxCmd3Kwj_RzFZDn3UQsveHxow@mail.gmail.com>

Greg Stark <stark@mit.edu> writes:
> On Wed, Apr 25, 2012 at 4:06 PM, Kevin Grittner
> <Kevin.Grittner@wicourts.gov> wrote:
>> A CHECK constraint using a volatile function is potentially valid
>> and useful, IMO.

> Hm. I suppose it depends on what you think a constraint is. I had
> always thought it was a guarantee that all the data in the table would
> meet that constraint. Not just a procedural definition for something
> to do at certain points in time.

Well, it's a guarantee that the expression evaluated to "true" at the
time of insertion or update of every row.  If you confine your attention
to immutable expressions then you can presume that the expression is
true for every row in the table at any time; but I'm with Kevin that
there are reasonable use-cases that don't fit into that.

> Hm, but this does raise the question of whether they're the right
> thing to be basing the partitioning constraint exclusion code on.

As long as we only consider expressions that are immutable as usable
partition constraints, that's not a problem.

> I'll
> speculate without checking again that we check the immutability of the
> constraint before using it in constraint exclusion but that seems a
> ad-hoc.

We do, and I don't see why that's ad-hoc.  In general the planner has to
check the volatility status of any expression it's going to try to
reason about.

			regards, tom lane



view thread (9+ messages)  latest in thread

Message-ID: <7395.1335370995@sss.pgh.pa.us>
Permalink:  ../7395.1335370995@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7395.1335370995@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, stark@mit.edu, Kevin.Grittner@wicourts.gov, atrigent@ccs.neu.edu
  Subject: Re: BUG #6612: Functions can be called inside CHECK statements
  In-Reply-To: <7395.1335370995@sss.pgh.pa.us>
  References: <E1SMzX4-0004Is-FF@wrigleys.postgresql.org> <CAM-w4HMCCRD3SOKkdoRO0WHK6Vm5bYp-X_3gvtOxaU592+514g@mail.gmail.com> <4F97CCB80200002500047332@gw.wicourts.gov> <CAM-w4HPq43NnPSE+7H1GwCZGzxCmd3Kwj_RzFZDn3UQsveHxow@mail.gmail.com> <7395.1335370995@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox