Re: BUG #5987: Rows created by WITH (INSERT ... RETURNING) are not visible to the rest of the query

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #5987: Rows created by WITH (INSERT ... RETURNING) are not visible to the rest of the query
Дата
Msg-id 7850.1303241387@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #5987: Rows created by WITH (INSERT ... RETURNING) are not visible to the rest of the query  ("Daniel Grace" <dgrace@wingsnw.com>)
Список pgsql-bugs
"Daniel Grace" <dgrace@wingsnw.com> writes:
> Description:        Rows created by WITH (INSERT ... RETURNING) are not
> visible to the rest of the query

This is not a bug but the designed behavior.  See
http://developer.postgresql.org/pgdocs/postgres/queries-with.html

particularly this bit:

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), so they cannot "see" each others' 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.

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Daniel Grace"
Дата:
Сообщение: BUG #5987: Rows created by WITH (INSERT ... RETURNING) are not visible to the rest of the query
Следующее
От: Dewin
Дата:
Сообщение: Re: BUG #5985: CLUSTER ... USING can fail with ERROR: index xxx does not belong to table yyy