]> granicus.if.org Git - postgresql/commit
Refactor the executor's API to support data-modifying CTEs better.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 27 Feb 2011 18:43:29 +0000 (13:43 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 27 Feb 2011 18:44:12 +0000 (13:44 -0500)
commita874fe7b4c890d1fe3455215a83ca777867beadd
tree04b7870100a76bb79470abaf0f971550043590d7
parent67a5e727c8655496013b007d2fb6137fcc244b18
Refactor the executor's API to support data-modifying CTEs better.

The originally committed patch for modifying CTEs didn't interact well
with EXPLAIN, as noted by myself, and also had corner-case problems with
triggers, as noted by Dean Rasheed.  Those problems show it is really not
practical for ExecutorEnd to call any user-defined code; so split the
cleanup duties out into a new function ExecutorFinish, which must be called
between the last ExecutorRun call and ExecutorEnd.  Some Asserts have been
added to these functions to help verify correct usage.

It is no longer necessary for callers of the executor to call
AfterTriggerBeginQuery/AfterTriggerEndQuery for themselves, as this is now
done by ExecutorStart/ExecutorFinish respectively.  If you really need to
suppress that and do it for yourself, pass EXEC_FLAG_SKIP_TRIGGERS to
ExecutorStart.

Also, refactor portal commit processing to allow for the possibility that
PortalDrop will invoke user-defined code.  I think this is not actually
necessary just yet, since the portal-execution-strategy logic forces any
non-pure-SELECT query to be run to completion before we will consider
committing.  But it seems like good future-proofing.
21 files changed:
contrib/auto_explain/auto_explain.c
contrib/pg_stat_statements/pg_stat_statements.c
src/backend/access/transam/xact.c
src/backend/commands/copy.c
src/backend/commands/discard.c
src/backend/commands/explain.c
src/backend/commands/extension.c
src/backend/commands/portalcmds.c
src/backend/commands/trigger.c
src/backend/executor/README
src/backend/executor/execMain.c
src/backend/executor/execUtils.c
src/backend/executor/functions.c
src/backend/executor/spi.c
src/backend/tcop/pquery.c
src/backend/utils/mmgr/portalmem.c
src/include/executor/executor.h
src/include/nodes/execnodes.h
src/include/utils/portal.h
src/test/regress/expected/with.out
src/test/regress/sql/with.sql