mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Fix commit_ts for FrozenXid and BootstrapXid
Previously, requesting commit timestamp for transactions FrozenTransactionId and BootstrapTransactionId resulted in an error. But since those values can validly appear in committed tuples' Xmin, this behavior is unhelpful and error prone: each caller would have to special-case those values before requesting timestamp data for an Xid. We already have a perfectly good interface for returning "the Xid you requested is too old for us to have commit TS data for it", so let's use that instead. Backpatch to 9.5, where commit timestamps appeared. Author: Craig Ringer Discussion: https://www.postgresql.org/message-id/CAMsr+YFM5Q=+ry3mKvWEqRTxrB0iU3qUSRnS28nz6FJYtBwhJg@mail.gmail.com
This commit is contained in:
@ -289,11 +289,18 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
|
||||
TransactionId oldestCommitTsXid;
|
||||
TransactionId newestCommitTsXid;
|
||||
|
||||
/* error if the given Xid doesn't normally commit */
|
||||
if (!TransactionIdIsNormal(xid))
|
||||
if (!TransactionIdIsValid(xid))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("cannot retrieve commit timestamp for transaction %u", xid)));
|
||||
else if (!TransactionIdIsNormal(xid))
|
||||
{
|
||||
/* frozen and bootstrap xids are always committed far in the past */
|
||||
*ts = 0;
|
||||
if (nodeid)
|
||||
*nodeid = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
LWLockAcquire(CommitTsLock, LW_SHARED);
|
||||
|
||||
|
Reference in New Issue
Block a user