pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kirk Parker <khp@equatoria.us>
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: Behavior of ON DELETE CASCADE in CTEs
Date: Wed, 04 Sep 2024 21:27:41 -0400
Message-ID: <1729420.1725499661@sss.pgh.pa.us> (raw)
In-Reply-To: <CANwZ8rm9Knqjf7K00j_mQW0Dkh45E+OQGtj+f4qESs4cE3YSSw@mail.gmail.com>
References: <CANwZ8rm9Knqjf7K00j_mQW0Dkh45E+OQGtj+f4qESs4cE3YSSw@mail.gmail.com>

Kirk Parker <khp@equatoria.us> writes:
> It appears that in With-queries (CTE) the ON CASCADE DELETE deletions
> happen at the very end of the entire statement. I have two questions about
> this:

> (1) Is this a correct observation?
> (2) Is this intentional behavior, or only an accident of the implementation?

I believe it's required by SQL spec.  Or more accurately, the spec
says that constraint-triggered actions happen either at the end of the
statement or the end of the transaction, depending on whether you set
them as "deferred".

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <1729420.1725499661@sss.pgh.pa.us>
Permalink:  ../1729420.1725499661@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1729420.1725499661@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 using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, khp@equatoria.us, pgsql-docs@lists.postgresql.org
  Subject: Re: Behavior of ON DELETE CASCADE in CTEs
  In-Reply-To: <1729420.1725499661@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