238#define SerializedTransactionStateHeaderSize \
239 offsetof(SerializedTransactionState, parallelCurrentXids)
249 .topXidLogged =
false,
346 const char *stmtType);
636 bool isSubXact = (s->
parent != NULL);
638 bool log_unknown_top =
false;
650 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
651 errmsg(
"cannot assign transaction IDs during a parallel operation")));
663 size_t parentOffset = 0;
668 parents[parentOffset++] = p;
676 while (parentOffset != 0)
694 log_unknown_top =
true;
841 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
842 errmsg(
"cannot modify data in a parallel worker")));
981 middle = low + (high - low) / 2;
985 else if (probe < xid)
1019 middle = low + (high - low) / 2;
1116 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
1117 errmsg(
"cannot start commands during a parallel operation")));
1124 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1125 errmsg(
"cannot have more than 2^32-2 commands in a transaction")));
1194 "TransactionAbortContext",
1207 "TopTransactionContext",
1270 "CurTransactionContext",
1323 int ndroppedstats = 0;
1327 bool RelcacheInitFileInval =
false;
1346 &RelcacheInitFileInval);
1353 if (!markXidCommitted)
1363 if (nrels != 0 || ndroppedstats != 0)
1364 elog(
ERROR,
"cannot commit a transaction that deleted files but has no xid");
1393 RelcacheInitFileInval);
1442 nchildren, children, nrels, rels,
1443 ndroppedstats, droppedstats,
1444 nmsgs, invalMessages,
1445 RelcacheInitFileInval,
1497 if ((wrote_xlog && markXidCommitted &&
1506 if (markXidCommitted)
1529 if (markXidCommitted)
1537 if (markXidCommitted)
1555 if (wrote_xlog && markXidCommitted)
1568 pfree(droppedstats);
1679 int new_maxChildXids;
1688 new_maxChildXids =
Min(new_nChildXids * 2,
1691 if (new_maxChildXids < new_nChildXids)
1693 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1694 errmsg(
"maximum number of committed subtransactions (%d) exceeded",
1759 int ndroppedstats = 0;
1792 elog(
PANIC,
"cannot abort transaction %u, it was already committed",
1819 nchildren, children,
1821 ndroppedstats, droppedstats,
1874 pfree(droppedstats);
2231 bool is_parallel_worker;
2236 if (is_parallel_worker)
2245 elog(
WARNING,
"CommitTransaction while in %s state",
2290 if (is_parallel_worker)
2293 elog(
WARNING,
"parallelModeLevel is %d not 1 at end of parallel worker transaction",
2299 elog(
WARNING,
"parallelModeLevel is %d not 0 at end of transaction",
2337 if (!is_parallel_worker)
2358 if (!is_parallel_worker)
2527 elog(
WARNING,
"PrepareTransaction while in %s state",
2612 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2613 errmsg(
"cannot PREPARE a transaction that has operated on temporary objects")));
2622 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2623 errmsg(
"cannot PREPARE a transaction that has exported snapshots")));
2808 bool is_parallel_worker;
2869 elog(
WARNING,
"AbortTransaction while in %s state",
2925 if (!is_parallel_worker)
2955 if (is_parallel_worker)
3009 elog(
FATAL,
"CleanupTransaction: unexpected state %s",
3105 elog(
ERROR,
"StartTransactionCommand: unexpected state %s",
3185 elog(
FATAL,
"CommitTransactionCommand: unexpected state %s",
3351 elog(
ERROR,
"CommitTransactionCommand: unexpected state %s",
3647 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3649 errmsg(
"%s cannot run inside a transaction block",
3657 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3659 errmsg(
"%s cannot run inside a subtransaction",
3667 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3669 errmsg(
"%s cannot be executed from a function", stmtType)));
3674 elog(
FATAL,
"cannot prevent transaction chain");
3738 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3740 errmsg(
"%s can only be used in transaction blocks",
3901 item->
callback(event, mySubid, parentSubid, item->
arg);
3947 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3948 errmsg(
"there is already a transaction in progress")));
3965 elog(
FATAL,
"BeginTransactionBlock: unexpected state %s",
3997 while (s->
parent != NULL)
4039 bool result =
false;
4060 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4062 errmsg(
"%s can only be used in transaction blocks",
4063 "COMMIT AND CHAIN")));
4066 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4067 errmsg(
"there is no transaction in progress")));
4085 while (s->
parent != NULL)
4090 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4097 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4108 while (s->
parent != NULL)
4115 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4124 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4139 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4141 errmsg(
"%s can only be used in transaction blocks",
4142 "COMMIT AND CHAIN")));
4145 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4146 errmsg(
"there is no transaction in progress")));
4156 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4157 errmsg(
"cannot commit during a parallel operation")));
4174 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4227 while (s->
parent != NULL)
4234 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4243 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4262 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4264 errmsg(
"%s can only be used in transaction blocks",
4265 "ROLLBACK AND CHAIN")));
4268 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4269 errmsg(
"there is no transaction in progress")));
4279 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4280 errmsg(
"cannot abort during a parallel operation")));
4297 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4378 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4379 errmsg(
"cannot define savepoints during a parallel operation")));
4413 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4415 errmsg(
"%s can only be used in transaction blocks",
4437 elog(
FATAL,
"DefineSavepoint: unexpected state %s",
4465 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4466 errmsg(
"cannot release savepoints during a parallel operation")));
4475 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4476 errmsg(
"savepoint \"%s\" does not exist",
name)));
4482 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4484 errmsg(
"%s can only be used in transaction blocks",
4485 "RELEASE SAVEPOINT")));
4513 elog(
FATAL,
"ReleaseSavepoint: unexpected state %s",
4526 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4527 errmsg(
"savepoint \"%s\" does not exist",
name)));
4532 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4533 errmsg(
"savepoint \"%s\" does not exist within current savepoint level",
name)));
4574 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4575 errmsg(
"cannot rollback to savepoints during a parallel operation")));
4586 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4587 errmsg(
"savepoint \"%s\" does not exist",
name)));
4593 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4595 errmsg(
"%s can only be used in transaction blocks",
4596 "ROLLBACK TO SAVEPOINT")));
4622 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4635 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4636 errmsg(
"savepoint \"%s\" does not exist",
name)));
4641 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4642 errmsg(
"savepoint \"%s\" does not exist within current savepoint level",
name)));
4659 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4671 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4741 elog(
FATAL,
"BeginInternalSubTransaction: unexpected state %s",
4771 elog(
ERROR,
"ReleaseCurrentSubTransaction: unexpected state %s",
4824 elog(
FATAL,
"RollbackAndReleaseCurrentSubTransaction: unexpected state %s",
5027 elog(
FATAL,
"invalid transaction block state: %s",
5064 elog(
WARNING,
"StartSubTransaction while in %s state",
5103 elog(
WARNING,
"CommitSubTransaction while in %s state",
5118 elog(
WARNING,
"parallelModeLevel is %d not 0 at end of subtransaction",
5271 elog(
WARNING,
"AbortSubTransaction while in %s state",