@@ -129,7 +129,7 @@ ExecAgg(Agg *node)
129
129
econtext = aggstate -> csstate .cstate .cs_ExprContext ;
130
130
131
131
nagg = length (node -> aggs );
132
-
132
+
133
133
value1 = node -> aggstate -> csstate .cstate .cs_ExprContext -> ecxt_values ;
134
134
nulls = node -> aggstate -> csstate .cstate .cs_ExprContext -> ecxt_nulls ;
135
135
@@ -158,7 +158,7 @@ ExecAgg(Agg *node)
158
158
xfn2_oid ,
159
159
finalfn_oid ;
160
160
161
- aggno ++ ;
161
+ aggref -> aggno = ++ aggno ;
162
162
163
163
/* ---------------------
164
164
*find transfer functions of all the aggregates and initialize
@@ -252,14 +252,15 @@ ExecAgg(Agg *node)
252
252
TupleDesc tupType ;
253
253
Datum * tupValue ;
254
254
char * null_array ;
255
+ AttrNumber attnum ;
255
256
256
257
tupType = aggstate -> csstate .css_ScanTupleSlot -> ttc_tupleDescriptor ;
257
258
tupValue = projInfo -> pi_tupValue ;
258
259
259
260
/* initially, set all the values to NULL */
260
261
null_array = palloc (sizeof (char )* tupType -> natts );
261
- for (aggno = 0 ;aggno < tupType -> natts ;aggno ++ )
262
- null_array [aggno ]= 'n' ;
262
+ for (attnum = 0 ;attnum < tupType -> natts ;attnum ++ )
263
+ null_array [attnum ]= 'n' ;
263
264
oneTuple = heap_formtuple (tupType ,tupValue ,null_array );
264
265
pfree (null_array );
265
266
}
@@ -328,8 +329,8 @@ ExecAgg(Agg *node)
328
329
attnum = ((Var * )aggref -> target )-> varattno ;
329
330
attlen = outerslot -> ttc_tupleDescriptor -> attrs [attnum - 1 ]-> attlen ;
330
331
byVal = outerslot -> ttc_tupleDescriptor -> attrs [attnum - 1 ]-> attbyval ;
331
-
332
332
break ;
333
+
333
334
case T_Expr :
334
335
{
335
336
FunctionCachePtr fcache_ptr ;
@@ -340,8 +341,8 @@ ExecAgg(Agg *node)
340
341
fcache_ptr = ((Oper * )tagnode )-> op_fcache ;
341
342
attlen = fcache_ptr -> typlen ;
342
343
byVal = fcache_ptr -> typbyval ;
343
-
344
344
break ;
345
+
345
346
}
346
347
case T_Const :
347
348
attlen = ((Const * )aggref -> target )-> constlen ;
@@ -371,10 +372,8 @@ ExecAgg(Agg *node)
371
372
*/
372
373
args [0 ]= value1 [aggno ];
373
374
args [1 ]= newVal ;
374
- value1 [aggno ]=
375
- (Datum )fmgr_c (& aggfns -> xfn1 ,
376
- (FmgrValues * )args ,
377
- & isNull1 );
375
+ value1 [aggno ]= (Datum )fmgr_c (& aggfns -> xfn1 ,
376
+ (FmgrValues * )args ,& isNull1 );
378
377
Assert (!isNull1 );
379
378
}
380
379
}
@@ -383,8 +382,7 @@ ExecAgg(Agg *node)
383
382
{
384
383
Datum xfn2_val = value2 [aggno ];
385
384
386
- value2 [aggno ]=
387
- (Datum )fmgr_c (& aggfns -> xfn2 ,
385
+ value2 [aggno ]= (Datum )fmgr_c (& aggfns -> xfn2 ,
388
386
(FmgrValues * )& xfn2_val ,& isNull2 );
389
387
Assert (!isNull2 );
390
388
}
@@ -481,9 +479,8 @@ ExecAgg(Agg *node)
481
479
* As long as the retrieved group does not match the
482
480
* qualifications it is ignored and the next group is fetched
483
481
*/
484
- if (node -> plan .qual != NULL ){
485
- qual_result = ExecQual (fix_opids (node -> plan .qual ),econtext );
486
- }
482
+ if (node -> plan .qual != NULL )
483
+ qual_result = ExecQual (fix_opids (node -> plan .qual ),econtext );
487
484
else qual_result = false;
488
485
489
486
if (oneTuple )
@@ -523,8 +520,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
523
520
/*
524
521
* assign node's base id and create expression context
525
522
*/
526
- ExecAssignNodeBaseInfo (estate ,& aggstate -> csstate .cstate ,
527
- (Plan * )parent );
523
+ ExecAssignNodeBaseInfo (estate ,& aggstate -> csstate .cstate , (Plan * )parent );
528
524
ExecAssignExprContext (estate ,& aggstate -> csstate .cstate );
529
525
530
526
#define AGG_NSLOTS 2
@@ -536,8 +532,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
536
532
ExecInitResultTupleSlot (estate ,& aggstate -> csstate .cstate );
537
533
538
534
econtext = aggstate -> csstate .cstate .cs_ExprContext ;
539
- econtext -> ecxt_values =
540
- (Datum * )palloc (sizeof (Datum )* length (node -> aggs ));
535
+ econtext -> ecxt_values = (Datum * )palloc (sizeof (Datum )* length (node -> aggs ));
541
536
MemSet (econtext -> ecxt_values ,0 ,sizeof (Datum )* length (node -> aggs ));
542
537
econtext -> ecxt_nulls = (char * )palloc (sizeof (char )* length (node -> aggs ));
543
538
MemSet (econtext -> ecxt_nulls ,0 ,sizeof (char )* length (node -> aggs ));
@@ -665,8 +660,7 @@ aggGetAttr(TupleTableSlot *slot,
665
660
return (Datum )tempSlot ;
666
661
}
667
662
668
- result =
669
- heap_getattr (heapTuple ,/* tuple containing attribute */
663
+ result = heap_getattr (heapTuple ,/* tuple containing attribute */
670
664
attnum ,/* attribute number of desired attribute */
671
665
tuple_type ,/* tuple descriptor of tuple */
672
666
isNull );/* return: is attribute null? */