"Daniel Grace" <dgr...@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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs