refactor CoordinatedTransactionCallback (#3571)

pull/3582/head
SaitTalhaNisanci 2020-03-05 18:36:12 +03:00 committed by GitHub
parent 6e6763678c
commit a75436a54b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 14 deletions

View File

@ -110,6 +110,7 @@ static void PushSubXact(SubTransactionId subId);
static void PopSubXact(SubTransactionId subId);
static void SwallowErrors(void (*func)());
static bool MaybeExecutingUDF(void);
static void ResetGlobalVariables(void);
/*
@ -248,13 +249,7 @@ CoordinatedTransactionCallback(XactEvent event, void *arg)
AfterXactConnectionHandling(true);
}
CurrentCoordinatedTransactionState = COORD_TRANS_NONE;
XactModificationLevel = XACT_MODIFICATION_NONE;
TransactionAccessedLocalPlacement = false;
TransactionConnectedToLocalGroup = false;
dlist_init(&InProgressTransactions);
activeSetStmts = NULL;
CoordinatedTransactionUses2PC = false;
ResetGlobalVariables();
UnSetDistributedTransactionId();
@ -303,13 +298,7 @@ CoordinatedTransactionCallback(XactEvent event, void *arg)
AfterXactConnectionHandling(false);
}
CurrentCoordinatedTransactionState = COORD_TRANS_NONE;
XactModificationLevel = XACT_MODIFICATION_NONE;
TransactionAccessedLocalPlacement = false;
TransactionConnectedToLocalGroup = false;
dlist_init(&InProgressTransactions);
activeSetStmts = NULL;
CoordinatedTransactionUses2PC = false;
ResetGlobalVariables();
/*
* Getting here without ExecutorLevel 0 is a bug, however it is such a big
@ -446,6 +435,23 @@ CoordinatedTransactionCallback(XactEvent event, void *arg)
}
/*
* ResetGlobalVariables resets global variables that
* might be changed during the execution of queries.
*/
static void
ResetGlobalVariables()
{
CurrentCoordinatedTransactionState = COORD_TRANS_NONE;
XactModificationLevel = XACT_MODIFICATION_NONE;
TransactionAccessedLocalPlacement = false;
TransactionConnectedToLocalGroup = false;
dlist_init(&InProgressTransactions);
activeSetStmts = NULL;
CoordinatedTransactionUses2PC = false;
}
/*
* ResetShardPlacementTransactionState performs cleanup after the end of a
* transaction.