Merge pull request #3372 from citusdata/dont-palloc-walkercontext

Replace ARRAY_OUT_FUNC_ID with postgres's F_ARRAY_OUT
pull/3375/head
Philip Dubé 2020-01-10 17:06:37 +00:00 committed by GitHub
commit f1a4b97450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 20 deletions

View File

@ -1409,11 +1409,10 @@ MasterExtendedOpNode(MultiExtendedOp *originalOpNode,
ListCell *targetEntryCell = NULL;
Node *originalHavingQual = originalOpNode->havingQual;
Node *newHavingQual = NULL;
MasterAggregateWalkerContext *walkerContext = palloc0(
sizeof(MasterAggregateWalkerContext));
MasterAggregateWalkerContext walkerContext = { 0 };
walkerContext->extendedOpNodeProperties = extendedOpNodeProperties;
walkerContext->columnId = 1;
walkerContext.extendedOpNodeProperties = extendedOpNodeProperties;
walkerContext.columnId = 1;
/* iterate over original target entries */
foreach(targetEntryCell, targetEntryList)
@ -1434,7 +1433,7 @@ MasterExtendedOpNode(MultiExtendedOp *originalOpNode,
!extendedOpNodeProperties->groupedByDisjointPartitionColumn)
{
Node *newNode = MasterAggregateMutator((Node *) originalExpression,
walkerContext);
&walkerContext);
newExpression = (Expr *) newNode;
}
else
@ -1447,9 +1446,9 @@ MasterExtendedOpNode(MultiExtendedOp *originalOpNode,
const uint32 masterTableId = 1; /* only one table on master node */
Var *column = makeVarFromTargetEntry(masterTableId, originalTargetEntry);
column->varattno = walkerContext->columnId;
column->varoattno = walkerContext->columnId;
walkerContext->columnId++;
column->varattno = walkerContext.columnId;
column->varoattno = walkerContext.columnId;
walkerContext.columnId++;
if (column->vartype == RECORDOID || column->vartype == RECORDARRAYOID)
{
@ -1473,7 +1472,7 @@ MasterExtendedOpNode(MultiExtendedOp *originalOpNode,
if (originalHavingQual != NULL)
{
newHavingQual = MasterAggregateMutator(originalHavingQual, walkerContext);
newHavingQual = MasterAggregateMutator(originalHavingQual, &walkerContext);
}
}
@ -2309,11 +2308,10 @@ ProcessTargetListForWorkerQuery(List *targetEntryList,
QueryGroupClause *queryGroupClause)
{
ListCell *targetEntryCell = NULL;
WorkerAggregateWalkerContext *workerAggContext =
palloc0(sizeof(WorkerAggregateWalkerContext));
WorkerAggregateWalkerContext workerAggContext = { 0 };
workerAggContext->extendedOpNodeProperties = extendedOpNodeProperties;
workerAggContext->expressionList = NIL;
workerAggContext.extendedOpNodeProperties = extendedOpNodeProperties;
workerAggContext.expressionList = NIL;
/* iterate over original target entries */
foreach(targetEntryCell, targetEntryList)
@ -2325,8 +2323,8 @@ ProcessTargetListForWorkerQuery(List *targetEntryList,
bool hasWindowFunction = contain_window_function((Node *) originalExpression);
/* reset walker context */
workerAggContext->expressionList = NIL;
workerAggContext->createGroupByClause = false;
workerAggContext.expressionList = NIL;
workerAggContext.createGroupByClause = false;
/*
* If the query has a window function, we currently assume it's safe to push
@ -2339,9 +2337,9 @@ ProcessTargetListForWorkerQuery(List *targetEntryList,
if (!hasWindowFunction && hasAggregates &&
!extendedOpNodeProperties->groupedByDisjointPartitionColumn)
{
WorkerAggregateWalker((Node *) originalExpression, workerAggContext);
WorkerAggregateWalker((Node *) originalExpression, &workerAggContext);
newExpressionList = workerAggContext->expressionList;
newExpressionList = workerAggContext.expressionList;
}
else
{
@ -2349,7 +2347,7 @@ ProcessTargetListForWorkerQuery(List *targetEntryList,
}
ExpandWorkerTargetEntry(newExpressionList, originalTargetEntry,
workerAggContext->createGroupByClause,
workerAggContext.createGroupByClause,
queryTargetList, queryGroupClause);
}
}

View File

@ -3953,7 +3953,7 @@ DatumArrayString(Datum *datumArray, uint32 datumCount, Oid datumTypeId)
/* convert the array object to its string representation */
FmgrInfo *arrayOutFunction = (FmgrInfo *) palloc0(sizeof(FmgrInfo));
fmgr_info(ARRAY_OUT_FUNC_ID, arrayOutFunction);
fmgr_info(F_ARRAY_OUT, arrayOutFunction);
Datum arrayStringDatum = FunctionCall1(arrayOutFunction, arrayObjectDatum);
char *arrayString = DatumGetCString(arrayStringDatum);

View File

@ -30,7 +30,6 @@
/* Definitions local to the physical planner */
#define ARRAY_OUT_FUNC_ID 751
#define NON_PRUNABLE_JOIN -1
#define RESERVED_HASHED_COLUMN_ID MaxAttrNumber
#define MERGE_COLUMN_FORMAT "merge_column_%u"