Commit e68be16b authored by Alvaro Herrera's avatar Alvaro Herrera

Do not allow *timestamp to be passed as NULL

The code had bugs that would cause crashes if NULL was passed as that
argument (originally intended to mean not to bother returning its
value), and after inspection it turns out that nothing seems interested
in the case that *ts is NULL anyway.  Therefore, remove the partial
checks intended to support that case.

Author: Michael Paquier
though I didn't include a proposed Assert.

Backpatch to 9.5.
parent 8c3d63c5
......@@ -252,8 +252,10 @@ TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
/*
* Interrogate the commit timestamp of a transaction.
*
* Return value indicates whether commit timestamp record was found for
* given xid.
* The return value indicates whether a commit timestamp record was found for
* the given xid. The timestamp value is returned in *ts (which may not be
* null), and the origin node for the Xid is returned in *nodeid, if it's not
* null.
*/
bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
......@@ -294,7 +296,6 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
TransactionIdPrecedes(xid, oldestCommitTs) ||
TransactionIdPrecedes(newestCommitTs, xid))
{
if (ts)
*ts = 0;
if (nodeid)
*nodeid = InvalidRepOriginId;
......@@ -312,7 +313,6 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
LWLockAcquire(CommitTsLock, LW_SHARED);
if (commitTsShared->xidLastCommit == xid)
{
if (ts)
*ts = commitTsShared->dataLastCommit.time;
if (nodeid)
*nodeid = commitTsShared->dataLastCommit.nodeid;
......@@ -330,7 +330,6 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
SizeOfCommitTimestampEntry * entryno,
SizeOfCommitTimestampEntry);
if (ts)
*ts = entry.time;
if (nodeid)
*nodeid = entry.nodeid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment