From faab7a957d31389f4abfd83784f622c91d076f49 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 9 Jan 2014 12:59:55 -0500 Subject: [PATCH] Remove unnecessary local variables to work around an icc optimization bug. Buildfarm member dunlin has been crashing since commit 8b49a60, but other machines seem fine with that code. It turns out that removing the local variables in ordered_set_startup() that are copies of fields in "qstate" dodges the problem. This might cost a few cycles on register-rich machines, but it's probably a wash on others, and in any case this code isn't performance-critical. Thanks to Jeremy Drake for off-list investigation. --- src/backend/utils/adt/orderedsetaggs.c | 40 ++++++++++---------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/src/backend/utils/adt/orderedsetaggs.c b/src/backend/utils/adt/orderedsetaggs.c index 216c498a2f..e5324e2869 100644 --- a/src/backend/utils/adt/orderedsetaggs.c +++ b/src/backend/utils/adt/orderedsetaggs.c @@ -159,27 +159,17 @@ ordered_set_startup(FunctionCallInfo fcinfo, bool use_tuples) if (use_tuples) { bool ishypothetical = (aggref->aggkind == AGGKIND_HYPOTHETICAL); - AttrNumber *sortColIdx; - Oid *sortOperators; - Oid *eqOperators; - Oid *sortCollations; - bool *sortNullsFirsts; ListCell *lc; int i; if (ishypothetical) numSortCols++; /* make space for flag column */ qstate->numSortCols = numSortCols; - qstate->sortColIdx = sortColIdx = - (AttrNumber *) palloc(numSortCols * sizeof(AttrNumber)); - qstate->sortOperators = sortOperators = - (Oid *) palloc(numSortCols * sizeof(Oid)); - qstate->eqOperators = eqOperators = - (Oid *) palloc(numSortCols * sizeof(Oid)); - qstate->sortCollations = sortCollations = - (Oid *) palloc(numSortCols * sizeof(Oid)); - qstate->sortNullsFirsts = sortNullsFirsts = - (bool *) palloc(numSortCols * sizeof(bool)); + qstate->sortColIdx = (AttrNumber *) palloc(numSortCols * sizeof(AttrNumber)); + qstate->sortOperators = (Oid *) palloc(numSortCols * sizeof(Oid)); + qstate->eqOperators = (Oid *) palloc(numSortCols * sizeof(Oid)); + qstate->sortCollations = (Oid *) palloc(numSortCols * sizeof(Oid)); + qstate->sortNullsFirsts = (bool *) palloc(numSortCols * sizeof(bool)); i = 0; foreach(lc, sortlist) @@ -191,22 +181,22 @@ ordered_set_startup(FunctionCallInfo fcinfo, bool use_tuples) /* the parser should have made sure of this */ Assert(OidIsValid(sortcl->sortop)); - sortColIdx[i] = tle->resno; - sortOperators[i] = sortcl->sortop; - eqOperators[i] = sortcl->eqop; - sortCollations[i] = exprCollation((Node *) tle->expr); - sortNullsFirsts[i] = sortcl->nulls_first; + qstate->sortColIdx[i] = tle->resno; + qstate->sortOperators[i] = sortcl->sortop; + qstate->eqOperators[i] = sortcl->eqop; + qstate->sortCollations[i] = exprCollation((Node *) tle->expr); + qstate->sortNullsFirsts[i] = sortcl->nulls_first; i++; } if (ishypothetical) { /* Add an integer flag column as the last sort column */ - sortColIdx[i] = list_length(aggref->args) + 1; - sortOperators[i] = Int4LessOperator; - eqOperators[i] = Int4EqualOperator; - sortCollations[i] = InvalidOid; - sortNullsFirsts[i] = false; + qstate->sortColIdx[i] = list_length(aggref->args) + 1; + qstate->sortOperators[i] = Int4LessOperator; + qstate->eqOperators[i] = Int4EqualOperator; + qstate->sortCollations[i] = InvalidOid; + qstate->sortNullsFirsts[i] = false; i++; } -- 2.40.0