233 #define SerializedTransactionStateHeaderSize \
234 offsetof(SerializedTransactionState, parallelCurrentXids)
244 .topXidLogged =
false,
341 const char *stmtType);
628 bool isSubXact = (s->
parent != NULL);
630 bool log_unknown_top =
false;
641 elog(
ERROR,
"cannot assign XIDs during a parallel operation");
653 size_t parentOffset = 0;
658 parents[parentOffset++] = p;
666 while (parentOffset != 0)
684 log_unknown_top =
true;
967 middle = low + (high - low) / 2;
971 else if (probe < xid)
1005 middle = low + (high - low) / 2;
1094 elog(
ERROR,
"cannot start commands during a parallel operation");
1101 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1102 errmsg(
"cannot have more than 2^32-2 commands in a transaction")));
1166 "TransactionAbortContext",
1181 "TopTransactionContext",
1239 "CurTransactionContext",
1292 int ndroppedstats = 0;
1296 bool RelcacheInitFileInval =
false;
1315 &RelcacheInitFileInval);
1322 if (!markXidCommitted)
1332 if (nrels != 0 || ndroppedstats != 0)
1333 elog(
ERROR,
"cannot commit a transaction that deleted files but has no xid");
1352 RelcacheInitFileInval);
1401 nchildren, children, nrels, rels,
1402 ndroppedstats, droppedstats,
1403 nmsgs, invalMessages,
1404 RelcacheInitFileInval,
1456 if ((wrote_xlog && markXidCommitted &&
1465 if (markXidCommitted)
1488 if (markXidCommitted)
1496 if (markXidCommitted)
1514 if (wrote_xlog && markXidCommitted)
1527 pfree(droppedstats);
1628 int new_maxChildXids;
1637 new_maxChildXids =
Min(new_nChildXids * 2,
1640 if (new_maxChildXids < new_nChildXids)
1642 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1643 errmsg(
"maximum number of committed subtransactions (%d) exceeded",
1708 int ndroppedstats = 0;
1741 elog(
PANIC,
"cannot abort transaction %u, it was already committed",
1768 nchildren, children,
1770 ndroppedstats, droppedstats,
1823 pfree(droppedstats);
2156 bool is_parallel_worker;
2161 if (is_parallel_worker)
2170 elog(
WARNING,
"CommitTransaction while in %s state",
2245 if (!is_parallel_worker)
2261 if (!is_parallel_worker)
2284 TRACE_POSTGRESQL_TRANSACTION_COMMIT(
MyProc->
lxid);
2427 elog(
WARNING,
"PrepareTransaction while in %s state",
2512 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2513 errmsg(
"cannot PREPARE a transaction that has operated on temporary objects")));
2522 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2523 errmsg(
"cannot PREPARE a transaction that has exported snapshots")));
2701 bool is_parallel_worker;
2758 elog(
WARNING,
"AbortTransaction while in %s state",
2813 if (!is_parallel_worker)
2827 TRACE_POSTGRESQL_TRANSACTION_ABORT(
MyProc->
lxid);
2843 if (is_parallel_worker)
2896 elog(
FATAL,
"CleanupTransaction: unexpected state %s",
2991 elog(
ERROR,
"StartTransactionCommand: unexpected state %s",
3052 elog(
FATAL,
"CommitTransactionCommand: unexpected state %s",
3218 elog(
ERROR,
"CommitTransactionCommand: unexpected state %s",
3488 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3490 errmsg(
"%s cannot run inside a transaction block",
3498 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3500 errmsg(
"%s cannot run inside a subtransaction",
3508 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3510 errmsg(
"%s cannot be executed within a pipeline",
3518 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3520 errmsg(
"%s cannot be executed from a function", stmtType)));
3525 elog(
FATAL,
"cannot prevent transaction chain");
3589 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3591 errmsg(
"%s can only be used in transaction blocks",
3755 item->
callback(event, mySubid, parentSubid, item->
arg);
3801 (
errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
3802 errmsg(
"there is already a transaction in progress")));
3819 elog(
FATAL,
"BeginTransactionBlock: unexpected state %s",
3851 while (s->
parent != NULL)
3893 bool result =
false;
3914 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3916 errmsg(
"%s can only be used in transaction blocks",
3917 "COMMIT AND CHAIN")));
3920 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3921 errmsg(
"there is no transaction in progress")));
3939 while (s->
parent != NULL)
3944 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3951 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3962 while (s->
parent != NULL)
3969 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3978 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
3993 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
3995 errmsg(
"%s can only be used in transaction blocks",
3996 "COMMIT AND CHAIN")));
3999 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4000 errmsg(
"there is no transaction in progress")));
4010 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4011 errmsg(
"cannot commit during a parallel operation")));
4028 elog(
FATAL,
"EndTransactionBlock: unexpected state %s",
4081 while (s->
parent != NULL)
4088 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4097 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4116 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4118 errmsg(
"%s can only be used in transaction blocks",
4119 "ROLLBACK AND CHAIN")));
4122 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4123 errmsg(
"there is no transaction in progress")));
4133 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4134 errmsg(
"cannot abort during a parallel operation")));
4151 elog(
FATAL,
"UserAbortTransactionBlock: unexpected state %s",
4232 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4233 errmsg(
"cannot define savepoints during a parallel operation")));
4267 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4269 errmsg(
"%s can only be used in transaction blocks",
4291 elog(
FATAL,
"DefineSavepoint: unexpected state %s",
4319 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4320 errmsg(
"cannot release savepoints during a parallel operation")));
4329 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4330 errmsg(
"savepoint \"%s\" does not exist",
name)));
4336 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4338 errmsg(
"%s can only be used in transaction blocks",
4339 "RELEASE SAVEPOINT")));
4367 elog(
FATAL,
"ReleaseSavepoint: unexpected state %s",
4380 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4381 errmsg(
"savepoint \"%s\" does not exist",
name)));
4386 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4387 errmsg(
"savepoint \"%s\" does not exist within current savepoint level",
name)));
4428 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4429 errmsg(
"cannot rollback to savepoints during a parallel operation")));
4440 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4441 errmsg(
"savepoint \"%s\" does not exist",
name)));
4447 (
errcode(ERRCODE_NO_ACTIVE_SQL_TRANSACTION),
4449 errmsg(
"%s can only be used in transaction blocks",
4450 "ROLLBACK TO SAVEPOINT")));
4476 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4489 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4490 errmsg(
"savepoint \"%s\" does not exist",
name)));
4495 (
errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
4496 errmsg(
"savepoint \"%s\" does not exist within current savepoint level",
name)));
4513 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4525 elog(
FATAL,
"RollbackToSavepoint: unexpected state %s",
4556 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4557 errmsg(
"cannot start subtransactions during a parallel operation")));
4594 elog(
FATAL,
"BeginInternalSubTransaction: unexpected state %s",
4624 (
errcode(ERRCODE_INVALID_TRANSACTION_STATE),
4625 errmsg(
"cannot commit subtransactions during a parallel operation")));
4628 elog(
ERROR,
"ReleaseCurrentSubTransaction: unexpected state %s",
4683 elog(
FATAL,
"RollbackAndReleaseCurrentSubTransaction: unexpected state %s",
4880 elog(
FATAL,
"invalid transaction block state: %s",
4917 elog(
WARNING,
"StartSubTransaction while in %s state",
4956 elog(
WARNING,
"CommitSubTransaction while in %s state",
5118 elog(
WARNING,
"AbortSubTransaction while in %s state",
5223 elog(
WARNING,
"CleanupSubTransaction while in %s state",
5270 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
5271 errmsg(
"cannot have more than 2^32-1 subtransactions in a transaction")));
5318 elog(
FATAL,
"PopTransaction with no parent");
5510 (
errmsg_internal(
"%s(%d) name: %s; blockState: %s; state: %s, xid/subid/cid: %u/%u/%u%s%s",
5540 return "INPROGRESS";
5542 return "IMPLICIT_INPROGRESS";
5544 return "PARALLEL_INPROGRESS";
5552 return "ABORT_PENDING";
5558 return "SUBINPROGRESS";
5560 return "SUBRELEASE";
5566 return "SUBABORT_END";
5568 return "SUBABORT_PENDING";
5570 return "SUBRESTART";
5572 return "SUBABORT_RESTART";
5574 return "UNRECOGNIZED";
5591 return "INPROGRESS";
5599 return "UNRECOGNIZED";
5643 const char *twophase_gid)