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

Commit419b91c

Browse files
committed
Correct some comments, fix a small memory wastage when datatype
is pass-by-value.
1 parentbeb1851 commit419b91c

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

‎src/backend/executor/nodeAgg.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ static Datum aggGetAttr(TupleTableSlot *tuple, Aggref *aggref, bool *isNull);
6767
* value1[i] = initcond1
6868
* value2[i] = initcond2
6969
* forall tuples do
70-
*value1[i] = sfunc1(aggregate_attribute,value1[i])
70+
*value1[i] = sfunc1(value1[i], aggregated_value)
7171
*value2[i] = sfunc2(value2[i])
7272
* value1[i] = finalfunc(value1[i], value2[i])
7373
*
74+
* If initcond1 is NULL then the first non-NULL aggregated_value is
75+
* assigned directly to value1[i]. sfunc1 isn't applied until value1[i]
76+
* is non-NULL.
77+
*
7478
* If the outer subplan is a Group node, ExecAgg returns as many tuples
7579
* as there are groups.
7680
*
@@ -272,7 +276,6 @@ ExecAgg(Agg *node)
272276
{
273277
Aggref*aggref=lfirst(alist);
274278
AttrNumberattnum;
275-
int2attlen=0;
276279
DatumnewVal= (Datum)NULL;
277280
AggFuncInfo*aggfns=&aggFuncInfo[++aggno];
278281
Datumargs[2];
@@ -309,6 +312,7 @@ ExecAgg(Agg *node)
309312
{
310313
if (noInitValue[aggno])
311314
{
315+
intattlen=0;
312316
intbyVal=0;
313317

314318
/*
@@ -352,16 +356,16 @@ ExecAgg(Agg *node)
352356
default:
353357
elog(ERROR,"ExecAgg: Bad Agg->Target for Agg %d",aggno);
354358
}
355-
if (attlen==-1)
356-
{
357-
/* variable length */
358-
attlen=VARSIZE((structvarlena*)newVal);
359-
}
360-
value1[aggno]= (Datum)palloc(attlen);
361359
if (byVal)
362360
value1[aggno]=newVal;
363361
else
364-
memmove((char*) (value1[aggno]), (char*)newVal,attlen);
362+
{
363+
if (attlen==-1)/* variable length */
364+
attlen=VARSIZE((structvarlena*)newVal);
365+
value1[aggno]= (Datum)palloc(attlen);
366+
memcpy((char*) (value1[aggno]), (char*)newVal,
367+
attlen);
368+
}
365369
noInitValue[aggno]=0;
366370
nulls[aggno]=0;
367371
}
@@ -380,10 +384,9 @@ ExecAgg(Agg *node)
380384

381385
if (aggfns->xfn2.fn_addr!=NULL)
382386
{
383-
Datumxfn2_val=value2[aggno];
384-
387+
args[0]=value2[aggno];
385388
value2[aggno]=(Datum)fmgr_c(&aggfns->xfn2,
386-
(FmgrValues*)&xfn2_val,&isNull2);
389+
(FmgrValues*)args,&isNull2);
387390
Assert(!isNull2);
388391
}
389392
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp