diff options
| author | Tom Lane | 2004-08-01 17:32:22 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-08-01 17:32:22 +0000 |
| commit | efcaf1e868d8399d932e68b8b248bcbd089b2d6b (patch) | |
| tree | c6235945f73faab427498dd8662efab5cf2fe5fd /src/pl | |
| parent | 9d9cdf82a404f3e2a2d82cefc2c35ded55bb3b2e (diff) | |
Some mop-up work for savepoints (nested transactions). Store a small
number of active subtransaction XIDs in each backend's PGPROC entry,
and use this to avoid expensive probes into pg_subtrans during
TransactionIdIsInProgress. Extend EOXactCallback API to allow add-on
modules to get control at subxact start/end. (This is deliberately
not compatible with the former API, since any uses of that API probably
need manual review anyway.) Add basic reference documentation for
SAVEPOINT and related commands. Minor other cleanups to check off some
of the open issues for subtransactions.
Alvaro Herrera and Tom Lane.
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 52 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_handler.c | 4 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/plpgsql.h | 4 |
3 files changed, 39 insertions, 21 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 4c579223d91..f075b96c0fc 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.111 2004/07/31 23:04:56 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.112 2004/08/01 17:32:21 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -4216,26 +4216,44 @@ exec_set_found(PLpgSQL_execstate * estate, bool state) * structs that are using it as no longer active. */ void -plpgsql_eoxact(bool isCommit, void *arg) +plpgsql_xact_cb(XactEvent event, TransactionId parentXid, void *arg) { PLpgSQL_expr *expr; PLpgSQL_expr *enext; - /* Mark all active exprs as inactive */ - for (expr = active_simple_exprs; expr; expr = enext) + switch (event) { - enext = expr->expr_simple_next; - expr->expr_simple_state = NULL; - expr->expr_simple_next = NULL; + /* + * Nothing to do at subtransaction events + * + * XXX really? Maybe subtransactions need to have their own + * simple_eval_estate? It would get a lot messier, so for now + * let's assume we don't need that. + */ + case XACT_EVENT_START_SUB: + case XACT_EVENT_ABORT_SUB: + case XACT_EVENT_COMMIT_SUB: + break; + + case XACT_EVENT_ABORT: + case XACT_EVENT_COMMIT: + /* Mark all active exprs as inactive */ + for (expr = active_simple_exprs; expr; expr = enext) + { + enext = expr->expr_simple_next; + expr->expr_simple_state = NULL; + expr->expr_simple_next = NULL; + } + active_simple_exprs = NULL; + /* + * If we are doing a clean transaction shutdown, free the EState + * (so that any remaining resources will be released correctly). + * In an abort, we expect the regular abort recovery procedures to + * release everything of interest. + */ + if (event == XACT_EVENT_COMMIT && simple_eval_estate) + FreeExecutorState(simple_eval_estate); + simple_eval_estate = NULL; + break; } - active_simple_exprs = NULL; - /* - * If we are doing a clean transaction shutdown, free the EState - * (so that any remaining resources will be released correctly). - * In an abort, we expect the regular abort recovery procedures to - * release everything of interest. - */ - if (isCommit && simple_eval_estate) - FreeExecutorState(simple_eval_estate); - simple_eval_estate = NULL; } diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index 5f6a83c11d6..d4e892eb719 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.22 2004/07/31 20:55:44 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.23 2004/08/01 17:32:22 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -66,7 +66,7 @@ plpgsql_init(void) plpgsql_HashTableInit(); - RegisterEOXactCallback(plpgsql_eoxact, NULL); + RegisterXactCallback(plpgsql_xact_cb, NULL); plpgsql_firstcall = 0; } diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index d57d4a7025e..e054d5b25f1 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.49 2004/07/31 23:04:56 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.50 2004/08/01 17:32:22 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -702,7 +702,7 @@ extern Datum plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo); extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function * func, TriggerData *trigdata); -extern void plpgsql_eoxact(bool isCommit, void *arg); +extern void plpgsql_xact_cb(XactEvent event, TransactionId parentXid, void *arg); /* ---------- * Functions for the dynamic string handling in pl_funcs.c |
