summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2015-08-21 17:36:54 +0000
committerAlvaro Herrera2015-08-21 17:36:54 +0000
commite68be16b0d0e857bc05949b8ee78c5aaf7d8954a (patch)
tree2320edc6672be0499f30701149a33baebf4a39ff
parent8c3d63c521a28c2224aefbdc28ae7e24e81a0156 (diff)
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.
-rw-r--r--src/backend/access/transam/commit_ts.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 5ad35c0d7f8..33136e3c1d9 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -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,8 +296,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
TransactionIdPrecedes(xid, oldestCommitTs) ||
TransactionIdPrecedes(newestCommitTs, xid))
{
- if (ts)
- *ts = 0;
+ *ts = 0;
if (nodeid)
*nodeid = InvalidRepOriginId;
return false;
@@ -312,8 +313,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
LWLockAcquire(CommitTsLock, LW_SHARED);
if (commitTsShared->xidLastCommit == xid)
{
- if (ts)
- *ts = commitTsShared->dataLastCommit.time;
+ *ts = commitTsShared->dataLastCommit.time;
if (nodeid)
*nodeid = commitTsShared->dataLastCommit.nodeid;
@@ -330,8 +330,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
SizeOfCommitTimestampEntry * entryno,
SizeOfCommitTimestampEntry);
- if (ts)
- *ts = entry.time;
+ *ts = entry.time;
if (nodeid)
*nodeid = entry.nodeid;