Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4878ea7

Browse files
committed
Avoid misbehavior when hash_table_bytes < bucket_size.
It's possible to reach this case when work_mem is very small and tupsizeis (relatively) very large. In that case ExecChooseHashTableSize wouldget 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 in28d9360.Back-patch to v13, as that was.Zhang MingliDiscussion:https://postgr.es/m/beb64ca0-91e2-44ac-bf4a-7ea36275ec02@Spark
1 parent60f8763 commit4878ea7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎src/backend/executor/nodeHash.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,10 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew,
832832
* overhead for the hash code, pointer to the next tuple, etc.
833833
*/
834834
bucket_size= (tupsize*NTUP_PER_BUCKET+sizeof(HashJoinTuple));
835-
sbuckets=pg_nextpower2_size_t(hash_table_bytes /bucket_size);
835+
if (hash_table_bytes <=bucket_size)
836+
sbuckets=1;/* avoid pg_nextpower2_size_t(0) */
837+
else
838+
sbuckets=pg_nextpower2_size_t(hash_table_bytes /bucket_size);
836839
sbuckets=Min(sbuckets,max_pointers);
837840
nbuckets= (int)sbuckets;
838841
nbuckets=pg_nextpower2_32(nbuckets);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp