Skip to content

Commit 1e87198

Browse files
committed
Fix division by zero in _bt_vacuum_needs_cleanup()
Checks inside _bt_vacuum_needs_cleanup() allow division by zero to happen when metad->btm_last_cleanup_num_heap_tuples == 0. This commit adjusts the expression so that no division by zero might happen. Reported-by: Piotr Stefaniak Discussion: https://postgr.es/m/DB8PR03MB5931C41F7787A95313F08322F22A0%40DB8PR03MB5931.eurprd03.prod.outlook.com Reviewed-by: Masahiko Sawada Backpatch-through: 11
1 parent 3a45321 commit 1e87198

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/access/nbtree/nbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ _bt_vacuum_needs_cleanup(IndexVacuumInfo *info)
835835
prev_num_heap_tuples = metad->btm_last_cleanup_num_heap_tuples;
836836

837837
if (cleanup_scale_factor <= 0 ||
838-
prev_num_heap_tuples < 0 ||
838+
prev_num_heap_tuples <= 0 ||
839839
(info->num_heap_tuples - prev_num_heap_tuples) /
840840
prev_num_heap_tuples >= cleanup_scale_factor)
841841
result = true;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy