Re: Behavior of ON DELETE CASCADE in CTEs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kirk Parker <khp(at)equatoria(dot)us>
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Behavior of ON DELETE CASCADE in CTEs
Date: 2024-09-05 01:27:41
Message-ID: 1729420.1725499661@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Kirk Parker <khp(at)equatoria(dot)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

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message David G. Johnston 2024-09-05 01:40:31 Re: Behavior of ON DELETE CASCADE in CTEs
Previous Message Kirk Parker 2024-09-05 01:23:25 Behavior of ON DELETE CASCADE in CTEs