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");
1383 RelcacheInitFileInval);
1432 nchildren, children, nrels, rels,
1433 ndroppedstats, droppedstats,
1434 nmsgs, invalMessages,
1435 RelcacheInitFileInval,
1487 if ((wrote_xlog && markXidCommitted &&
1496 if (markXidCommitted)
1519 if (markXidCommitted)
1527 if (markXidCommitted)
1545 if (wrote_xlog && markXidCommitted)
1558 pfree(droppedstats);
1669 int new_maxChildXids;
1678 new_maxChildXids =
Min(new_nChildXids * 2,
1681 if (new_maxChildXids < new_nChildXids)
1683 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1684 errmsg(
"maximum number of committed subtransactions (%d) exceeded",
1749 int ndroppedstats = 0;
1782 elog(
PANIC,
"cannot abort transaction %u, it was already committed",
1809 nchildren, children,
1811 ndroppedstats, droppedstats,
1864 pfree(droppedstats);
2221 bool is_parallel_worker;
2226 if (is_parallel_worker)
2235 elog(
WARNING,
"CommitTransaction while in %s state",
2280 if (is_parallel_worker)
2283 elog(
WARNING,
"parallelModeLevel is %d not 1 at end of parallel worker transaction",
2289 elog(
WARNING,
"parallelModeLevel is %d not 0 at end of transaction",
2327 if (!is_parallel_worker)
2348 if (!is_parallel_worker)
2514 elog(
WARNING,
"PrepareTransaction while in %s state",
2599 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2600 errmsg(
"cannot PREPARE a transaction that has operated on temporary objects")));
2609 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2610 errmsg(
"cannot PREPARE a transaction that has exported snapshots")));
2792 bool is_parallel_worker;
2858 elog(
WARNING,
"AbortTransaction while in %s state",
2914 if (!is_parallel_worker)
2944 if (is_parallel_worker)
2997 elog(
FATAL,
"CleanupTransaction: unexpected state %s",
3093 elog(
ERROR,
"StartTransactionCommand: unexpected state %s",
3173 elog(
FATAL,
"CommitTransactionCommand: unexpected state %s",
3339 elog(
ERROR,
"CommitTransactionCommand: unexpected state %s",
3635 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3637 errmsg(
"%s cannot run inside a transaction block",
3645 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3647 errmsg(
"%s cannot run inside a subtransaction",
3655 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3657 errmsg(
"%s cannot be executed within a pipeline",
3665 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3667 errmsg(
"%s cannot be executed from a function", stmtType)));
3672 elog(
FATAL,
"cannot prevent transaction chain");
3736 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3738 errmsg(
"%s can only be used in transaction blocks",
3902 item->
callback(event, mySubid, parentSubid, item->
arg);
3948 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3949 errmsg(
"there is already a transaction in progress")));
3966 elog(
FATAL,
"BeginTransactionBlock: unexpected state %s",
3998 while (s->
parent != NULL)
4040 bool result =
false;
4061 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4063 errmsg(
"%s can only be used in transaction blocks",
4064 "COMMIT AND CHAIN")));
4067 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4068 errmsg(
"there is no transaction in progress")));
4086 while (s->
parent != NULL)
4091 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4098 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4109 while (s->
parent != NULL)
4116 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4125 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4140 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4142 errmsg(
"%s can only be used in transaction blocks",
4143 "COMMIT AND CHAIN")));
4146 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4147 errmsg(
"there is no transaction in progress")));
4157 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4158 errmsg(
"cannot commit during a parallel operation")));
4175 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4228 while (s->
parent != NULL)
4235 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4244 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4263 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4265 errmsg(
"%s can only be used in transaction blocks",
4266 "ROLLBACK AND CHAIN")));
4269 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4270 errmsg(
"there is no transaction in progress")));
4280 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4281 errmsg(
"cannot abort during a parallel operation")));
4298 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4379 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4380 errmsg(
"cannot define savepoints during a parallel operation")));
4414 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4416 errmsg(
"%s can only be used in transaction blocks",
4438 elog(
FATAL,
"DefineSavepoint: unexpected state %s",
4466 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4467 errmsg(
"cannot release savepoints during a parallel operation")));
4476 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4477 errmsg(
"savepoint \"%s\" does not exist",
name)));
4483 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4485 errmsg(
"%s can only be used in transaction blocks",
4486 "RELEASE SAVEPOINT")));
4514 elog(
FATAL,
"ReleaseSavepoint: unexpected state %s",
4527 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4528 errmsg(
"savepoint \"%s\" does not exist",
name)));
4533 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4534 errmsg(
"savepoint \"%s\" does not exist within current savepoint level",
name)));
4575 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4576 errmsg(
"cannot rollback to savepoints during a parallel operation")));
4587 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4588 errmsg(
"savepoint \"%s\" does not exist",
name)));
4594 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4596 errmsg(
"%s can only be used in transaction blocks",
4597 "ROLLBACK TO SAVEPOINT")));
4623 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4636 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4637 errmsg(
"savepoint \"%s\" does not exist",
name)));
4642 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4643 errmsg(
"savepoint \"%s\" does not exist within current savepoint level",
name)));
4660 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4672 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4742 elog(
FATAL,
"BeginInternalSubTransaction: unexpected state %s",
4772 elog(
ERROR,
"ReleaseCurrentSubTransaction: unexpected state %s",
4825 elog(
FATAL,
"RollbackAndReleaseCurrentSubTransaction: unexpected state %s",
5028 elog(
FATAL,
"invalid transaction block state: %s",
5065 elog(
WARNING,
"StartSubTransaction while in %s state",
5104 elog(
WARNING,
"CommitSubTransaction while in %s state",
5119 elog(
WARNING,
"parallelModeLevel is %d not 0 at end of subtransaction",
5271 elog(
WARNING,
"AbortSubTransaction while in %s state",
5377 elog(
WARNING,
"CleanupSubTransaction while in %s state",
5424 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
5425 errmsg(
"cannot have more than 2^32-1 subtransactions in a transaction")));
5474 elog(
FATAL,
"PopTransaction with no parent");
5676 (
errmsg_internal(
"%s(%d) name: %s; blockState: %s; state: %s, xid/subid/cid: %u/%u/%u%s%s",