Thread: Deferrable constraint checking with SAVEPOINT?

Deferrable constraint checking with SAVEPOINT?

From
Mike Toews
Date:
Hi,

I have a question that is not specified in the docs[1]. I am using
deferrable constraints in a transaction with SET CONSTRAINTS ALL
DEFERRED. Now I know that DEFERRED constraints are not checked until
transaction COMMIT (i.e., the end), however are they checked with
SAVEPOINT (i.e., part-way in)?

Thanks,

-Mike

[1] http://www.postgresql.org/docs/8.4/static/sql-set-constraints.html

Re: Deferrable constraint checking with SAVEPOINT?

From
Dean Rasheed
Date:
On 8 June 2010 03:02, Mike Toews <mwtoews@gmail.com> wrote:
> Hi,
>
> I have a question that is not specified in the docs[1]. I am using
> deferrable constraints in a transaction with SET CONSTRAINTS ALL
> DEFERRED. Now I know that DEFERRED constraints are not checked until
> transaction COMMIT (i.e., the end), however are they checked with
> SAVEPOINT (i.e., part-way in)?
>

No, SAVEPOINTs will not force a check. A SAVEPOINT is nothing like a
COMMIT (it's more like a nested BEGIN). The only things that will
cause deferred constraints to be checked are a COMMIT or a SET
CONSTRAINTS .. IMMEDIATE.

Regards,
Dean