Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 36693c0

Browse files
committed
More agg cleanup.
1 parent 38a5bda commit 36693c0

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

src/backend/executor/nodeAgg.c

+18-20
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ ExecAgg(Agg *node)
117117
*/
118118

119119
/*
120-
* We loop retrieving groups until we find one matching
121-
* node->plan.qual
120+
* We loop retrieving groups until we find one matching node->plan.qual
122121
*/
123122
do
124123
{
@@ -141,14 +140,14 @@ ExecAgg(Agg *node)
141140
MemSet(aggFuncInfo, 0, sizeof(AggFuncInfo) * nagg);
142141

143142
noInitValue = (int *) palloc(sizeof(int) * nagg);
144-
MemSet(noInitValue, 0, sizeof(noInitValue) * nagg);
143+
MemSet(noInitValue, 0, sizeof(int) * nagg);
145144

146145
outerPlan = outerPlan(node);
147146
oneTuple = NULL;
148147

149148
projInfo = aggstate->csstate.cstate.cs_ProjInfo;
150149

151-
aggno = 0;
150+
aggno = -1;
152151
foreach(alist, node->aggs)
153152
{
154153
Aggref *aggref = lfirst(alist);
@@ -159,6 +158,8 @@ ExecAgg(Agg *node)
159158
xfn2_oid,
160159
finalfn_oid;
161160

161+
aggno++;
162+
162163
/* ---------------------
163164
* find transfer functions of all the aggregates and initialize
164165
* their initial values
@@ -226,7 +227,6 @@ ExecAgg(Agg *node)
226227
nulls[aggno] = 1;
227228
}
228229
}
229-
aggno++;
230230
}
231231

232232
/* ----------------
@@ -257,7 +257,7 @@ ExecAgg(Agg *node)
257257
tupValue = projInfo->pi_tupValue;
258258

259259
/* initially, set all the values to NULL */
260-
null_array = palloc(tupType->natts);
260+
null_array = palloc(sizeof(char) * tupType->natts);
261261
for (aggno = 0; aggno < tupType->natts; aggno++)
262262
null_array[aggno] = 'n';
263263
oneTuple = heap_formtuple(tupType, tupValue, null_array);
@@ -266,14 +266,14 @@ ExecAgg(Agg *node)
266266
break;
267267
}
268268

269-
aggno = 0;
269+
aggno = -1;
270270
foreach(alist, node->aggs)
271271
{
272272
Aggref *aggref = lfirst(alist);
273273
AttrNumber attnum;
274274
int2 attlen = 0;
275275
Datum newVal = (Datum) NULL;
276-
AggFuncInfo *aggfns = &aggFuncInfo[aggno];
276+
AggFuncInfo *aggfns = &aggFuncInfo[++aggno];
277277
Datum args[2];
278278
Node *tagnode = NULL;
279279

@@ -388,7 +388,6 @@ ExecAgg(Agg *node)
388388
(FmgrValues *) &xfn2_val, &isNull2);
389389
Assert(!isNull2);
390390
}
391-
aggno++;
392391
}
393392

394393
/*
@@ -407,11 +406,11 @@ ExecAgg(Agg *node)
407406
* --------------
408407
*/
409408

410-
aggno = 0;
409+
aggno = -1;
411410
foreach(alist, node->aggs)
412411
{
413412
char *args[2];
414-
AggFuncInfo *aggfns = &aggFuncInfo[aggno];
413+
AggFuncInfo *aggfns = &aggFuncInfo[++aggno];
415414

416415
if (noInitValue[aggno])
417416
{
@@ -450,7 +449,6 @@ ExecAgg(Agg *node)
450449
value1[aggno] = value2[aggno];
451450
else
452451
elog(ERROR, "ExecAgg: no valid transition functions??");
453-
aggno++;
454452
}
455453

456454
/*
@@ -539,10 +537,10 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
539537

540538
econtext = aggstate->csstate.cstate.cs_ExprContext;
541539
econtext->ecxt_values =
542-
(Datum *) palloc(sizeof(Datum) * length(node->aggs));
540+
(Datum *) palloc(sizeof(Datum) * length(node->aggs));
543541
MemSet(econtext->ecxt_values, 0, sizeof(Datum) * length(node->aggs));
544-
econtext->ecxt_nulls = (char *) palloc(length(node->aggs));
545-
MemSet(econtext->ecxt_nulls, 0, length(node->aggs));
542+
econtext->ecxt_nulls = (char *) palloc(sizeof(char) * length(node->aggs));
543+
MemSet(econtext->ecxt_nulls, 0, sizeof(char) * length(node->aggs));
546544

547545
/*
548546
* initializes child nodes
@@ -583,8 +581,8 @@ int
583581
ExecCountSlotsAgg(Agg *node)
584582
{
585583
return ExecCountSlotsNode(outerPlan(node)) +
586-
ExecCountSlotsNode(innerPlan(node)) +
587-
AGG_NSLOTS;
584+
ExecCountSlotsNode(innerPlan(node)) +
585+
AGG_NSLOTS;
588586
}
589587

590588
/* ------------------------
@@ -654,8 +652,8 @@ aggGetAttr(TupleTableSlot *slot,
654652
tempSlot = makeNode(TupleTableSlot);
655653
tempSlot->ttc_shouldFree = false;
656654
tempSlot->ttc_descIsNew = true;
657-
tempSlot->ttc_tupleDescriptor = (TupleDesc) NULL,
658-
tempSlot->ttc_buffer = InvalidBuffer;
655+
tempSlot->ttc_tupleDescriptor = (TupleDesc) NULL;
656+
tempSlot->ttc_buffer = InvalidBuffer;
659657
tempSlot->ttc_whichplan = -1;
660658

661659
tup = heap_copytuple(heapTuple);
@@ -691,7 +689,7 @@ ExecReScanAgg(Agg *node, ExprContext *exprCtxt, Plan *parent)
691689

692690
aggstate->agg_done = FALSE;
693691
MemSet(econtext->ecxt_values, 0, sizeof(Datum) * length(node->aggs));
694-
MemSet(econtext->ecxt_nulls, 0, length(node->aggs));
692+
MemSet(econtext->ecxt_nulls, 0, sizeof(char) * length(node->aggs));
695693

696694
/*
697695
* if chgParam of subnode is not null then plan will be re-scanned by

src/backend/parser/gram.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
*
240240
*
241241
* IDENTIFICATION
242-
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.63 1999/01/25 12:01:07 vadim Exp $
242+
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.64 1999/01/26 23:32:04 momjian Exp $
243243
*
244244
* HISTORY
245245
* AUTHOR DATE MAJOR EVENT
@@ -4791,7 +4791,7 @@ static const short yycheck[] = { 3,
47914791
-1, -1, -1, -1, -1, -1, -1, 214
47924792
};
47934793
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
4794-
#line 3 "/usr/share/misc/bison.simple"
4794+
#line 3 "/usr/local/bison/bison.simple"
47954795

47964796
/* Skeleton output parser for bison,
47974797
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
@@ -4984,7 +4984,7 @@ __yy_memcpy (char *to, char *from, int count)
49844984
#endif
49854985
#endif
49864986

4987-
#line 196 "/usr/share/misc/bison.simple"
4987+
#line 196 "/usr/local/bison/bison.simple"
49884988

49894989
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
49904990
into yyparse. The argument should have type void *.
@@ -11088,7 +11088,7 @@ case 960:
1108811088
break;}
1108911089
}
1109011090
/* the action file gets copied in in place of this dollarsign */
11091-
#line 498 "/usr/share/misc/bison.simple"
11091+
#line 498 "/usr/local/bison/bison.simple"
1109211092

1109311093
yyvsp -= yylen;
1109411094
yyssp -= yylen;

0 commit comments

Comments
 (0)