1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

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.
This commit is contained in:
Tom Lane
2004-08-01 17:32:22 +00:00
parent 9d9cdf82a4
commit efcaf1e868
23 changed files with 1103 additions and 330 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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