Re: with and trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: PegoraroF10 <marcos(at)f10(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: with and trigger
Date: 2019-05-29 13:26:05
Message-ID: 2487.1559136365@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

PegoraroF10 <marcos(at)f10(dot)com(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-05-29 14:20:12 Re:
Previous Message PegoraroF10 2019-05-29 13:10:23 Re: with and trigger