Exclude localPlannedStatements from copy distributedPlan

pull/3388/head
Onder Kalaci 2020-01-14 10:09:16 +01:00 committed by Onder Kalaci
parent ff12df411b
commit 5dc454cdad
1 changed files with 11 additions and 0 deletions

View File

@ -224,10 +224,21 @@ CitusGenerateDeferredQueryStrings(CustomScanState *node, EState *estate, int efl
* We must not change the distributed plan since it may be reused across multiple
* executions of a prepared statement. Instead we create a deep copy that we only
* use for the current execution.
*
* We also exclude localPlannedStatements from the copyObject call for performance
* reasons, as they are immutable, so no need to have a deep copy.
*/
DistributedPlan *originalDistributedPlan = scanState->distributedPlan;
List *localPlannedStatements = originalDistributedPlan->workerJob->localPlannedStatements;
originalDistributedPlan->workerJob->localPlannedStatements = NIL;
DistributedPlan *distributedPlan = copyObject(scanState->distributedPlan);
scanState->distributedPlan = distributedPlan;
/* set back the immutable field */
originalDistributedPlan->workerJob->localPlannedStatements = localPlannedStatements;
distributedPlan->workerJob->localPlannedStatements = localPlannedStatements;
Job *workerJob = distributedPlan->workerJob;
Query *jobQuery = workerJob->jobQuery;