pgsql: Support data-modifying commands (INSERT/UPDATE/DELETE) in WITH.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Support data-modifying commands (INSERT/UPDATE/DELETE) in WITH.
Date: 2011-02-25 23:58:26
Message-ID: E1Pt7YI-0000VG-Dz@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-committers

Support data-modifying commands (INSERT/UPDATE/DELETE) in WITH.

This patch implements data-modifying WITH queries according to the
semantics that the updates all happen with the same command counter value,
and in an unspecified order. Therefore one WITH clause can't see the
effects of another, nor can the outer query see the effects other than
through the RETURNING values. And attempts to do conflicting updates will
have unpredictable results. We'll need to document all that.

This commit just fixes the code; documentation updates are waiting on
author.

Marko Tiikkaja and Hitoshi Harada

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/389af951552ff2209eae3e62fa147fef12329d4f

Modified Files
--------------
src/backend/commands/tablecmds.c | 3 +-
src/backend/commands/view.c | 14 +
src/backend/executor/execMain.c | 155 ++++++---
src/backend/executor/execUtils.c | 2 +
src/backend/executor/nodeModifyTable.c | 151 ++++++---
src/backend/nodes/copyfuncs.c | 4 +
src/backend/nodes/equalfuncs.c | 1 +
src/backend/nodes/nodeFuncs.c | 50 +++
src/backend/nodes/outfuncs.c | 6 +-
src/backend/nodes/readfuncs.c | 1 +
src/backend/optimizer/plan/createplan.c | 5 +-
src/backend/optimizer/plan/planner.c | 22 +-
src/backend/optimizer/plan/setrefs.c | 16 +-
src/backend/optimizer/plan/subselect.c | 11 +-
src/backend/parser/analyze.c | 16 +
src/backend/parser/gram.y | 4 +-
src/backend/parser/parse_clause.c | 2 +-
src/backend/parser/parse_cte.c | 60 +++-
src/backend/parser/parse_relation.c | 21 ++-
src/backend/parser/parse_target.c | 10 +-
src/backend/rewrite/rewriteDefine.c | 8 +
src/backend/rewrite/rewriteHandler.c | 68 ++++
src/backend/tcop/pquery.c | 36 ++-
src/backend/tcop/utility.c | 2 +
src/backend/utils/adt/ruleutils.c | 2 +-
src/backend/utils/cache/plancache.c | 1 +
src/include/catalog/catversion.h | 2 +-
src/include/executor/executor.h | 2 +-
src/include/nodes/execnodes.h | 9 +-
src/include/nodes/parsenodes.h | 12 +-
src/include/nodes/plannodes.h | 4 +
src/include/nodes/relation.h | 4 +-
src/include/optimizer/planmain.h | 4 +-
src/include/parser/parse_node.h | 1 +
src/include/parser/parse_relation.h | 2 +-
src/include/utils/portal.h | 6 +
src/test/regress/expected/with.out | 563 ++++++++++++++++++++++++++++++-
src/test/regress/sql/with.sql | 204 +++++++++++-
38 files changed, 1323 insertions(+), 161 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-02-26 04:54:07 pgsql: Fix order of shutdown processing when CTEs contain inter-referen
Previous Message Alvaro Herrera 2011-02-25 22:41:02 Re: pgsql: Fix pageinspect's heap_page_item to return infomasks as 32 bit v