From 030754e8e7303b3044ed54a28d6f07fa2f56f5dc Mon Sep 17 00:00:00 2001 From: Pengzhou Tang Date: Thu, 12 Mar 2020 04:38:36 -0400 Subject: [PATCH 2/4] 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 b4f53bf77a..cee51fe636 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.14.1