229 #define SerializedTransactionStateHeaderSize \ 230 offsetof(SerializedTransactionState, parallelCurrentXids) 334 const char *stmtType);
528 CurrentTransactionState->
didLogXid =
true;
571 bool isSubXact = (s->
parent != NULL);
573 bool log_unknown_top =
false;
584 elog(
ERROR,
"cannot assign XIDs during a parallel operation");
596 size_t parentOffset = 0;
601 parents[parentOffset++] = p;
609 while (parentOffset != 0)
627 log_unknown_top =
true;
714 TopTransactionStateData.
didLogXid =
true;
741 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
910 middle = low + (high - low) / 2;
914 else if (probe < xid)
929 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
948 middle = low + (high - low) / 2;
1037 elog(
ERROR,
"cannot start commands during a parallel operation");
1044 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1045 errmsg(
"cannot have more than 2^32-2 commands in a transaction")));
1106 if (TransactionAbortContext == NULL)
1107 TransactionAbortContext =
1109 "TransactionAbortContext",
1124 "TopTransactionContext",
1182 "CurTransactionContext",
1237 bool RelcacheInitFileInval =
false;
1255 &RelcacheInitFileInval);
1262 if (!markXidCommitted)
1271 elog(
ERROR,
"cannot commit a transaction that deleted files but has no xid");
1290 RelcacheInitFileInval);
1343 nchildren, children, nrels, rels,
1344 nmsgs, invalMessages,
1345 RelcacheInitFileInval,
1397 if ((wrote_xlog && markXidCommitted &&
1406 if (markXidCommitted)
1429 if (markXidCommitted)
1437 if (markXidCommitted)
1455 if (wrote_xlog && markXidCommitted)
1567 int new_maxChildXids;
1576 new_maxChildXids =
Min(new_nChildXids * 2,
1579 if (new_maxChildXids < new_nChildXids)
1581 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1582 errmsg(
"maximum number of committed subtransactions (%d) exceeded",
1677 elog(
PANIC,
"cannot abort transaction %u, it was already committed",
1697 nchildren, children,
1763 if (TransactionAbortContext != NULL)
1775 Assert(TransactionAbortContext != NULL);
1856 if (TransactionAbortContext != NULL)
1892 if (TransactionAbortContext != NULL)
1923 CurrentTransactionState = s;
2077 bool is_parallel_worker;
2082 if (is_parallel_worker)
2091 elog(
WARNING,
"CommitTransaction while in %s state",
2166 if (!is_parallel_worker)
2182 if (!is_parallel_worker)
2205 TRACE_POSTGRESQL_TRANSACTION_COMMIT(
MyProc->
lxid);
2337 elog(
WARNING,
"PrepareTransaction while in %s state",
2422 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2423 errmsg(
"cannot PREPARE a transaction that has operated on temporary objects")));
2432 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2433 errmsg(
"cannot PREPARE a transaction that has exported snapshots")));
2605 bool is_parallel_worker;
2663 elog(
WARNING,
"AbortTransaction while in %s state",
2715 if (!is_parallel_worker)
2729 TRACE_POSTGRESQL_TRANSACTION_ABORT(
MyProc->
lxid);
2745 if (is_parallel_worker)
2797 elog(
FATAL,
"CleanupTransaction: unexpected state %s",
2892 elog(
ERROR,
"StartTransactionCommand: unexpected state %s",
2956 elog(
FATAL,
"CommitTransactionCommand: unexpected state %s",
3123 elog(
ERROR,
"CommitTransactionCommand: unexpected state %s",
3386 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3388 errmsg(
"%s cannot run inside a transaction block",
3396 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3398 errmsg(
"%s cannot run inside a subtransaction",
3406 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3408 errmsg(
"%s cannot be executed from a function", stmtType)));
3413 elog(
FATAL,
"cannot prevent transaction chain");
3475 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3477 errmsg(
"%s can only be used in transaction blocks",
3536 Xact_callbacks = item;
3546 for (item = Xact_callbacks; item; prev = item, item = item->
next)
3548 if (item->callback == callback && item->arg == arg)
3553 Xact_callbacks = item->
next;
3565 for (item = Xact_callbacks; item; item = item->
next)
3591 SubXact_callbacks = item;
3601 for (item = SubXact_callbacks; item; prev = item, item = item->
next)
3603 if (item->callback == callback && item->arg == arg)
3608 SubXact_callbacks = item->
next;
3622 for (item = SubXact_callbacks; item; item = item->
next)
3623 item->
callback(event, mySubid, parentSubid, item->
arg);
3668 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3669 errmsg(
"there is already a transaction in progress")));
3686 elog(
FATAL,
"BeginTransactionBlock: unexpected state %s",
3718 while (s->
parent != NULL)
3760 bool result =
false;
3781 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3783 errmsg(
"%s can only be used in transaction blocks",
3784 "COMMIT AND CHAIN")));
3787 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3788 errmsg(
"there is no transaction in progress")));
3806 while (s->
parent != NULL)
3811 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3818 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3829 while (s->
parent != NULL)
3836 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3845 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3860 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3862 errmsg(
"%s can only be used in transaction blocks",
3863 "COMMIT AND CHAIN")));
3866 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3867 errmsg(
"there is no transaction in progress")));
3877 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
3878 errmsg(
"cannot commit during a parallel operation")));
3895 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3948 while (s->
parent != NULL)
3955 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
3964 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
3983 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3985 errmsg(
"%s can only be used in transaction blocks",
3986 "ROLLBACK AND CHAIN")));
3989 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3990 errmsg(
"there is no transaction in progress")));
4000 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4001 errmsg(
"cannot abort during a parallel operation")));
4018 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4099 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4100 errmsg(
"cannot define savepoints during a parallel operation")));
4134 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4136 errmsg(
"%s can only be used in transaction blocks",
4158 elog(
FATAL,
"DefineSavepoint: unexpected state %s",
4186 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4187 errmsg(
"cannot release savepoints during a parallel operation")));
4196 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4197 errmsg(
"savepoint \"%s\" does not exist", name)));
4203 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4205 errmsg(
"%s can only be used in transaction blocks",
4206 "RELEASE SAVEPOINT")));
4234 elog(
FATAL,
"ReleaseSavepoint: unexpected state %s",
4247 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4248 errmsg(
"savepoint \"%s\" does not exist", name)));
4253 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4254 errmsg(
"savepoint \"%s\" does not exist within current savepoint level", name)));
4295 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4296 errmsg(
"cannot rollback to savepoints during a parallel operation")));
4307 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4308 errmsg(
"savepoint \"%s\" does not exist", name)));
4314 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4316 errmsg(
"%s can only be used in transaction blocks",
4317 "ROLLBACK TO SAVEPOINT")));
4343 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4356 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4357 errmsg(
"savepoint \"%s\" does not exist", name)));
4362 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4363 errmsg(
"savepoint \"%s\" does not exist within current savepoint level", name)));
4380 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4392 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4423 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4424 errmsg(
"cannot start subtransactions during a parallel operation")));
4461 elog(
FATAL,
"BeginInternalSubTransaction: unexpected state %s",
4491 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4492 errmsg(
"cannot commit subtransactions during a parallel operation")));
4495 elog(
ERROR,
"ReleaseCurrentSubTransaction: unexpected state %s",
4550 elog(
FATAL,
"RollbackAndReleaseCurrentSubTransaction: unexpected state %s",
4747 elog(
FATAL,
"invalid transaction block state: %s",
4784 elog(
WARNING,
"StartSubTransaction while in %s state",
4823 elog(
WARNING,
"CommitSubTransaction while in %s state",
4985 elog(
WARNING,
"AbortSubTransaction while in %s state",
5085 elog(
WARNING,
"CleanupSubTransaction while in %s state",
5132 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
5133 errmsg(
"cannot have more than 2^32-1 subtransactions in a transaction")));
5153 CurrentTransactionState = s;
5180 elog(
FATAL,
"PopTransaction with no parent");
5182 CurrentTransactionState = s->
parent;
5211 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
5267 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
5278 for (s = CurrentTransactionState; s != NULL; s = s->
parent)
5371 (
errmsg_internal(
"%s(%d) name: %s; blockState: %s; state: %s, xid/subid/cid: %u/%u/%u%s%s",
5401 return "INPROGRESS";
5403 return "IMPLICIT_INPROGRESS";
5405 return "PARALLEL_INPROGRESS";
5413 return "ABORT_PENDING";
5419 return "SUBINPROGRESS";
5421 return "SUBRELEASE";
5427 return "SUBABORT_END";
5429 return "SUBABORT_PENDING";
5431 return "SUBRESTART";
5433 return "SUBABORT_RESTART";
5435 return "UNRECOGNIZED";
5452 return "INPROGRESS";
5460 return "UNRECOGNIZED";
5503 const char *twophase_gid)
5563 xl_relfilenodes.
nrels = nrels;
5570 xl_invals.
nmsgs = nmsgs;
5576 xl_twophase.
xid = twophase_xid;
5577 Assert(twophase_gid != NULL);
5592 if (xl_xinfo.
xinfo != 0)
5601 if (xl_xinfo.
xinfo != 0)
5657 const char *twophase_gid)
5696 xl_relfilenodes.
nrels = nrels;
5703 xl_twophase.
xid = twophase_xid;
5704 Assert(twophase_gid != NULL);
5730 if (xl_xinfo.
xinfo != 0)
5739 if (xl_xinfo.
xinfo != 0)