Re: [PATCH] SQL assertions prototype - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: [PATCH] SQL assertions prototype
Date
Msg-id CA+U5nML--wR-y6KvkCnKJOU_9oFgZMx=HzJCRdryi9kaP+yF3g@mail.gmail.com
Whole thread Raw
In response to [PATCH] SQL assertions prototype  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: [PATCH] SQL assertions prototype  (Andrew Tipton <andrew@kiwidrew.com>)
Re: [PATCH] SQL assertions prototype  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
On 15 November 2013 03:30, Peter Eisentraut <peter_e@gmx.net> wrote:

> A constraint trigger performs the actual checking.

Good, that is consistent with other constraints.

> This is not a performance feature.  It's for things like, this table
> should have at most 10 rows, or all the values in this table must be
> bigger than all the values in that other table.  It's a bit esoteric,
> but it comes up again and again.

While I accept it may never perform well, it needs to perform reasonably well.

The key use cases for this are

* enforcing "one and only one" relationships
* enforcing quantified relationships like we do in XML: minoccurs and maxoccurs
* enforcing only one sub-type across multiple sub-type tables
etc

So we'd need to get access to the changed rows, rather than
re-executing a huge SQL command that re-checks every row of the table.
That last point will make it unusable for sensible amounts of data.

-- Simon Riggs                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: pre-commit triggers
Next
From: Simon Riggs
Date:
Subject: Re: preserving forensic information when we freeze