diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-08-10 11:48:42 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-08-10 11:48:42 -0400 |
commit | 0b7ba3d6474b8f58e74dba548886df3250805cdf (patch) | |
tree | cd3ba2bd478e28d14d2aa1d3a255a5be397fdc89 | |
parent | ec99dd5aee8b831760046d43098c2d1cf23157ed (diff) | |
download | postgresql-0b7ba3d6474b8f58e74dba548886df3250805cdf.tar.gz postgresql-0b7ba3d6474b8f58e74dba548886df3250805cdf.zip |
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
-rw-r--r-- | contrib/pgstattuple/pgstatindex.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c index 44e322d1f9a..9365ba7e02c 100644 --- a/contrib/pgstattuple/pgstatindex.c +++ b/contrib/pgstattuple/pgstatindex.c @@ -687,13 +687,14 @@ pgstathashindex(PG_FUNCTION_ARGS) index_close(rel, AccessShareLock); /* Count unused pages as free space. */ - stats.free_space += stats.unused_pages * stats.space_per_page; + stats.free_space += (uint64) stats.unused_pages * stats.space_per_page; /* * Total space available for tuples excludes the metapage and the bitmap * pages. */ - total_space = (nblocks - (stats.bitmap_pages + 1)) * stats.space_per_page; + total_space = (uint64) (nblocks - (stats.bitmap_pages + 1)) * + stats.space_per_page; if (total_space == 0) free_percent = 0.0; |