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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Refactor the executor's API to support data-modifying CTEs bette
Date: 2011-02-27 18:44:32
Message-ID: E1Ptlbc-0002SG-UD@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

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(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2011-02-27 19:16:07 pgsql: Remove remaining expected file for Python 2.2
Previous Message Bruce Momjian 2011-02-27 17:21:59 pgsql: Be less detailed about reporting shared memory failure by avoidi

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-02-27 18:55:48 Re: wCTE: why not finish sub-updates at the end, not the beginning?
Previous Message Robert Haas 2011-02-27 17:44:35 Re: WIP: cross column correlation ...