Skip to content

Commit 0b7ba3d

Browse files
committed
pgstatindex: Insert some casts to prevent overflow.
This could cause hash indexes to report greater than 100% free space. Ashutosh Sharma, reviewed by Amit Kapila Discussion: http://postgr.es/m/CAE9k0PnCKfg-ZK1CwGZJPF1yKcG2A=GUgC3BMdNMzLAXVOo4Eg@mail.gmail.com
1 parent ec99dd5 commit 0b7ba3d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

contrib/pgstattuple/pgstatindex.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,14 @@ pgstathashindex(PG_FUNCTION_ARGS)
687687
index_close(rel, AccessShareLock);
688688

689689
/* Count unused pages as free space. */
690-
stats.free_space += stats.unused_pages * stats.space_per_page;
690+
stats.free_space += (uint64) stats.unused_pages * stats.space_per_page;
691691

692692
/*
693693
* Total space available for tuples excludes the metapage and the bitmap
694694
* pages.
695695
*/
696-
total_space = (nblocks - (stats.bitmap_pages + 1)) * stats.space_per_page;
696+
total_space = (uint64) (nblocks - (stats.bitmap_pages + 1)) *
697+
stats.space_per_page;
697698

698699
if (total_space == 0)
699700
free_percent = 0.0;

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