* Initialize all aggregate transition states for a new group of input values. * * If there are multiple grouping sets, we initialize only the first numReset * of them (the grouping sets are ordered so that the most specific one, which * is reset most often, is first). As a convenience, if numReset is 0, we * reinitialize all sets. * * NB: This cannot be used for hash aggregates, as for thos
| 699 | * When called, CurrentMemoryContext should be the per-query context. |
| 700 | */ |
| 701 | static void |
| 702 | initialize_aggregates(AggState *aggstate, |
| 703 | AggStatePerGroup *pergroups, |
| 704 | int numReset) |
| 705 | { |
| 706 | int transno; |
| 707 | int numGroupingSets = Max(aggstate->phase->numsets, 1); |
| 708 | int setno = 0; |
| 709 | int numTrans = aggstate->numtrans; |
| 710 | AggStatePerTrans transstates = aggstate->pertrans; |
| 711 | |
| 712 | if (numReset == 0) |
| 713 | numReset = numGroupingSets; |
| 714 | |
| 715 | for (setno = 0; setno < numReset; setno++) |
| 716 | { |
| 717 | AggStatePerGroup pergroup = pergroups[setno]; |
| 718 | |
| 719 | select_current_set(aggstate, setno, false); |
| 720 | |
| 721 | for (transno = 0; transno < numTrans; transno++) |
| 722 | { |
| 723 | AggStatePerTrans pertrans = &transstates[transno]; |
| 724 | AggStatePerGroup pergroupstate = &pergroup[transno]; |
| 725 | if (!bms_is_member(transno, aggstate->aggs_used)) |
| 726 | continue; |
| 727 | initialize_aggregate(aggstate, pertrans, pergroupstate); |
| 728 | } |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | /* |
| 733 | * Given new input value(s), advance the transition function of one aggregate |
no test coverage detected