Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd611ccb

Browse files
committed
fix for aggregates
1 parent2ae5d51 commitd611ccb

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

‎src/backend/executor/nodeAgg.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ ExecAgg(Agg *node)
129129
econtext=aggstate->csstate.cstate.cs_ExprContext;
130130

131131
nagg=length(node->aggs);
132-
132+
133133
value1=node->aggstate->csstate.cstate.cs_ExprContext->ecxt_values;
134134
nulls=node->aggstate->csstate.cstate.cs_ExprContext->ecxt_nulls;
135135

@@ -158,7 +158,7 @@ ExecAgg(Agg *node)
158158
xfn2_oid,
159159
finalfn_oid;
160160

161-
aggno++;
161+
aggref->aggno=++aggno;
162162

163163
/* ---------------------
164164
*find transfer functions of all the aggregates and initialize
@@ -252,14 +252,15 @@ ExecAgg(Agg *node)
252252
TupleDesctupType;
253253
Datum*tupValue;
254254
char*null_array;
255+
AttrNumberattnum;
255256

256257
tupType=aggstate->csstate.css_ScanTupleSlot->ttc_tupleDescriptor;
257258
tupValue=projInfo->pi_tupValue;
258259

259260
/* initially, set all the values to NULL */
260261
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';
263264
oneTuple=heap_formtuple(tupType,tupValue,null_array);
264265
pfree(null_array);
265266
}
@@ -328,8 +329,8 @@ ExecAgg(Agg *node)
328329
attnum= ((Var*)aggref->target)->varattno;
329330
attlen=outerslot->ttc_tupleDescriptor->attrs[attnum-1]->attlen;
330331
byVal=outerslot->ttc_tupleDescriptor->attrs[attnum-1]->attbyval;
331-
332332
break;
333+
333334
caseT_Expr:
334335
{
335336
FunctionCachePtrfcache_ptr;
@@ -340,8 +341,8 @@ ExecAgg(Agg *node)
340341
fcache_ptr= ((Oper*)tagnode)->op_fcache;
341342
attlen=fcache_ptr->typlen;
342343
byVal=fcache_ptr->typbyval;
343-
344344
break;
345+
345346
}
346347
caseT_Const:
347348
attlen= ((Const*)aggref->target)->constlen;
@@ -371,10 +372,8 @@ ExecAgg(Agg *node)
371372
*/
372373
args[0]=value1[aggno];
373374
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);
378377
Assert(!isNull1);
379378
}
380379
}
@@ -383,8 +382,7 @@ ExecAgg(Agg *node)
383382
{
384383
Datumxfn2_val=value2[aggno];
385384

386-
value2[aggno]=
387-
(Datum)fmgr_c(&aggfns->xfn2,
385+
value2[aggno]=(Datum)fmgr_c(&aggfns->xfn2,
388386
(FmgrValues*)&xfn2_val,&isNull2);
389387
Assert(!isNull2);
390388
}
@@ -481,9 +479,8 @@ ExecAgg(Agg *node)
481479
* As long as the retrieved group does not match the
482480
* qualifications it is ignored and the next group is fetched
483481
*/
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);
487484
elsequal_result= false;
488485

489486
if (oneTuple)
@@ -523,8 +520,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
523520
/*
524521
* assign node's base id and create expression context
525522
*/
526-
ExecAssignNodeBaseInfo(estate,&aggstate->csstate.cstate,
527-
(Plan*)parent);
523+
ExecAssignNodeBaseInfo(estate,&aggstate->csstate.cstate, (Plan*)parent);
528524
ExecAssignExprContext(estate,&aggstate->csstate.cstate);
529525

530526
#defineAGG_NSLOTS 2
@@ -536,8 +532,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
536532
ExecInitResultTupleSlot(estate,&aggstate->csstate.cstate);
537533

538534
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));
541536
MemSet(econtext->ecxt_values,0,sizeof(Datum)*length(node->aggs));
542537
econtext->ecxt_nulls= (char*)palloc(sizeof(char)*length(node->aggs));
543538
MemSet(econtext->ecxt_nulls,0,sizeof(char)*length(node->aggs));
@@ -665,8 +660,7 @@ aggGetAttr(TupleTableSlot *slot,
665660
return (Datum)tempSlot;
666661
}
667662

668-
result=
669-
heap_getattr(heapTuple,/* tuple containing attribute */
663+
result=heap_getattr(heapTuple,/* tuple containing attribute */
670664
attnum,/* attribute number of desired attribute */
671665
tuple_type,/* tuple descriptor of tuple */
672666
isNull);/* return: is attribute null? */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp