]> granicus.if.org Git - postgresql/commit
Fix array size allocation for HashAggregate hash keys.
authorAndrew Gierth <rhodiumtoad@postgresql.org>
Thu, 23 May 2019 14:26:01 +0000 (15:26 +0100)
committerAndrew Gierth <rhodiumtoad@postgresql.org>
Thu, 23 May 2019 14:39:17 +0000 (15:39 +0100)
commit99efd8d727b0662e152daa2ccd1dcc668ac36056
treee65b52c315fbdda551672fe56d5d13e56541398d
parent2ccebcd23689779b97db1375d038b50bed8dcd68
Fix array size allocation for HashAggregate hash keys.

When there were duplicate columns in the hash key list, the array
sizes could be miscomputed, resulting in access off the end of the
array. Adjust the computation to ensure the array is always large
enough.

(I considered whether the duplicates could be removed in planning, but
I can't rule out the possibility that duplicate columns might have
different hash functions assigned. Simpler to just make sure it works
at execution time regardless.)

Bug apparently introduced in fc4b3dea2 as part of narrowing down the
tuples stored in the hashtable. Reported by Colm McHugh of Salesforce,
though I didn't use their patch. Backpatch back to version 10 where
the bug was introduced.

Discussion: https://postgr.es/m/CAFeeJoKKu0u+A_A9R9316djW-YW3-+Gtgvy3ju655qRHR3jtdA@mail.gmail.com
src/backend/executor/nodeAgg.c
src/test/regress/expected/aggregates.out
src/test/regress/sql/aggregates.sql