pgsql: Refactor the executor's API to support data-modifying CTEs bette - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Refactor the executor's API to support data-modifying CTEs bette
Date
Msg-id E1Ptlbc-0002SG-UD@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a874fe7b4c890d1fe3455215a83ca777867beadd

Modified Files
--------------
contrib/auto_explain/auto_explain.c             |   28 ++++
contrib/pg_stat_statements/pg_stat_statements.c |   28 ++++
src/backend/access/transam/xact.c               |   60 ++++----
src/backend/commands/copy.c                     |    1 +
src/backend/commands/discard.c                  |    3 +-
src/backend/commands/explain.c                  |   25 +---
src/backend/commands/extension.c                |    3 +-
src/backend/commands/portalcmds.c               |   11 +-
src/backend/commands/trigger.c                  |    4 +-
src/backend/executor/README                     |    5 +
src/backend/executor/execMain.c                 |  135 ++++++++++++++----
src/backend/executor/execUtils.c                |    4 +-
src/backend/executor/functions.c                |   25 ++--
src/backend/executor/spi.c                      |   13 +-
src/backend/tcop/pquery.c                       |   20 +--
src/backend/utils/mmgr/portalmem.c              |  181 ++++++++++------------
src/include/executor/executor.h                 |   12 ++
src/include/nodes/execnodes.h                   |    2 +
src/include/utils/portal.h                      |    4 +-
src/test/regress/expected/with.out              |    6 +-
src/test/regress/sql/with.sql                   |    2 +-
21 files changed, 350 insertions(+), 222 deletions(-)


pgsql-committers by date:

Previous
From: Bruce Momjian
Date:
Subject: pgsql: Be less detailed about reporting shared memory failure by avoidi
Next
From: Peter Eisentraut
Date:
Subject: pgsql: Remove remaining expected file for Python 2.2