pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: PegoraroF10 <marcos@f10.com.br>
Cc: pgsql-general@postgresql.org
Subject: Re: with and trigger
Date: Wed, 29 May 2019 09:26:05 -0400
Message-ID: <2487.1559136365@sss.pgh.pa.us> (raw)
In-Reply-To: <1559130758966-0.post@n3.nabble.com>
References: <1559130758966-0.post@n3.nabble.com>

PegoraroF10 <marcos@f10.com.br> writes:
> We like to use With to insert, update and return some value to user. But some
> informations of those related tables are not available on that time, is that
> a bug ?

No, see the "WITH Clause" section of the SELECT reference page:

    The primary query and the WITH queries are all (notionally) executed
    at the same time. This implies that the effects of a data-modifying
    statement in WITH cannot be seen from other parts of the query, other
    than by reading its RETURNING output. If two such data-modifying
    statements attempt to modify the same row, the results are
    unspecified.

This doesn't explicitly talk about triggers, but I think our attitude
about the case you're discussing is that the results are unspecified.
If a trigger fired in one WITH arm tries to look at the table(s)
modified by other WITH arms, it might or might not see those changes.

			regards, tom lane





view thread (8+ messages)  latest in thread

Message-ID: <2487.1559136365@sss.pgh.pa.us>
Permalink:  ../2487.1559136365@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2487.1559136365@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, marcos@f10.com.br
  Subject: Re: with and trigger
  In-Reply-To: <2487.1559136365@sss.pgh.pa.us>
  References: <1559130758966-0.post@n3.nabble.com> <2487.1559136365@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