]> granicus.if.org Git - postgresql/commitdiff
Remove unnecessary local variables to work around an icc optimization bug.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Jan 2014 17:59:55 +0000 (12:59 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Jan 2014 17:59:55 +0000 (12:59 -0500)
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

index 216c498a2f18775175bcc3eb6ab6263ee68afe5f..e5324e28699d41bef23673e77c78f0503681325e 100644 (file)
@@ -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++;
                        }