Refactor: use a temporary timestamp variable

It's against our coding convention to call functions inside parameter
lists; when single-stepping with a debugger it's difficult to determine
what the function returned.

That wouldn't be good enough reason to change this code but while
porting Citus to Windows I ran into this line of code.
assign_distributed_transaction_id was called with a weird timestamp and
I wasn't able to find the problem without first making this change.
pull/1983/head
Brian Cloutier 2017-11-03 17:51:42 -07:00 committed by Brian Cloutier
parent 0303dfc463
commit 61a6b846b9
1 changed files with 3 additions and 1 deletions

View File

@ -62,6 +62,7 @@ StartRemoteTransactionBegin(struct MultiConnection *connection)
DistributedTransactionId *distributedTransactionId = NULL; DistributedTransactionId *distributedTransactionId = NULL;
ListCell *subIdCell = NULL; ListCell *subIdCell = NULL;
List *activeSubXacts = NIL; List *activeSubXacts = NIL;
const char *timestamp = NULL;
Assert(transaction->transactionState == REMOTE_TRANS_INVALID); Assert(transaction->transactionState == REMOTE_TRANS_INVALID);
@ -84,12 +85,13 @@ StartRemoteTransactionBegin(struct MultiConnection *connection)
* seperate roundtrips for these two statements. * seperate roundtrips for these two statements.
*/ */
distributedTransactionId = GetCurrentDistributedTransactionId(); distributedTransactionId = GetCurrentDistributedTransactionId();
timestamp = timestamptz_to_str(distributedTransactionId->timestamp);
appendStringInfo(beginAndSetDistributedTransactionId, appendStringInfo(beginAndSetDistributedTransactionId,
"SELECT assign_distributed_transaction_id(%d, " UINT64_FORMAT "SELECT assign_distributed_transaction_id(%d, " UINT64_FORMAT
", '%s');", ", '%s');",
distributedTransactionId->initiatorNodeIdentifier, distributedTransactionId->initiatorNodeIdentifier,
distributedTransactionId->transactionNumber, distributedTransactionId->transactionNumber,
timestamptz_to_str(distributedTransactionId->timestamp)); timestamp);
/* append in-progress savepoints for this transaction */ /* append in-progress savepoints for this transaction */
activeSubXacts = ActiveSubXacts(); activeSubXacts = ActiveSubXacts();