From d765999cd2446fa05ad9b53a5e87dd5480a9b55c Mon Sep 17 00:00:00 2001 From: Pengzhou Tang Date: Thu, 12 Mar 2020 04:38:36 -0400 Subject: [PATCH 3/7] fix a numtrans bug aggstate->numtrans is always zero when building the hash table for hash aggregates, this make the additional size of hash table not correct. --- src/backend/executor/nodeAgg.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index c3a043e448..f7af5eebd0 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -2570,10 +2570,6 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) { /* this is an array of pointers, not structures */ aggstate->hash_pergroup = pergroups; - - find_hash_columns(aggstate); - build_hash_tables(aggstate); - aggstate->table_filled = false; } /* @@ -2929,6 +2925,14 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) (errcode(ERRCODE_GROUPING_ERROR), errmsg("aggregate function calls cannot be nested"))); + /* Initialize hash tables for hash aggregates */ + if (use_hashing) + { + find_hash_columns(aggstate); + build_hash_tables(aggstate); + aggstate->table_filled = false; + } + /* * Build expressions doing all the transition work at once. We build a * different one for each phase, as the number of transition function -- 2.21.1