The following documentation comment has been logged on the website: Page: https://www.postgresql.org/docs/17/sql-insert.html Description:
Hi, the example found in the doc above: WITH upd AS ( UPDATE employees SET sales_count = sales_count + 1 WHERE id = (SELECT sales_person FROM accounts WHERE name = 'Acme Corporation') RETURNING * ) INSERT INTO employees_log SELECT *, current_timestamp FROM upd; might result into UPDATE 0 / INSERT 0 because the documentation regarding the CTE states: "The sub-statements in WITH are executed concurrently with each other and with the main query". The subquery SELECT sales_person FROM accounts WHERE name = 'Acme Corporation' might not be waited on by the UPDATE query resulting into an UPDATE 0. Is my suspicion valid?