diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index 73a6ad3280..aa4066f9f0 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -490,9 +490,15 @@ pg_size_pretty(PG_FUNCTION_ARGS) (size + mult / 2) / mult); else { + /* Here we have to worry about avoiding overflow */ + int64 val; + mult *= 1024; + val = size / mult; + if ((size % mult) >= (mult / 2)) + val++; snprintf(buf, sizeof(buf), INT64_FORMAT " TB", - (size + mult / 2) / mult); + val); } } }