]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid misbehavior when hash_table_bytes < bucket_size.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 13 Aug 2022 20:59:58 +0000 (16:59 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 13 Aug 2022 20:59:58 +0000 (16:59 -0400)
commit4878ea717c7166e3453cb94796a2044837bf1d2b
treed0f25115375f52501541d504bb6259f6c063f226
parent60f876317efc7b9ad624b11ae2f4b8208e408ef4
Avoid misbehavior when hash_table_bytes < bucket_size.

It's possible to reach this case when work_mem is very small and tupsize
is (relatively) very large.  In that case ExecChooseHashTableSize would
get an assertion failure, or with asserts off it'd compute nbuckets = 0,
which'd likely cause misbehavior later (I've not checked).  To fix,
clamp the number of buckets to be at least 1.

This is due to faulty conversion of old my_log2() coding in 28d936031.
Back-patch to v13, as that was.

Zhang Mingli

Discussion: https://postgr.es/m/beb64ca0-91e2-44ac-bf4a-7ea36275ec02@Spark
src/backend/executor/nodeHash.c