Re: Behavior of ON DELETE CASCADE in CTEs

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Kirk Parker <khp(at)equatoria(dot)us>
Cc: "pgsql-docs(at)lists(dot)postgresql(dot)org" <pgsql-docs(at)lists(dot)postgresql(dot)org>
Subject: Re: Behavior of ON DELETE CASCADE in CTEs
Date: 2024-09-05 01:40:31
Message-ID: CAKFQuwbr=xhxaDYekUSbpCcyTe_Xak2BTw9TpoaW6S95n+iO_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Wednesday, September 4, 2024, Kirk Parker <khp(at)equatoria(dot)us> wrote:

>
> And the relevance to this current list is: if it IS intended behavior, can
> it be documented somewhere?
>

It’s follows from this paragraph:

https://www.postgresql.org/docs/current/queries-with.html#QUERIES-WITH-MODIFYING

The sub-statements in WITH are executed concurrently with each other and
with the main query. Therefore, when using data-modifying statements in WITH,
the order in which the specified updates actually happen is unpredictable.
All the statements are executed with the same *snapshot* (see Chapter 13
<https://www.postgresql.org/docs/current/mvcc.html>), so they cannot “see” one
another's effects on the target tables. This alleviates the effects of the
unpredictability of the actual order of row updates, and means that
RETURNING data is the only way to communicate changes between
different WITH sub-statements
and the main query.

David J.

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Kirk Parker 2024-09-05 02:46:35 Re: Behavior of ON DELETE CASCADE in CTEs
Previous Message Tom Lane 2024-09-05 01:27:41 Re: Behavior of ON DELETE CASCADE in CTEs