Skip to content

Commit c080b22

Browse files
committed
Fix minor oversights in nodeAgg.c.
aggstate->evalproj is always set up by ExecInitAgg, so there's no need to test. Doing so led Coverity to think that we might be intending "slot" to be possibly NULL here, and it quite properly complained that the rest of combine_aggregates() wasn't prepared for that. Also fix a couple of obvious thinkos in Asserts checking that "inputoff" isn't past the end of the slot. Errors introduced in commit 8ed3f11, so no need for back-patch.
1 parent 7d41a2b commit c080b22

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/backend/executor/nodeAgg.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ advance_aggregates(AggState *aggstate, AggStatePerGroup pergroup)
932932

933933
/* Load values into fcinfo */
934934
/* Start from 1, since the 0th arg will be the transition value */
935-
Assert(slot->tts_nvalid >= numTransInputs);
935+
Assert(slot->tts_nvalid >= (numTransInputs + inputoff));
936+
936937
for (i = 0; i < numTransInputs; i++)
937938
{
938939
fcinfo->arg[i + 1] = slot->tts_values[i + inputoff];
@@ -963,14 +964,13 @@ combine_aggregates(AggState *aggstate, AggStatePerGroup pergroup)
963964
{
964965
int transno;
965966
int numTrans = aggstate->numtrans;
966-
TupleTableSlot *slot = NULL;
967+
TupleTableSlot *slot;
967968

968969
/* combine not supported with grouping sets */
969970
Assert(aggstate->phase->numsets == 0);
970971

971972
/* compute input for all aggregates */
972-
if (aggstate->evalproj)
973-
slot = ExecProject(aggstate->evalproj, NULL);
973+
slot = ExecProject(aggstate->evalproj, NULL);
974974

975975
for (transno = 0; transno < numTrans; transno++)
976976
{
@@ -979,8 +979,7 @@ combine_aggregates(AggState *aggstate, AggStatePerGroup pergroup)
979979
FunctionCallInfo fcinfo = &pertrans->transfn_fcinfo;
980980
int inputoff = pertrans->inputoff;
981981

982-
Assert(slot->tts_nvalid >= 1);
983-
Assert(slot->tts_nvalid + inputoff >= 1);
982+
Assert(slot->tts_nvalid > inputoff);
984983

985984
/*
986985
* deserialfn_oid will be set if we must deserialize the input state

0 commit comments

Comments
 (0)