#include "access/xlog.h"
#include "nodes/pg_list.h"
#include "storage/relfilenode.h"
Go to the source code of this file.
#define IsolationIsSerializable | ( | ) | (XactIsoLevel == XACT_SERIALIZABLE) |
Definition at line 41 of file xact.h.
Referenced by begin_remote_xact(), GetSerializableTransactionSnapshot(), GetTransactionSnapshot(), ImportSnapshot(), PreCommit_CheckForSerializationFailure(), ReleasePredicateLocks(), SetSerializableTransactionSnapshot(), and SetTransactionSnapshot().
#define IsolationUsesXactSnapshot | ( | ) | (XactIsoLevel >= XACT_REPEATABLE_READ) |
Definition at line 40 of file xact.h.
Referenced by EvalPlanQualFetch(), ExecDelete(), ExecLockRows(), ExecUpdate(), GetTransactionSnapshot(), GetTupleForTrigger(), ImportSnapshot(), ri_PerformCheck(), and SetTransactionSnapshot().
#define MinSizeOfXactAbort offsetof(xl_xact_abort, xnodes) |
#define MinSizeOfXactAbortPrepared offsetof(xl_xact_abort_prepared, arec.xnodes) |
#define MinSizeOfXactAssignment offsetof(xl_xact_assignment, xsub) |
#define MinSizeOfXactCommit offsetof(xl_xact_commit, xnodes) |
#define MinSizeOfXactCommitCompact offsetof(xl_xact_commit_compact, subxacts) |
#define MinSizeOfXactCommitPrepared offsetof(xl_xact_commit_prepared, crec.xnodes) |
#define XACT_COMPLETION_UPDATE_RELCACHE_FILE 0x01 |
Definition at line 159 of file xact.h.
Referenced by RecordTransactionCommitPrepared().
#define XACT_READ_COMMITTED 1 |
Definition at line 26 of file xact.h.
Referenced by show_XactIsoLevel().
#define XACT_READ_UNCOMMITTED 0 |
Definition at line 25 of file xact.h.
Referenced by show_XactIsoLevel().
#define XACT_REPEATABLE_READ 2 |
Definition at line 27 of file xact.h.
Referenced by show_XactIsoLevel().
#define XACT_SERIALIZABLE 3 |
Definition at line 28 of file xact.h.
Referenced by check_XactIsoLevel(), ImportSnapshot(), and show_XactIsoLevel().
#define XactCompletionForceSyncCommit | ( | xinfo | ) | (xinfo & XACT_COMPLETION_FORCE_SYNC_COMMIT) |
Definition at line 164 of file xact.h.
Referenced by xact_redo_commit_internal().
#define XactCompletionRelcacheInitFileInval | ( | xinfo | ) | (xinfo & XACT_COMPLETION_UPDATE_RELCACHE_FILE) |
Definition at line 163 of file xact.h.
Referenced by xact_desc_commit(), and xact_redo_commit_internal().
#define XLOG_XACT_ABORT 0x20 |
Definition at line 109 of file xact.h.
Referenced by RecordTransactionAbort(), recoveryStopsHere(), xact_desc(), and xact_redo().
#define XLOG_XACT_ABORT_PREPARED 0x40 |
Definition at line 111 of file xact.h.
Referenced by RecordTransactionAbortPrepared(), xact_desc(), and xact_redo().
#define XLOG_XACT_ASSIGNMENT 0x50 |
Definition at line 112 of file xact.h.
Referenced by AssignTransactionId(), xact_desc(), and xact_redo().
#define XLOG_XACT_COMMIT 0x00 |
Definition at line 107 of file xact.h.
Referenced by RecordTransactionCommit(), recoveryStopsHere(), xact_desc(), and xact_redo().
#define XLOG_XACT_COMMIT_COMPACT 0x60 |
Definition at line 113 of file xact.h.
Referenced by RecordTransactionCommit(), recoveryStopsHere(), xact_desc(), and xact_redo().
#define XLOG_XACT_COMMIT_PREPARED 0x30 |
Definition at line 110 of file xact.h.
Referenced by RecordTransactionCommitPrepared(), xact_desc(), and xact_redo().
#define XLOG_XACT_PREPARE 0x10 |
Definition at line 108 of file xact.h.
Referenced by EndPrepare(), xact_desc(), and xact_redo().
typedef void(* SubXactCallback)(SubXactEvent event, SubTransactionId mySubid, SubTransactionId parentSubid, void *arg) |
typedef void(* XactCallback)(XactEvent event, void *arg) |
typedef struct xl_xact_abort xl_xact_abort |
typedef struct xl_xact_abort_prepared xl_xact_abort_prepared |
typedef struct xl_xact_assignment xl_xact_assignment |
typedef struct xl_xact_commit xl_xact_commit |
typedef struct xl_xact_commit_compact xl_xact_commit_compact |
typedef struct xl_xact_commit_prepared xl_xact_commit_prepared |
enum SubXactEvent |
SUBXACT_EVENT_START_SUB | |
SUBXACT_EVENT_COMMIT_SUB | |
SUBXACT_EVENT_ABORT_SUB | |
SUBXACT_EVENT_PRE_COMMIT_SUB |
Definition at line 86 of file xact.h.
{ SUBXACT_EVENT_START_SUB, SUBXACT_EVENT_COMMIT_SUB, SUBXACT_EVENT_ABORT_SUB, SUBXACT_EVENT_PRE_COMMIT_SUB } SubXactEvent;
enum SyncCommitLevel |
SYNCHRONOUS_COMMIT_OFF | |
SYNCHRONOUS_COMMIT_LOCAL_FLUSH | |
SYNCHRONOUS_COMMIT_REMOTE_WRITE | |
SYNCHRONOUS_COMMIT_REMOTE_FLUSH |
Definition at line 54 of file xact.h.
{ SYNCHRONOUS_COMMIT_OFF, /* asynchronous commit */ SYNCHRONOUS_COMMIT_LOCAL_FLUSH, /* wait for local flush only */ SYNCHRONOUS_COMMIT_REMOTE_WRITE, /* wait for local flush and remote * write */ SYNCHRONOUS_COMMIT_REMOTE_FLUSH /* wait for local and remote flush */ } SyncCommitLevel;
enum XactEvent |
XACT_EVENT_COMMIT | |
XACT_EVENT_ABORT | |
XACT_EVENT_PREPARE | |
XACT_EVENT_PRE_COMMIT | |
XACT_EVENT_PRE_PREPARE |
Definition at line 75 of file xact.h.
{ XACT_EVENT_COMMIT, XACT_EVENT_ABORT, XACT_EVENT_PREPARE, XACT_EVENT_PRE_COMMIT, XACT_EVENT_PRE_PREPARE } XactEvent;
void AbortCurrentTransaction | ( | void | ) |
Definition at line 2745 of file xact.c.
References AbortCurrentTransaction(), AbortSubTransaction(), AbortTransaction(), TransactionStateData::blockState, CleanupSubTransaction(), CleanupTransaction(), TransactionStateData::state, TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, TBLOCK_SUBRESTART, TRANS_DEFAULT, and TRANS_START.
Referenced by AbortCurrentTransaction(), AutoVacLauncherMain(), and PostgresMain().
{ TransactionState s = CurrentTransactionState; switch (s->blockState) { case TBLOCK_DEFAULT: if (s->state == TRANS_DEFAULT) { /* we are idle, so nothing to do */ } else { /* * We can get here after an error during transaction start * (state will be TRANS_START). Need to clean up the * incompletely started transaction. First, adjust the * low-level state to suppress warning message from * AbortTransaction. */ if (s->state == TRANS_START) s->state = TRANS_INPROGRESS; AbortTransaction(); CleanupTransaction(); } break; /* * if we aren't in a transaction block, we just do the basic abort * & cleanup transaction. */ case TBLOCK_STARTED: AbortTransaction(); CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * If we are in TBLOCK_BEGIN it means something screwed up right * after reading "BEGIN TRANSACTION". We assume that the user * will interpret the error as meaning the BEGIN failed to get him * into a transaction block, so we should abort and return to idle * state. */ case TBLOCK_BEGIN: AbortTransaction(); CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * We are somewhere in a transaction block and we've gotten a * failure, so we abort the transaction and set up the persistent * ABORT state. We will stay in ABORT until we get a ROLLBACK. */ case TBLOCK_INPROGRESS: AbortTransaction(); s->blockState = TBLOCK_ABORT; /* CleanupTransaction happens when we exit TBLOCK_ABORT_END */ break; /* * Here, we failed while trying to COMMIT. Clean up the * transaction and return to idle state (we do not want to stay in * the transaction). */ case TBLOCK_END: AbortTransaction(); CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * Here, we are already in an aborted transaction state and are * waiting for a ROLLBACK, but for some reason we failed again! So * we just remain in the abort state. */ case TBLOCK_ABORT: case TBLOCK_SUBABORT: break; /* * We are in a failed transaction and we got the ROLLBACK command. * We have already aborted, we just need to cleanup and go to idle * state. */ case TBLOCK_ABORT_END: CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * We are in a live transaction and we got a ROLLBACK command. * Abort, cleanup, go to idle state. */ case TBLOCK_ABORT_PENDING: AbortTransaction(); CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * Here, we failed while trying to PREPARE. Clean up the * transaction and return to idle state (we do not want to stay in * the transaction). */ case TBLOCK_PREPARE: AbortTransaction(); CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * We got an error inside a subtransaction. Abort just the * subtransaction, and go to the persistent SUBABORT state until * we get ROLLBACK. */ case TBLOCK_SUBINPROGRESS: AbortSubTransaction(); s->blockState = TBLOCK_SUBABORT; break; /* * If we failed while trying to create a subtransaction, clean up * the broken subtransaction and abort the parent. The same * applies if we get a failure while ending a subtransaction. */ case TBLOCK_SUBBEGIN: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: AbortSubTransaction(); CleanupSubTransaction(); AbortCurrentTransaction(); break; /* * Same as above, except the Abort() was already done. */ case TBLOCK_SUBABORT_END: case TBLOCK_SUBABORT_RESTART: CleanupSubTransaction(); AbortCurrentTransaction(); break; } }
void AbortOutOfAnyTransaction | ( | void | ) |
Definition at line 3862 of file xact.c.
References AbortSubTransaction(), AbortTransaction(), Assert, TransactionStateData::blockState, CleanupSubTransaction(), CleanupTransaction(), NULL, TransactionStateData::parent, TransactionStateData::state, TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, TBLOCK_SUBRESTART, TRANS_DEFAULT, and TRANS_START.
Referenced by do_autovacuum(), RemoveTempRelationsCallback(), and ShutdownPostgres().
{ TransactionState s = CurrentTransactionState; /* * Get out of any transaction or nested transaction */ do { switch (s->blockState) { case TBLOCK_DEFAULT: if (s->state == TRANS_DEFAULT) { /* Not in a transaction, do nothing */ } else { /* * We can get here after an error during transaction start * (state will be TRANS_START). Need to clean up the * incompletely started transaction. First, adjust the * low-level state to suppress warning message from * AbortTransaction. */ if (s->state == TRANS_START) s->state = TRANS_INPROGRESS; AbortTransaction(); CleanupTransaction(); } break; case TBLOCK_STARTED: case TBLOCK_BEGIN: case TBLOCK_INPROGRESS: case TBLOCK_END: case TBLOCK_ABORT_PENDING: case TBLOCK_PREPARE: /* In a transaction, so clean up */ AbortTransaction(); CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; case TBLOCK_ABORT: case TBLOCK_ABORT_END: /* AbortTransaction already done, still need Cleanup */ CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * In a subtransaction, so clean it up and abort parent too */ case TBLOCK_SUBBEGIN: case TBLOCK_SUBINPROGRESS: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: AbortSubTransaction(); CleanupSubTransaction(); s = CurrentTransactionState; /* changed by pop */ break; case TBLOCK_SUBABORT: case TBLOCK_SUBABORT_END: case TBLOCK_SUBABORT_RESTART: /* As above, but AbortSubTransaction already done */ CleanupSubTransaction(); s = CurrentTransactionState; /* changed by pop */ break; } } while (s->blockState != TBLOCK_DEFAULT); /* Should be out of all subxacts now */ Assert(s->parent == NULL); }
void BeginInternalSubTransaction | ( | char * | name | ) |
Definition at line 3730 of file xact.c.
References TransactionStateData::blockState, BlockStateAsString(), CommitTransactionCommand(), elog, FATAL, MemoryContextStrdup(), TransactionStateData::name, PushTransaction(), StartTransactionCommand(), TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, TBLOCK_SUBRESTART, and TopTransactionContext.
Referenced by exec_stmt_block(), plperl_spi_exec(), plperl_spi_exec_prepared(), plperl_spi_fetchrow(), plperl_spi_prepare(), plperl_spi_query(), plperl_spi_query_prepared(), pltcl_subtrans_begin(), PLy_spi_subtransaction_begin(), and PLy_subtransaction_enter().
{ TransactionState s = CurrentTransactionState; switch (s->blockState) { case TBLOCK_STARTED: case TBLOCK_INPROGRESS: case TBLOCK_END: case TBLOCK_PREPARE: case TBLOCK_SUBINPROGRESS: /* Normal subtransaction start */ PushTransaction(); s = CurrentTransactionState; /* changed by push */ /* * Savepoint names, like the TransactionState block itself, live * in TopTransactionContext. */ if (name) s->name = MemoryContextStrdup(TopTransactionContext, name); break; /* These cases are invalid. */ case TBLOCK_DEFAULT: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_ABORT: case TBLOCK_SUBABORT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: elog(FATAL, "BeginInternalSubTransaction: unexpected state %s", BlockStateAsString(s->blockState)); break; } CommitTransactionCommand(); StartTransactionCommand(); }
void BeginTransactionBlock | ( | void | ) |
Definition at line 3152 of file xact.c.
References TransactionStateData::blockState, BlockStateAsString(), elog, ereport, errcode(), errmsg(), FATAL, TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, TBLOCK_SUBRESTART, and WARNING.
Referenced by standard_ProcessUtility().
{ TransactionState s = CurrentTransactionState; switch (s->blockState) { /* * We are not inside a transaction block, so allow one to begin. */ case TBLOCK_STARTED: s->blockState = TBLOCK_BEGIN; break; /* * Already a transaction block in progress. */ case TBLOCK_INPROGRESS: case TBLOCK_SUBINPROGRESS: case TBLOCK_ABORT: case TBLOCK_SUBABORT: ereport(WARNING, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), errmsg("there is already a transaction in progress"))); break; /* These cases are invalid. */ case TBLOCK_DEFAULT: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: elog(FATAL, "BeginTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); break; } }
void CommandCounterIncrement | ( | void | ) |
Definition at line 758 of file xact.c.
References AtCCI_LocalCache(), currentCommandId, currentCommandIdUsed, ereport, errcode(), errmsg(), ERROR, FirstCommandId, and SnapshotSetCommandId().
Referenced by _SPI_execute_plan(), acquire_inherited_sample_rows(), AddRoleMems(), AlterRole(), ATAddCheckConstraint(), ATExecAddColumn(), ATExecAlterColumnType(), ATExecCmd(), ATExecDropColumn(), ATExecDropConstraint(), ATExecSetTableSpace(), CommitSubTransaction(), CommitTransactionCommand(), create_toast_table(), CreateFKCheckTrigger(), createForeignKeyTriggers(), CreateForeignTable(), CreateRole(), CreateSchemaCommand(), DefineCollation(), DefineDomain(), DefineQueryRewrite(), DefineRange(), DefineRelation(), DefineType(), DefineView(), deleteOneObject(), DelRoleMems(), DropRole(), EventTriggerDDLCommandEnd(), EventTriggerDDLCommandStart(), EventTriggerInvoke(), EventTriggerSQLDrop(), exec_eval_simple_expr(), exec_execute_message(), exec_parse_message(), exec_simple_query(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), execute_sql_string(), ExplainOnePlan(), findTypeInputFunction(), findTypeOutputFunction(), fmgr_sql(), index_build(), index_create(), InitTempTableNamespace(), intorel_startup(), inv_create(), inv_drop(), inv_truncate(), inv_write(), make_new_heap(), makeConfigurationDependencies(), moveArrayTypeName(), OperatorShellMake(), OperatorUpd(), PortalRunMulti(), PreCommit_on_commit_actions(), ProcedureCreate(), ProcessUtilitySlow(), reindex_relation(), RelationSetNewRelfilenode(), RenumberEnumType(), ri_PerformCheck(), shdepReassignOwned(), SPI_cursor_open_internal(), and StoreConstraints().
{ /* * If the current value of the command counter hasn't been "used" to mark * tuples, we need not increment it, since there's no need to distinguish * a read-only command from others. This helps postpone command counter * overflow, and keeps no-op CommandCounterIncrement operations cheap. */ if (currentCommandIdUsed) { currentCommandId += 1; if (currentCommandId == FirstCommandId) /* check for overflow */ { currentCommandId -= 1; ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("cannot have more than 2^32-1 commands in a transaction"))); } currentCommandIdUsed = false; /* Propagate new command ID into static snapshots */ SnapshotSetCommandId(currentCommandId); /* * Make any catalog changes done by the just-completed command visible * in the local syscache. We obviously don't need to do this after a * read-only command. (But see hacks in inval.c to make real sure we * don't think a command that queued inval messages was read-only.) */ AtCCI_LocalCache(); } }
void CommitTransactionCommand | ( | void | ) |
Definition at line 2508 of file xact.c.
References AbortSubTransaction(), AbortTransaction(), Assert, AssertState, TransactionStateData::blockState, BlockStateAsString(), CleanupSubTransaction(), CleanupTransaction(), CommandCounterIncrement(), CommitSubTransaction(), CommitTransaction(), CommitTransactionCommand(), DefineSavepoint(), elog, ERROR, FATAL, TransactionStateData::name, name, NULL, TransactionStateData::parent, PrepareTransaction(), TransactionStateData::savepointLevel, StartSubTransaction(), TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, and TBLOCK_SUBRESTART.
Referenced by BeginInternalSubTransaction(), cluster(), CommitTransactionCommand(), DefineIndex(), do_autovacuum(), finish_xact_command(), get_database_list(), index_drop(), initialize_worker_spi(), InitPostgres(), movedb(), ProcessCatchupEvent(), ProcessCompletedNotifies(), ProcessIncomingNotify(), ReindexDatabase(), RemoveTempRelationsCallback(), vacuum(), vacuum_rel(), and worker_spi_main().
{ TransactionState s = CurrentTransactionState; switch (s->blockState) { /* * This shouldn't happen, because it means the previous * StartTransactionCommand didn't set the STARTED state * appropriately. */ case TBLOCK_DEFAULT: elog(FATAL, "CommitTransactionCommand: unexpected state %s", BlockStateAsString(s->blockState)); break; /* * If we aren't in a transaction block, just do our usual * transaction commit, and return to the idle state. */ case TBLOCK_STARTED: CommitTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * We are completing a "BEGIN TRANSACTION" command, so we change * to the "transaction block in progress" state and return. (We * assume the BEGIN did nothing to the database, so we need no * CommandCounterIncrement.) */ case TBLOCK_BEGIN: s->blockState = TBLOCK_INPROGRESS; break; /* * This is the case when we have finished executing a command * someplace within a transaction block. We increment the command * counter and return. */ case TBLOCK_INPROGRESS: case TBLOCK_SUBINPROGRESS: CommandCounterIncrement(); break; /* * We are completing a "COMMIT" command. Do it and return to the * idle state. */ case TBLOCK_END: CommitTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * Here we are in the middle of a transaction block but one of the * commands caused an abort so we do nothing but remain in the * abort state. Eventually we will get a ROLLBACK comand. */ case TBLOCK_ABORT: case TBLOCK_SUBABORT: break; /* * Here we were in an aborted transaction block and we just got * the ROLLBACK command from the user, so clean up the * already-aborted transaction and return to the idle state. */ case TBLOCK_ABORT_END: CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * Here we were in a perfectly good transaction block but the user * told us to ROLLBACK anyway. We have to abort the transaction * and then clean up. */ case TBLOCK_ABORT_PENDING: AbortTransaction(); CleanupTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * We are completing a "PREPARE TRANSACTION" command. Do it and * return to the idle state. */ case TBLOCK_PREPARE: PrepareTransaction(); s->blockState = TBLOCK_DEFAULT; break; /* * We were just issued a SAVEPOINT inside a transaction block. * Start a subtransaction. (DefineSavepoint already did * PushTransaction, so as to have someplace to put the SUBBEGIN * state.) */ case TBLOCK_SUBBEGIN: StartSubTransaction(); s->blockState = TBLOCK_SUBINPROGRESS; break; /* * We were issued a RELEASE command, so we end the current * subtransaction and return to the parent transaction. The parent * might be ended too, so repeat till we find an INPROGRESS * transaction or subtransaction. */ case TBLOCK_SUBRELEASE: do { CommitSubTransaction(); s = CurrentTransactionState; /* changed by pop */ } while (s->blockState == TBLOCK_SUBRELEASE); Assert(s->blockState == TBLOCK_INPROGRESS || s->blockState == TBLOCK_SUBINPROGRESS); break; /* * We were issued a COMMIT, so we end the current subtransaction * hierarchy and perform final commit. We do this by rolling up * any subtransactions into their parent, which leads to O(N^2) * operations with respect to resource owners - this isn't that * bad until we approach a thousands of savepoints but is * necessary for correctness should after triggers create new * resource owners. */ case TBLOCK_SUBCOMMIT: do { CommitSubTransaction(); s = CurrentTransactionState; /* changed by pop */ } while (s->blockState == TBLOCK_SUBCOMMIT); /* If we had a COMMIT command, finish off the main xact too */ if (s->blockState == TBLOCK_END) { Assert(s->parent == NULL); CommitTransaction(); s->blockState = TBLOCK_DEFAULT; } else if (s->blockState == TBLOCK_PREPARE) { Assert(s->parent == NULL); PrepareTransaction(); s->blockState = TBLOCK_DEFAULT; } else elog(ERROR, "CommitTransactionCommand: unexpected state %s", BlockStateAsString(s->blockState)); break; /* * The current already-failed subtransaction is ending due to a * ROLLBACK or ROLLBACK TO command, so pop it and recursively * examine the parent (which could be in any of several states). */ case TBLOCK_SUBABORT_END: CleanupSubTransaction(); CommitTransactionCommand(); break; /* * As above, but it's not dead yet, so abort first. */ case TBLOCK_SUBABORT_PENDING: AbortSubTransaction(); CleanupSubTransaction(); CommitTransactionCommand(); break; /* * The current subtransaction is the target of a ROLLBACK TO * command. Abort and pop it, then start a new subtransaction * with the same name. */ case TBLOCK_SUBRESTART: { char *name; int savepointLevel; /* save name and keep Cleanup from freeing it */ name = s->name; s->name = NULL; savepointLevel = s->savepointLevel; AbortSubTransaction(); CleanupSubTransaction(); DefineSavepoint(NULL); s = CurrentTransactionState; /* changed by push */ s->name = name; s->savepointLevel = savepointLevel; /* This is the same as TBLOCK_SUBBEGIN case */ AssertState(s->blockState == TBLOCK_SUBBEGIN); StartSubTransaction(); s->blockState = TBLOCK_SUBINPROGRESS; } break; /* * Same as above, but the subtransaction had already failed, so we * don't need AbortSubTransaction. */ case TBLOCK_SUBABORT_RESTART: { char *name; int savepointLevel; /* save name and keep Cleanup from freeing it */ name = s->name; s->name = NULL; savepointLevel = s->savepointLevel; CleanupSubTransaction(); DefineSavepoint(NULL); s = CurrentTransactionState; /* changed by push */ s->name = name; s->savepointLevel = savepointLevel; /* This is the same as TBLOCK_SUBBEGIN case */ AssertState(s->blockState == TBLOCK_SUBBEGIN); StartSubTransaction(); s->blockState = TBLOCK_SUBINPROGRESS; } break; } }
void DefineSavepoint | ( | char * | name | ) |
Definition at line 3464 of file xact.c.
References TransactionStateData::blockState, BlockStateAsString(), elog, FATAL, MemoryContextStrdup(), TransactionStateData::name, PushTransaction(), TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, TBLOCK_SUBRESTART, and TopTransactionContext.
Referenced by CommitTransactionCommand(), and standard_ProcessUtility().
{ TransactionState s = CurrentTransactionState; switch (s->blockState) { case TBLOCK_INPROGRESS: case TBLOCK_SUBINPROGRESS: /* Normal subtransaction start */ PushTransaction(); s = CurrentTransactionState; /* changed by push */ /* * Savepoint names, like the TransactionState block itself, live * in TopTransactionContext. */ if (name) s->name = MemoryContextStrdup(TopTransactionContext, name); break; /* These cases are invalid. */ case TBLOCK_DEFAULT: case TBLOCK_STARTED: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_ABORT: case TBLOCK_SUBABORT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: elog(FATAL, "DefineSavepoint: unexpected state %s", BlockStateAsString(s->blockState)); break; } }
bool EndTransactionBlock | ( | void | ) |
Definition at line 3261 of file xact.c.
References TransactionStateData::blockState, BlockStateAsString(), elog, ereport, errcode(), errmsg(), FATAL, NULL, TransactionStateData::parent, TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, TBLOCK_SUBRESTART, and WARNING.
Referenced by PrepareTransactionBlock(), and standard_ProcessUtility().
{ TransactionState s = CurrentTransactionState; bool result = false; switch (s->blockState) { /* * We are in a transaction block, so tell CommitTransactionCommand * to COMMIT. */ case TBLOCK_INPROGRESS: s->blockState = TBLOCK_END; result = true; break; /* * We are in a failed transaction block. Tell * CommitTransactionCommand it's time to exit the block. */ case TBLOCK_ABORT: s->blockState = TBLOCK_ABORT_END; break; /* * We are in a live subtransaction block. Set up to subcommit all * open subtransactions and then commit the main transaction. */ case TBLOCK_SUBINPROGRESS: while (s->parent != NULL) { if (s->blockState == TBLOCK_SUBINPROGRESS) s->blockState = TBLOCK_SUBCOMMIT; else elog(FATAL, "EndTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); s = s->parent; } if (s->blockState == TBLOCK_INPROGRESS) s->blockState = TBLOCK_END; else elog(FATAL, "EndTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); result = true; break; /* * Here we are inside an aborted subtransaction. Treat the COMMIT * as ROLLBACK: set up to abort everything and exit the main * transaction. */ case TBLOCK_SUBABORT: while (s->parent != NULL) { if (s->blockState == TBLOCK_SUBINPROGRESS) s->blockState = TBLOCK_SUBABORT_PENDING; else if (s->blockState == TBLOCK_SUBABORT) s->blockState = TBLOCK_SUBABORT_END; else elog(FATAL, "EndTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); s = s->parent; } if (s->blockState == TBLOCK_INPROGRESS) s->blockState = TBLOCK_ABORT_PENDING; else if (s->blockState == TBLOCK_ABORT) s->blockState = TBLOCK_ABORT_END; else elog(FATAL, "EndTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); break; /* * The user issued COMMIT when not inside a transaction. Issue a * WARNING, staying in TBLOCK_STARTED state. The upcoming call to * CommitTransactionCommand() will then close the transaction and * put us back into the default state. */ case TBLOCK_STARTED: ereport(WARNING, (errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION), errmsg("there is no transaction in progress"))); result = true; break; /* These cases are invalid. */ case TBLOCK_DEFAULT: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: elog(FATAL, "EndTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); break; } return result; }
void ForceSyncCommit | ( | void | ) |
Definition at line 798 of file xact.c.
References forceSyncCommit.
Referenced by createdb(), CreateTableSpace(), dropdb(), DropTableSpace(), and movedb().
{ forceSyncCommit = true; }
Definition at line 604 of file xact.c.
References currentCommandId, and currentCommandIdUsed.
Referenced by ATRewriteTable(), CopyFrom(), GetSnapshotData(), HeapTupleSatisfiesNow(), intorel_startup(), pgrowlocks(), RegisterRelcacheInvalidation(), simple_heap_delete(), simple_heap_insert(), simple_heap_update(), standard_ExecutorStart(), toast_save_datum(), transientrel_startup(), and UpdateActiveSnapshotCommandId().
{ /* this is global to a transaction, not subtransaction-local */ if (used) currentCommandIdUsed = true; return currentCommandId; }
TimestampTz GetCurrentStatementStartTimestamp | ( | void | ) |
Definition at line 625 of file xact.c.
References stmtStartTimestamp.
Referenced by check_log_duration(), CreatePortal(), pgstat_report_activity(), statement_timestamp(), and StorePreparedStatement().
{ return stmtStartTimestamp; }
SubTransactionId GetCurrentSubTransactionId | ( | void | ) |
Definition at line 566 of file xact.c.
References TransactionStateData::subTransactionId.
Referenced by AllocateDir(), AllocateFile(), CopyFrom(), CreatePortal(), ExecuteTruncate(), init_sql_fcache(), InitTempTableNamespace(), inv_open(), OpenPipeStream(), OpenTransientFile(), plpgsql_create_econtext(), register_on_commit_action(), RelationBuildLocalRelation(), RelationSetNewRelfilenode(), remove_on_commit_action(), sepgsql_set_client_label(), and SPI_connect().
{ TransactionState s = CurrentTransactionState; return s->subTransactionId; }
TransactionId GetCurrentTransactionId | ( | void | ) |
Definition at line 371 of file xact.c.
References AssignTransactionId(), TransactionStateData::transactionId, and TransactionIdIsValid.
Referenced by AlterEnum(), asyncQueueNotificationToEntry(), funny_dup17(), heap_delete(), heap_insert(), heap_lock_tuple(), heap_multi_insert(), heap_update(), PreCommit_Notify(), PrepareTransaction(), and vac_truncate_clog().
{ TransactionState s = CurrentTransactionState; if (!TransactionIdIsValid(s->transactionId)) AssignTransactionId(s); return s->transactionId; }
TransactionId GetCurrentTransactionIdIfAny | ( | void | ) |
Definition at line 388 of file xact.c.
References TransactionStateData::transactionId.
Referenced by pgrowlocks(), RecordTransactionAbort(), and XLogInsert().
{ return CurrentTransactionState->transactionId; }
int GetCurrentTransactionNestLevel | ( | void | ) |
Definition at line 669 of file xact.c.
References TransactionStateData::nestingLevel.
Referenced by AfterTriggerBeginSubXact(), AfterTriggerEndSubXact(), AfterTriggerSetState(), AtEOSubXact_Inval(), AtEOSubXact_Namespace(), AtStart_Inval(), AtSubAbort_Notify(), AtSubCommit_Notify(), AtSubCommit_smgr(), AtSubStart_Inval(), AtSubStart_Notify(), begin_remote_xact(), pgfdw_subxact_callback(), pgstat_count_heap_delete(), pgstat_count_heap_insert(), pgstat_count_heap_update(), PopOverrideSearchPath(), PushActiveSnapshot(), PushOverrideSearchPath(), register_seq_scan(), RelationCreateStorage(), RelationDropStorage(), RelationMapUpdateMap(), smgrDoPendingDeletes(), and smgrGetPendingDeletes().
{ TransactionState s = CurrentTransactionState; return s->nestingLevel; }
TimestampTz GetCurrentTransactionStartTimestamp | ( | void | ) |
Definition at line 616 of file xact.c.
References xactStartTimestamp.
Referenced by GetCurrentDateTime(), GetCurrentTimeUsec(), now(), and pg_timezone_names().
{ return xactStartTimestamp; }
TimestampTz GetCurrentTransactionStopTimestamp | ( | void | ) |
Definition at line 637 of file xact.c.
References GetCurrentTimestamp(), and xactStopTimestamp.
Referenced by pgstat_report_stat().
{ if (xactStopTimestamp != 0) return xactStopTimestamp; return GetCurrentTimestamp(); }
TransactionId GetStableLatestTransactionId | ( | void | ) |
Definition at line 402 of file xact.c.
References Assert, GetTopTransactionIdIfAny(), PGPROC::lxid, MyProc, ReadNewTransactionId(), and TransactionIdIsValid.
Referenced by xid_age().
{ static LocalTransactionId lxid = InvalidLocalTransactionId; static TransactionId stablexid = InvalidTransactionId; if (lxid != MyProc->lxid) { lxid = MyProc->lxid; stablexid = GetTopTransactionIdIfAny(); if (!TransactionIdIsValid(stablexid)) stablexid = ReadNewTransactionId(); } Assert(TransactionIdIsValid(stablexid)); return stablexid; }
TransactionId GetTopTransactionId | ( | void | ) |
Definition at line 343 of file xact.c.
References AssignTransactionId(), TransactionStateData::transactionId, and TransactionIdIsValid.
Referenced by AssignTransactionId(), AtEOXact_Snapshot(), ExportSnapshot(), LockGXact(), LogAccessExclusiveLock(), LogAccessExclusiveLockPrepare(), and txid_current().
TransactionId GetTopTransactionIdIfAny | ( | void | ) |
Definition at line 358 of file xact.c.
References TransactionStateData::transactionId.
Referenced by CheckForSerializableConflictOut(), ConditionalXactLockTableWait(), GetSerializableTransactionSnapshotInt(), GetStableLatestTransactionId(), ImportSnapshot(), index_drop(), index_set_state_flags(), initSpGistState(), log_line_prefix(), PredicateLockTuple(), RecordTransactionCommit(), write_csvlog(), XactLockTableWait(), and XidIsConcurrent().
{ return TopTransactionStateData.transactionId; }
bool IsAbortedTransactionBlockState | ( | void | ) |
Definition at line 324 of file xact.c.
References TransactionStateData::blockState, TBLOCK_ABORT, and TBLOCK_SUBABORT.
Referenced by errdetail_params(), exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_execute_message(), exec_parse_message(), exec_simple_query(), HandleFunctionRequest(), PostgresMain(), and RecoveryConflictInterrupt().
{ TransactionState s = CurrentTransactionState; if (s->blockState == TBLOCK_ABORT || s->blockState == TBLOCK_SUBABORT) return true; return false; }
Definition at line 3007 of file xact.c.
References TransactionStateData::blockState, IsSubTransaction(), IsTransactionBlock(), TBLOCK_DEFAULT, and TBLOCK_STARTED.
Referenced by vacuum().
{ /* * Return true on same conditions that would make PreventTransactionChain * error out */ if (IsTransactionBlock()) return true; if (IsSubTransaction()) return true; if (!isTopLevel) return true; if (CurrentTransactionState->blockState != TBLOCK_DEFAULT && CurrentTransactionState->blockState != TBLOCK_STARTED) return true; return false; }
bool IsSubTransaction | ( | void | ) |
Definition at line 4014 of file xact.c.
References TransactionStateData::nestingLevel.
Referenced by AfterTriggerSetState(), check_transaction_deferrable(), check_transaction_read_only(), check_XactIsoLevel(), CheckTargetForConflictsIn(), ExportSnapshot(), ImportSnapshot(), IsInTransactionChain(), PreventTransactionChain(), RecoveryConflictInterrupt(), and RequireTransactionChain().
{ TransactionState s = CurrentTransactionState; if (s->nestingLevel >= 2) return true; return false; }
bool IsTransactionBlock | ( | void | ) |
Definition at line 3943 of file xact.c.
References TransactionStateData::blockState, TBLOCK_DEFAULT, and TBLOCK_STARTED.
Referenced by IsInTransactionChain(), PreventTransactionChain(), and RequireTransactionChain().
{ TransactionState s = CurrentTransactionState; if (s->blockState == TBLOCK_DEFAULT || s->blockState == TBLOCK_STARTED) return false; return true; }
bool IsTransactionOrTransactionBlock | ( | void | ) |
Definition at line 3961 of file xact.c.
References TransactionStateData::blockState, and TBLOCK_DEFAULT.
Referenced by EnableNotifyInterrupt(), PostgresMain(), ProcessCatchupEvent(), and RecoveryConflictInterrupt().
{ TransactionState s = CurrentTransactionState; if (s->blockState == TBLOCK_DEFAULT) return false; return true; }
bool IsTransactionState | ( | void | ) |
Definition at line 304 of file xact.c.
References TransactionStateData::state, and TRANS_INPROGRESS.
Referenced by check_client_encoding(), check_default_tablespace(), check_role(), check_session_authorization(), check_temp_tablespaces(), check_transaction_read_only(), check_TSCurrentConfig(), check_XactIsoLevel(), HandleFunctionRequest(), pg_do_encoding_conversion(), PrepareClientEncoding(), PrepareTempTablespaces(), SetMultiXactIdLimit(), SetTransactionIdLimit(), and SocketBackend().
{ TransactionState s = CurrentTransactionState; /* * TRANS_DEFAULT and TRANS_ABORT are obviously unsafe states. However, we * also reject the startup/shutdown states TRANS_START, TRANS_COMMIT, * TRANS_PREPARE since it might be too soon or too late within those * transition states to do anything interesting. Hence, the only "valid" * state is TRANS_INPROGRESS. */ return (s->state == TRANS_INPROGRESS); }
bool PrepareTransactionBlock | ( | char * | gid | ) |
Definition at line 3210 of file xact.c.
References Assert, TransactionStateData::blockState, EndTransactionBlock(), MemoryContextStrdup(), NULL, TransactionStateData::parent, prepareGID, TBLOCK_END, TBLOCK_STARTED, and TopTransactionContext.
Referenced by standard_ProcessUtility().
{ TransactionState s; bool result; /* Set up to commit the current transaction */ result = EndTransactionBlock(); /* If successful, change outer tblock state to PREPARE */ if (result) { s = CurrentTransactionState; while (s->parent != NULL) s = s->parent; if (s->blockState == TBLOCK_END) { /* Save GID where PrepareTransaction can find it again */ prepareGID = MemoryContextStrdup(TopTransactionContext, gid); s->blockState = TBLOCK_PREPARE; } else { /* * ignore case where we are not in a transaction; * EndTransactionBlock already issued a warning. */ Assert(s->blockState == TBLOCK_STARTED); /* Don't send back a PREPARE result tag... */ result = false; } } return result; }
void PreventTransactionChain | ( | bool | isTopLevel, | |
const char * | stmtType | |||
) |
Definition at line 2912 of file xact.c.
References TransactionStateData::blockState, elog, ereport, errcode(), errmsg(), ERROR, FATAL, IsSubTransaction(), IsTransactionBlock(), TBLOCK_DEFAULT, and TBLOCK_STARTED.
Referenced by AlterDatabase(), AlterEnum(), cluster(), DiscardAll(), ExecDropStmt(), ProcessUtilitySlow(), standard_ProcessUtility(), and vacuum().
{ /* * xact block already started? */ if (IsTransactionBlock()) ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), /* translator: %s represents an SQL statement name */ errmsg("%s cannot run inside a transaction block", stmtType))); /* * subtransaction? */ if (IsSubTransaction()) ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), /* translator: %s represents an SQL statement name */ errmsg("%s cannot run inside a subtransaction", stmtType))); /* * inside a function call? */ if (!isTopLevel) ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), /* translator: %s represents an SQL statement name */ errmsg("%s cannot be executed from a function or multi-command string", stmtType))); /* If we got past IsTransactionBlock test, should be in default state */ if (CurrentTransactionState->blockState != TBLOCK_DEFAULT && CurrentTransactionState->blockState != TBLOCK_STARTED) elog(FATAL, "cannot prevent transaction chain"); /* all okay */ }
void RegisterSubXactCallback | ( | SubXactCallback | callback, | |
void * | arg | |||
) |
Definition at line 3097 of file xact.c.
References SubXactCallbackItem::arg, SubXactCallbackItem::callback, MemoryContextAlloc(), SubXactCallbackItem::next, and TopMemoryContext.
Referenced by _PG_init(), GetConnection(), and sepgsql_init_client_label().
{ SubXactCallbackItem *item; item = (SubXactCallbackItem *) MemoryContextAlloc(TopMemoryContext, sizeof(SubXactCallbackItem)); item->callback = callback; item->arg = arg; item->next = SubXact_callbacks; SubXact_callbacks = item; }
void RegisterXactCallback | ( | XactCallback | callback, | |
void * | arg | |||
) |
Definition at line 3042 of file xact.c.
References XactCallbackItem::arg, XactCallbackItem::callback, MemoryContextAlloc(), XactCallbackItem::next, and TopMemoryContext.
Referenced by _PG_init(), GetConnection(), and sepgsql_init_client_label().
{ XactCallbackItem *item; item = (XactCallbackItem *) MemoryContextAlloc(TopMemoryContext, sizeof(XactCallbackItem)); item->callback = callback; item->arg = arg; item->next = Xact_callbacks; Xact_callbacks = item; }
void ReleaseCurrentSubTransaction | ( | void | ) |
Definition at line 3784 of file xact.c.
References Assert, TransactionStateData::blockState, BlockStateAsString(), CommitSubTransaction(), CurTransactionContext, elog, ERROR, MemoryContextSwitchTo(), TransactionStateData::state, TBLOCK_SUBINPROGRESS, and TRANS_INPROGRESS.
Referenced by exec_stmt_block(), plperl_spi_exec(), plperl_spi_exec_prepared(), plperl_spi_fetchrow(), plperl_spi_prepare(), plperl_spi_query(), plperl_spi_query_prepared(), pltcl_subtrans_commit(), PLy_spi_subtransaction_commit(), and PLy_subtransaction_exit().
{ TransactionState s = CurrentTransactionState; if (s->blockState != TBLOCK_SUBINPROGRESS) elog(ERROR, "ReleaseCurrentSubTransaction: unexpected state %s", BlockStateAsString(s->blockState)); Assert(s->state == TRANS_INPROGRESS); MemoryContextSwitchTo(CurTransactionContext); CommitSubTransaction(); s = CurrentTransactionState; /* changed by pop */ Assert(s->state == TRANS_INPROGRESS); }
void ReleaseSavepoint | ( | List * | options | ) |
Definition at line 3514 of file xact.c.
References DefElem::arg, Assert, TransactionStateData::blockState, BlockStateAsString(), DefElem::defname, elog, ereport, errcode(), errmsg(), ERROR, FATAL, lfirst, TransactionStateData::name, name, TransactionStateData::parent, PointerIsValid, TransactionStateData::savepointLevel, strVal, TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, and TBLOCK_SUBRESTART.
Referenced by standard_ProcessUtility().
{ TransactionState s = CurrentTransactionState; TransactionState target, xact; ListCell *cell; char *name = NULL; switch (s->blockState) { /* * We can't rollback to a savepoint if there is no savepoint * defined. */ case TBLOCK_INPROGRESS: ereport(ERROR, (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), errmsg("no such savepoint"))); break; /* * We are in a non-aborted subtransaction. This is the only valid * case. */ case TBLOCK_SUBINPROGRESS: break; /* These cases are invalid. */ case TBLOCK_DEFAULT: case TBLOCK_STARTED: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_ABORT: case TBLOCK_SUBABORT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: elog(FATAL, "ReleaseSavepoint: unexpected state %s", BlockStateAsString(s->blockState)); break; } foreach(cell, options) { DefElem *elem = lfirst(cell); if (strcmp(elem->defname, "savepoint_name") == 0) name = strVal(elem->arg); } Assert(PointerIsValid(name)); for (target = s; PointerIsValid(target); target = target->parent) { if (PointerIsValid(target->name) && strcmp(target->name, name) == 0) break; } if (!PointerIsValid(target)) ereport(ERROR, (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), errmsg("no such savepoint"))); /* disallow crossing savepoint level boundaries */ if (target->savepointLevel != s->savepointLevel) ereport(ERROR, (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), errmsg("no such savepoint"))); /* * Mark "commit pending" all subtransactions up to the target * subtransaction. The actual commits will happen when control gets to * CommitTransactionCommand. */ xact = CurrentTransactionState; for (;;) { Assert(xact->blockState == TBLOCK_SUBINPROGRESS); xact->blockState = TBLOCK_SUBRELEASE; if (xact == target) break; xact = xact->parent; Assert(PointerIsValid(xact)); } }
void RequireTransactionChain | ( | bool | isTopLevel, | |
const char * | stmtType | |||
) |
Definition at line 2969 of file xact.c.
References ereport, errcode(), errmsg(), ERROR, IsSubTransaction(), and IsTransactionBlock().
Referenced by PerformCursorOpen(), and standard_ProcessUtility().
{ /* * xact block already started? */ if (IsTransactionBlock()) return; /* * subtransaction? */ if (IsSubTransaction()) return; /* * inside a function call? */ if (!isTopLevel) return; ereport(ERROR, (errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION), /* translator: %s represents an SQL statement name */ errmsg("%s can only be used in transaction blocks", stmtType))); }
void RollbackAndReleaseCurrentSubTransaction | ( | void | ) |
Definition at line 3806 of file xact.c.
References AbortSubTransaction(), AssertState, TransactionStateData::blockState, BlockStateAsString(), CleanupSubTransaction(), elog, FATAL, TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, and TBLOCK_SUBRESTART.
Referenced by exec_stmt_block(), plperl_spi_exec(), plperl_spi_exec_prepared(), plperl_spi_fetchrow(), plperl_spi_prepare(), plperl_spi_query(), plperl_spi_query_prepared(), pltcl_subtrans_abort(), PLy_abort_open_subtransactions(), PLy_spi_subtransaction_abort(), and PLy_subtransaction_exit().
{ TransactionState s = CurrentTransactionState; switch (s->blockState) { /* Must be in a subtransaction */ case TBLOCK_SUBINPROGRESS: case TBLOCK_SUBABORT: break; /* These cases are invalid. */ case TBLOCK_DEFAULT: case TBLOCK_STARTED: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_INPROGRESS: case TBLOCK_END: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_ABORT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: elog(FATAL, "RollbackAndReleaseCurrentSubTransaction: unexpected state %s", BlockStateAsString(s->blockState)); break; } /* * Abort the current subtransaction, if needed. */ if (s->blockState == TBLOCK_SUBINPROGRESS) AbortSubTransaction(); /* And clean it up, too */ CleanupSubTransaction(); s = CurrentTransactionState; /* changed by pop */ AssertState(s->blockState == TBLOCK_SUBINPROGRESS || s->blockState == TBLOCK_INPROGRESS || s->blockState == TBLOCK_STARTED); }
void RollbackToSavepoint | ( | List * | options | ) |
Definition at line 3614 of file xact.c.
References DefElem::arg, Assert, TransactionStateData::blockState, BlockStateAsString(), DefElem::defname, elog, ereport, errcode(), errmsg(), ERROR, FATAL, lfirst, TransactionStateData::name, name, TransactionStateData::parent, PointerIsValid, TransactionStateData::savepointLevel, strVal, TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, and TBLOCK_SUBRESTART.
Referenced by standard_ProcessUtility().
{ TransactionState s = CurrentTransactionState; TransactionState target, xact; ListCell *cell; char *name = NULL; switch (s->blockState) { /* * We can't rollback to a savepoint if there is no savepoint * defined. */ case TBLOCK_INPROGRESS: case TBLOCK_ABORT: ereport(ERROR, (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), errmsg("no such savepoint"))); break; /* * There is at least one savepoint, so proceed. */ case TBLOCK_SUBINPROGRESS: case TBLOCK_SUBABORT: break; /* These cases are invalid. */ case TBLOCK_DEFAULT: case TBLOCK_STARTED: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: elog(FATAL, "RollbackToSavepoint: unexpected state %s", BlockStateAsString(s->blockState)); break; } foreach(cell, options) { DefElem *elem = lfirst(cell); if (strcmp(elem->defname, "savepoint_name") == 0) name = strVal(elem->arg); } Assert(PointerIsValid(name)); for (target = s; PointerIsValid(target); target = target->parent) { if (PointerIsValid(target->name) && strcmp(target->name, name) == 0) break; } if (!PointerIsValid(target)) ereport(ERROR, (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), errmsg("no such savepoint"))); /* disallow crossing savepoint level boundaries */ if (target->savepointLevel != s->savepointLevel) ereport(ERROR, (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), errmsg("no such savepoint"))); /* * Mark "abort pending" all subtransactions up to the target * subtransaction. The actual aborts will happen when control gets to * CommitTransactionCommand. */ xact = CurrentTransactionState; for (;;) { if (xact == target) break; if (xact->blockState == TBLOCK_SUBINPROGRESS) xact->blockState = TBLOCK_SUBABORT_PENDING; else if (xact->blockState == TBLOCK_SUBABORT) xact->blockState = TBLOCK_SUBABORT_END; else elog(FATAL, "RollbackToSavepoint: unexpected state %s", BlockStateAsString(xact->blockState)); xact = xact->parent; Assert(PointerIsValid(xact)); } /* And mark the target as "restart pending" */ if (xact->blockState == TBLOCK_SUBINPROGRESS) xact->blockState = TBLOCK_SUBRESTART; else if (xact->blockState == TBLOCK_SUBABORT) xact->blockState = TBLOCK_SUBABORT_RESTART; else elog(FATAL, "RollbackToSavepoint: unexpected state %s", BlockStateAsString(xact->blockState)); }
void SetCurrentStatementStartTimestamp | ( | void | ) |
Definition at line 648 of file xact.c.
References GetCurrentTimestamp(), and stmtStartTimestamp.
Referenced by autovac_report_activity(), initialize_worker_spi(), InitPostgres(), PostgresMain(), and worker_spi_main().
{ stmtStartTimestamp = GetCurrentTimestamp(); }
void StartTransactionCommand | ( | void | ) |
Definition at line 2439 of file xact.c.
References Assert, TransactionStateData::blockState, BlockStateAsString(), CurTransactionContext, elog, ERROR, MemoryContextSwitchTo(), NULL, StartTransaction(), TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, and TBLOCK_SUBRESTART.
Referenced by BeginInternalSubTransaction(), cluster(), DefineIndex(), do_autovacuum(), get_database_list(), index_drop(), initialize_worker_spi(), InitPostgres(), movedb(), ProcessCatchupEvent(), ProcessCompletedNotifies(), ProcessIncomingNotify(), ReindexDatabase(), RemoveTempRelationsCallback(), start_xact_command(), vacuum(), vacuum_rel(), and worker_spi_main().
{ TransactionState s = CurrentTransactionState; switch (s->blockState) { /* * if we aren't in a transaction block, we just do our usual start * transaction. */ case TBLOCK_DEFAULT: StartTransaction(); s->blockState = TBLOCK_STARTED; break; /* * We are somewhere in a transaction block or subtransaction and * about to start a new command. For now we do nothing, but * someday we may do command-local resource initialization. (Note * that any needed CommandCounterIncrement was done by the * previous CommitTransactionCommand.) */ case TBLOCK_INPROGRESS: case TBLOCK_SUBINPROGRESS: break; /* * Here we are in a failed transaction block (one of the commands * caused an abort) so we do nothing but remain in the abort * state. Eventually we will get a ROLLBACK command which will * get us out of this state. (It is up to other code to ensure * that no commands other than ROLLBACK will be processed in these * states.) */ case TBLOCK_ABORT: case TBLOCK_SUBABORT: break; /* These cases are invalid. */ case TBLOCK_STARTED: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: elog(ERROR, "StartTransactionCommand: unexpected state %s", BlockStateAsString(s->blockState)); break; } /* * We must switch to CurTransactionContext before returning. This is * already done if we called StartTransaction, otherwise not. */ Assert(CurTransactionContext != NULL); MemoryContextSwitchTo(CurTransactionContext); }
bool SubTransactionIsActive | ( | SubTransactionId | subxid | ) |
Definition at line 580 of file xact.c.
References TransactionStateData::parent, TransactionStateData::state, TransactionStateData::subTransactionId, and TRANS_ABORT.
Referenced by fmgr_sql().
{ TransactionState s; for (s = CurrentTransactionState; s != NULL; s = s->parent) { if (s->state == TRANS_ABORT) continue; if (s->subTransactionId == subxid) return true; } return false; }
char TransactionBlockStatusCode | ( | void | ) |
Definition at line 3975 of file xact.c.
References TransactionStateData::blockState, BlockStateAsString(), elog, FATAL, TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, and TBLOCK_SUBRESTART.
Referenced by ReadyForQuery().
{ TransactionState s = CurrentTransactionState; switch (s->blockState) { case TBLOCK_DEFAULT: case TBLOCK_STARTED: return 'I'; /* idle --- not in transaction */ case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_INPROGRESS: case TBLOCK_SUBINPROGRESS: case TBLOCK_END: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_PREPARE: return 'T'; /* in transaction */ case TBLOCK_ABORT: case TBLOCK_SUBABORT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: return 'E'; /* in failed transaction */ } /* should never get here */ elog(FATAL, "invalid transaction block state: %s", BlockStateAsString(s->blockState)); return 0; /* keep compiler quiet */ }
bool TransactionIdIsCurrentTransactionId | ( | TransactionId | xid | ) |
Definition at line 681 of file xact.c.
References TransactionStateData::childXids, TransactionStateData::nChildXids, TransactionStateData::parent, TransactionStateData::state, TRANS_ABORT, TransactionStateData::transactionId, TransactionIdEquals, TransactionIdIsNormal, TransactionIdIsValid, and TransactionIdPrecedes().
Referenced by acquire_sample_rows(), copy_heap_data(), Do_MultiXactIdWait(), EvalPlanQualFetch(), funny_dup17(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), HeapTupleHeaderAdjustCmax(), HeapTupleHeaderGetCmax(), HeapTupleHeaderGetCmin(), HeapTupleHeaderIsOnlyLocked(), HeapTupleSatisfiesDirty(), HeapTupleSatisfiesMVCC(), HeapTupleSatisfiesNow(), HeapTupleSatisfiesSelf(), HeapTupleSatisfiesToast(), HeapTupleSatisfiesUpdate(), HeapTupleSatisfiesVacuum(), IndexBuildHeapScan(), MultiXactIdIsRunning(), RI_FKey_fk_upd_check_required(), and TransactionIdIsInProgress().
{ TransactionState s; /* * We always say that BootstrapTransactionId is "not my transaction ID" * even when it is (ie, during bootstrap). Along with the fact that * transam.c always treats BootstrapTransactionId as already committed, * this causes the tqual.c routines to see all tuples as committed, which * is what we need during bootstrap. (Bootstrap mode only inserts tuples, * it never updates or deletes them, so all tuples can be presumed good * immediately.) * * Likewise, InvalidTransactionId and FrozenTransactionId are certainly * not my transaction ID, so we can just return "false" immediately for * any non-normal XID. */ if (!TransactionIdIsNormal(xid)) return false; /* * We will return true for the Xid of the current subtransaction, any of * its subcommitted children, any of its parents, or any of their * previously subcommitted children. However, a transaction being aborted * is no longer "current", even though it may still have an entry on the * state stack. */ for (s = CurrentTransactionState; s != NULL; s = s->parent) { int low, high; if (s->state == TRANS_ABORT) continue; if (!TransactionIdIsValid(s->transactionId)) continue; /* it can't have any child XIDs either */ if (TransactionIdEquals(xid, s->transactionId)) return true; /* As the childXids array is ordered, we can use binary search */ low = 0; high = s->nChildXids - 1; while (low <= high) { int middle; TransactionId probe; middle = low + (high - low) / 2; probe = s->childXids[middle]; if (TransactionIdEquals(probe, xid)) return true; else if (TransactionIdPrecedes(probe, xid)) low = middle + 1; else high = middle - 1; } } return false; }
void UnregisterSubXactCallback | ( | SubXactCallback | callback, | |
void * | arg | |||
) |
Definition at line 3110 of file xact.c.
References SubXactCallbackItem::next, and pfree().
{ SubXactCallbackItem *item; SubXactCallbackItem *prev; prev = NULL; for (item = SubXact_callbacks; item; prev = item, item = item->next) { if (item->callback == callback && item->arg == arg) { if (prev) prev->next = item->next; else SubXact_callbacks = item->next; pfree(item); break; } } }
void UnregisterXactCallback | ( | XactCallback | callback, | |
void * | arg | |||
) |
Definition at line 3055 of file xact.c.
References XactCallbackItem::next, and pfree().
{ XactCallbackItem *item; XactCallbackItem *prev; prev = NULL; for (item = Xact_callbacks; item; prev = item, item = item->next) { if (item->callback == callback && item->arg == arg) { if (prev) prev->next = item->next; else Xact_callbacks = item->next; pfree(item); break; } } }
void UserAbortTransactionBlock | ( | void | ) |
Definition at line 3375 of file xact.c.
References TransactionStateData::blockState, BlockStateAsString(), elog, ereport, errcode(), errmsg(), FATAL, NOTICE, NULL, TransactionStateData::parent, TBLOCK_ABORT, TBLOCK_ABORT_END, TBLOCK_ABORT_PENDING, TBLOCK_BEGIN, TBLOCK_DEFAULT, TBLOCK_END, TBLOCK_INPROGRESS, TBLOCK_PREPARE, TBLOCK_STARTED, TBLOCK_SUBABORT, TBLOCK_SUBABORT_END, TBLOCK_SUBABORT_PENDING, TBLOCK_SUBABORT_RESTART, TBLOCK_SUBBEGIN, TBLOCK_SUBCOMMIT, TBLOCK_SUBINPROGRESS, TBLOCK_SUBRELEASE, and TBLOCK_SUBRESTART.
Referenced by standard_ProcessUtility().
{ TransactionState s = CurrentTransactionState; switch (s->blockState) { /* * We are inside a transaction block and we got a ROLLBACK command * from the user, so tell CommitTransactionCommand to abort and * exit the transaction block. */ case TBLOCK_INPROGRESS: s->blockState = TBLOCK_ABORT_PENDING; break; /* * We are inside a failed transaction block and we got a ROLLBACK * command from the user. Abort processing is already done, so * CommitTransactionCommand just has to cleanup and go back to * idle state. */ case TBLOCK_ABORT: s->blockState = TBLOCK_ABORT_END; break; /* * We are inside a subtransaction. Mark everything up to top * level as exitable. */ case TBLOCK_SUBINPROGRESS: case TBLOCK_SUBABORT: while (s->parent != NULL) { if (s->blockState == TBLOCK_SUBINPROGRESS) s->blockState = TBLOCK_SUBABORT_PENDING; else if (s->blockState == TBLOCK_SUBABORT) s->blockState = TBLOCK_SUBABORT_END; else elog(FATAL, "UserAbortTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); s = s->parent; } if (s->blockState == TBLOCK_INPROGRESS) s->blockState = TBLOCK_ABORT_PENDING; else if (s->blockState == TBLOCK_ABORT) s->blockState = TBLOCK_ABORT_END; else elog(FATAL, "UserAbortTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); break; /* * The user issued ABORT when not inside a transaction. Issue a * NOTICE and go to abort state. The upcoming call to * CommitTransactionCommand() will then put us back into the * default state. */ case TBLOCK_STARTED: ereport(NOTICE, (errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION), errmsg("there is no transaction in progress"))); s->blockState = TBLOCK_ABORT_PENDING; break; /* These cases are invalid. */ case TBLOCK_DEFAULT: case TBLOCK_BEGIN: case TBLOCK_SUBBEGIN: case TBLOCK_END: case TBLOCK_SUBRELEASE: case TBLOCK_SUBCOMMIT: case TBLOCK_ABORT_END: case TBLOCK_SUBABORT_END: case TBLOCK_ABORT_PENDING: case TBLOCK_SUBABORT_PENDING: case TBLOCK_SUBRESTART: case TBLOCK_SUBABORT_RESTART: case TBLOCK_PREPARE: elog(FATAL, "UserAbortTransactionBlock: unexpected state %s", BlockStateAsString(s->blockState)); break; } }
void xact_desc | ( | StringInfo | buf, | |
uint8 | xl_info, | |||
char * | rec | |||
) |
Definition at line 138 of file xactdesc.c.
References appendStringInfo(), xl_xact_abort_prepared::arec, xl_xact_commit_prepared::crec, xact_desc_abort(), xact_desc_assignment(), xact_desc_commit(), xact_desc_commit_compact(), xl_xact_abort_prepared::xid, xl_xact_commit_prepared::xid, XLOG_XACT_ABORT, XLOG_XACT_ABORT_PREPARED, XLOG_XACT_ASSIGNMENT, XLOG_XACT_COMMIT, XLOG_XACT_COMMIT_COMPACT, XLOG_XACT_COMMIT_PREPARED, XLOG_XACT_PREPARE, and xl_xact_assignment::xtop.
{ uint8 info = xl_info & ~XLR_INFO_MASK; if (info == XLOG_XACT_COMMIT_COMPACT) { xl_xact_commit_compact *xlrec = (xl_xact_commit_compact *) rec; appendStringInfo(buf, "commit: "); xact_desc_commit_compact(buf, xlrec); } else if (info == XLOG_XACT_COMMIT) { xl_xact_commit *xlrec = (xl_xact_commit *) rec; appendStringInfo(buf, "commit: "); xact_desc_commit(buf, xlrec); } else if (info == XLOG_XACT_ABORT) { xl_xact_abort *xlrec = (xl_xact_abort *) rec; appendStringInfo(buf, "abort: "); xact_desc_abort(buf, xlrec); } else if (info == XLOG_XACT_PREPARE) { appendStringInfo(buf, "prepare"); } else if (info == XLOG_XACT_COMMIT_PREPARED) { xl_xact_commit_prepared *xlrec = (xl_xact_commit_prepared *) rec; appendStringInfo(buf, "commit prepared %u: ", xlrec->xid); xact_desc_commit(buf, &xlrec->crec); } else if (info == XLOG_XACT_ABORT_PREPARED) { xl_xact_abort_prepared *xlrec = (xl_xact_abort_prepared *) rec; appendStringInfo(buf, "abort prepared %u: ", xlrec->xid); xact_desc_abort(buf, &xlrec->arec); } else if (info == XLOG_XACT_ASSIGNMENT) { xl_xact_assignment *xlrec = (xl_xact_assignment *) rec; /* * Note that we ignore the WAL record's xid, since we're more * interested in the top-level xid that issued the record and which * xids are being reported here. */ appendStringInfo(buf, "xid assignment xtop %u: ", xlrec->xtop); xact_desc_assignment(buf, xlrec); } else appendStringInfo(buf, "UNKNOWN"); }
void xact_redo | ( | XLogRecPtr | lsn, | |
XLogRecord * | record | |||
) |
Definition at line 4822 of file xact.c.
References xl_xact_abort_prepared::arec, Assert, xl_xact_commit_prepared::crec, elog, xl_xact_assignment::nsubxacts, PANIC, ProcArrayApplyXidAssignment(), RecreateTwoPhaseFile(), RemoveTwoPhaseFile(), STANDBY_INITIALIZED, standbyState, xact_redo_abort(), xact_redo_commit(), xact_redo_commit_compact(), xl_xact_abort_prepared::xid, xl_xact_commit_prepared::xid, XLogRecord::xl_info, XLogRecord::xl_len, XLogRecord::xl_xid, XLOG_XACT_ABORT, XLOG_XACT_ABORT_PREPARED, XLOG_XACT_ASSIGNMENT, XLOG_XACT_COMMIT, XLOG_XACT_COMMIT_COMPACT, XLOG_XACT_COMMIT_PREPARED, XLOG_XACT_PREPARE, XLogRecGetData, XLR_BKP_BLOCK_MASK, xl_xact_assignment::xsub, and xl_xact_assignment::xtop.
{ uint8 info = record->xl_info & ~XLR_INFO_MASK; /* Backup blocks are not used in xact records */ Assert(!(record->xl_info & XLR_BKP_BLOCK_MASK)); if (info == XLOG_XACT_COMMIT_COMPACT) { xl_xact_commit_compact *xlrec = (xl_xact_commit_compact *) XLogRecGetData(record); xact_redo_commit_compact(xlrec, record->xl_xid, lsn); } else if (info == XLOG_XACT_COMMIT) { xl_xact_commit *xlrec = (xl_xact_commit *) XLogRecGetData(record); xact_redo_commit(xlrec, record->xl_xid, lsn); } else if (info == XLOG_XACT_ABORT) { xl_xact_abort *xlrec = (xl_xact_abort *) XLogRecGetData(record); xact_redo_abort(xlrec, record->xl_xid); } else if (info == XLOG_XACT_PREPARE) { /* the record contents are exactly the 2PC file */ RecreateTwoPhaseFile(record->xl_xid, XLogRecGetData(record), record->xl_len); } else if (info == XLOG_XACT_COMMIT_PREPARED) { xl_xact_commit_prepared *xlrec = (xl_xact_commit_prepared *) XLogRecGetData(record); xact_redo_commit(&xlrec->crec, xlrec->xid, lsn); RemoveTwoPhaseFile(xlrec->xid, false); } else if (info == XLOG_XACT_ABORT_PREPARED) { xl_xact_abort_prepared *xlrec = (xl_xact_abort_prepared *) XLogRecGetData(record); xact_redo_abort(&xlrec->arec, xlrec->xid); RemoveTwoPhaseFile(xlrec->xid, false); } else if (info == XLOG_XACT_ASSIGNMENT) { xl_xact_assignment *xlrec = (xl_xact_assignment *) XLogRecGetData(record); if (standbyState >= STANDBY_INITIALIZED) ProcArrayApplyXidAssignment(xlrec->xtop, xlrec->nsubxacts, xlrec->xsub); } else elog(PANIC, "xact_redo: unknown op code %u", info); }
int xactGetCommittedChildren | ( | TransactionId ** | ptr | ) |
Definition at line 4544 of file xact.c.
References TransactionStateData::childXids, and TransactionStateData::nChildXids.
Referenced by ExportSnapshot(), RecordTransactionAbort(), RecordTransactionCommit(), and StartPrepare().
{ TransactionState s = CurrentTransactionState; if (s->nChildXids == 0) *ptr = NULL; else *ptr = s->childXids; return s->nChildXids; }
Definition at line 68 of file xact.c.
Referenced by StartTransaction().
Definition at line 62 of file xact.c.
Referenced by check_XactIsoLevel(), and StartTransaction().
Definition at line 65 of file xact.c.
Referenced by StartTransaction().
Definition at line 78 of file xact.c.
Referenced by PreCommit_on_commit_actions(), PrepareTransaction(), relation_open(), StartTransaction(), and try_relation_open().
Definition at line 71 of file xact.c.
Referenced by AutoVacWorkerMain(), and RecordTransactionCommit().
Definition at line 69 of file xact.c.
Referenced by GetSafeSnapshot(), GetSerializableTransactionSnapshot(), SetSerializableTransactionSnapshot(), and StartTransaction().
PGDLLIMPORT int XactIsoLevel |
Definition at line 63 of file xact.c.
Referenced by assign_XactIsoLevel(), check_XactIsoLevel(), ExportSnapshot(), InitPostgres(), show_XactIsoLevel(), and StartTransaction().
Definition at line 66 of file xact.c.
Referenced by AbortSubTransaction(), check_transaction_read_only(), check_xact_readonly(), CommitSubTransaction(), DoCopy(), ExportSnapshot(), GetSafeSnapshot(), GetSerializableTransactionSnapshot(), GetSerializableTransactionSnapshotInt(), ImportSnapshot(), PreventCommandIfReadOnly(), PushTransaction(), SetSerializableTransactionSnapshot(), standard_ExecutorStart(), and StartTransaction().