313 const char *stmtType);
448 CurrentTransactionState->
didLogXid =
true;
491 bool isSubXact = (s->
parent != NULL);
493 bool log_unknown_top =
false;
504 elog(
ERROR,
"cannot assign XIDs during a parallel operation");
516 size_t parentOffset = 0;
521 parents[parentOffset++] = p;
529 while (parentOffset != 0)
547 log_unknown_top =
true;
632 TopTransactionStateData.
didLogXid =
true;
659 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
803 middle = low + (high - low) / 2;
807 else if (probe < xid)
822 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
841 middle = low + (high - low) / 2;
930 elog(
ERROR,
"cannot start commands during a parallel operation");
937 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
938 errmsg(
"cannot have more than 2^32-2 commands in a transaction")));
997 if (TransactionAbortContext == NULL)
998 TransactionAbortContext =
1000 "TransactionAbortContext",
1015 "TopTransactionContext",
1073 "CurTransactionContext",
1128 bool RelcacheInitFileInval =
false;
1136 &RelcacheInitFileInval);
1143 if (!markXidCommitted)
1152 elog(
ERROR,
"cannot commit a transaction that deleted files but has no xid");
1171 RelcacheInitFileInval);
1224 nchildren, children, nrels, rels,
1225 nmsgs, invalMessages,
1278 if ((wrote_xlog && markXidCommitted &&
1287 if (markXidCommitted)
1310 if (markXidCommitted)
1318 if (markXidCommitted)
1336 if (wrote_xlog && markXidCommitted)
1448 int new_maxChildXids;
1457 new_maxChildXids =
Min(new_nChildXids * 2,
1460 if (new_maxChildXids < new_nChildXids)
1462 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1463 errmsg(
"maximum number of committed subtransactions (%d) exceeded",
1558 elog(
PANIC,
"cannot abort transaction %u, it was already committed",
1578 nchildren, children,
1644 if (TransactionAbortContext != NULL)
1656 Assert(TransactionAbortContext != NULL);
1737 if (TransactionAbortContext != NULL)
1773 if (TransactionAbortContext != NULL)
1804 CurrentTransactionState = s;
1812 elog(
WARNING,
"StartTransaction while in %s state",
1937 bool is_parallel_worker;
1942 if (is_parallel_worker)
1951 elog(
WARNING,
"CommitTransaction while in %s state",
2030 if (!is_parallel_worker)
2053 TRACE_POSTGRESQL_TRANSACTION_COMMIT(
MyProc->
lxid);
2184 elog(
WARNING,
"PrepareTransaction while in %s state",
2257 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2258 errmsg(
"cannot PREPARE a transaction that has operated on temporary tables")));
2267 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2268 errmsg(
"cannot PREPARE a transaction that has exported snapshots")));
2276 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2277 errmsg(
"cannot PREPARE a transaction that has manipulated logical replication workers")));
2448 bool is_parallel_worker;
2506 elog(
WARNING,
"AbortTransaction while in %s state",
2551 if (!is_parallel_worker)
2565 TRACE_POSTGRESQL_TRANSACTION_ABORT(
MyProc->
lxid);
2581 if (is_parallel_worker)
2632 elog(
FATAL,
"CleanupTransaction: unexpected state %s",
2727 elog(
ERROR,
"StartTransactionCommand: unexpected state %s",
2758 elog(
FATAL,
"CommitTransactionCommand: unexpected state %s",
2897 elog(
ERROR,
"CommitTransactionCommand: unexpected state %s",
3160 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3162 errmsg(
"%s cannot run inside a transaction block",
3170 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3172 errmsg(
"%s cannot run inside a subtransaction",
3180 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3182 errmsg(
"%s cannot be executed from a function", stmtType)));
3187 elog(
FATAL,
"cannot prevent transaction chain");
3249 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3251 errmsg(
"%s can only be used in transaction blocks",
3311 Xact_callbacks = item;
3321 for (item = Xact_callbacks; item; prev = item, item = item->
next)
3323 if (item->callback == callback && item->arg == arg)
3328 Xact_callbacks = item->
next;
3340 for (item = Xact_callbacks; item; item = item->
next)
3366 SubXact_callbacks = item;
3376 for (item = SubXact_callbacks; item; prev = item, item = item->
next)
3378 if (item->callback == callback && item->arg == arg)
3383 SubXact_callbacks = item->
next;
3397 for (item = SubXact_callbacks; item; item = item->
next)
3398 item->
callback(event, mySubid, parentSubid, item->
arg);
3443 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3444 errmsg(
"there is already a transaction in progress")));
3461 elog(
FATAL,
"BeginTransactionBlock: unexpected state %s",
3493 while (s->
parent != NULL)
3535 bool result =
false;
3554 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3555 errmsg(
"there is no transaction in progress")));
3573 while (s->
parent != NULL)
3578 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3585 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3596 while (s->
parent != NULL)
3603 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3612 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3624 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3625 errmsg(
"there is no transaction in progress")));
3635 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
3636 errmsg(
"cannot commit during a parallel operation")));
3653 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3699 while (s->
parent != NULL)
3706 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
3715 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
3733 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3734 errmsg(
"there is no transaction in progress")));
3744 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
3745 errmsg(
"cannot abort during a parallel operation")));
3762 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
3838 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
3839 errmsg(
"cannot define savepoints during a parallel operation")));
3873 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3875 errmsg(
"%s can only be used in transaction blocks",
3897 elog(
FATAL,
"DefineSavepoint: unexpected state %s",
3925 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
3926 errmsg(
"cannot release savepoints during a parallel operation")));
3935 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
3936 errmsg(
"savepoint \"%s\" does not exist", name)));
3942 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3944 errmsg(
"%s can only be used in transaction blocks",
3945 "RELEASE SAVEPOINT")));
3973 elog(
FATAL,
"ReleaseSavepoint: unexpected state %s",
3986 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
3987 errmsg(
"savepoint \"%s\" does not exist", name)));
3992 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
3993 errmsg(
"savepoint \"%s\" does not exist within current savepoint level", name)));
4034 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4035 errmsg(
"cannot rollback to savepoints during a parallel operation")));
4046 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4047 errmsg(
"savepoint \"%s\" does not exist", name)));
4053 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4055 errmsg(
"%s can only be used in transaction blocks",
4056 "ROLLBACK TO SAVEPOINT")));
4082 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4095 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4096 errmsg(
"savepoint \"%s\" does not exist", name)));
4101 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4102 errmsg(
"savepoint \"%s\" does not exist within current savepoint level", name)));
4119 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4131 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4162 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4163 errmsg(
"cannot start subtransactions during a parallel operation")));
4200 elog(
FATAL,
"BeginInternalSubTransaction: unexpected state %s",
4230 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4231 errmsg(
"cannot commit subtransactions during a parallel operation")));
4234 elog(
ERROR,
"ReleaseCurrentSubTransaction: unexpected state %s",
4289 elog(
FATAL,
"RollbackAndReleaseCurrentSubTransaction: unexpected state %s",
4486 elog(
FATAL,
"invalid transaction block state: %s",
4523 elog(
WARNING,
"StartSubTransaction while in %s state",
4563 elog(
WARNING,
"CommitSubTransaction while in %s state",
4725 elog(
WARNING,
"AbortSubTransaction while in %s state",
4819 elog(
WARNING,
"CleanupSubTransaction while in %s state",
4866 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
4867 errmsg(
"cannot have more than 2^32-1 subtransactions in a transaction")));
4886 CurrentTransactionState = s;
4913 elog(
FATAL,
"PopTransaction with no parent");
4915 CurrentTransactionState = s->
parent;
4944 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
5005 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
5015 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
5030 memcpy(&result[c], workspace, nxids *
sizeof(
TransactionId));
5106 (
errmsg_internal(
"%s(%d) name: %s; blockState: %s; state: %s, xid/subid/cid: %u/%u/%u%s%s",
5136 return "INPROGRESS";
5138 return "IMPLICIT_INPROGRESS";
5140 return "PARALLEL_INPROGRESS";
5148 return "ABORT_PENDING";
5154 return "SUBINPROGRESS";
5156 return "SUBRELEASE";
5162 return "SUBABORT_END";
5164 return "SUBABORT_PENDING";
5166 return "SUBRESTART";
5168 return "SUBABORT_RESTART";
5170 return "UNRECOGNIZED";
5187 return "INPROGRESS";
5195 return "UNRECOGNIZED";
5236 bool relcacheInval,
bool forceSync,
5238 const char *twophase_gid)
5298 xl_relfilenodes.
nrels = nrels;
5304 xl_invals.
nmsgs = nmsgs;
5310 xl_twophase.
xid = twophase_xid;
5311 Assert(twophase_gid != NULL);
5326 if (xl_xinfo.
xinfo != 0)
5335 if (xl_xinfo.
xinfo != 0)
5391 const char *twophase_gid)
5430 xl_relfilenodes.
nrels = nrels;
5436 xl_twophase.
xid = twophase_xid;
5437 Assert(twophase_gid != NULL);
5461 if (xl_xinfo.
xinfo != 0)
5470 if (xl_xinfo.
xinfo != 0)
5552 commit_time, origin_id,
false);
5621 if (parsed->
nrels > 0)
5640 for (i = 0; i < parsed->
nrels; i++)
5753 for (i = 0; i < parsed->
nrels; i++)