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

Commitd3964cd

Browse files
committed
Fix pg_size_pretty() to avoid overflow for inputs close to INT64_MAX.
The expression that tried to round the value to the nearest TB couldoverflow, leading to bogus output as reported in bug #5993 from NicolaCossu. This isn't likely to ever happen in the intended usage of thefunction (if it could, we'd be needing to use a wider datatype instead);but it's not hard to give the expected output, so let's do so.
1 parent1e28982 commitd3964cd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎src/backend/utils/adt/dbsize.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,15 @@ pg_size_pretty(PG_FUNCTION_ARGS)
405405
(size+mult /2) /mult);
406406
else
407407
{
408+
/* Here we have to worry about avoiding overflow */
409+
int64val;
410+
408411
mult *=1024;
412+
val=size /mult;
413+
if ((size %mult) >= (mult /2))
414+
val++;
409415
snprintf(VARDATA(result),50,INT64_FORMAT" TB",
410-
(size+mult /2) /mult);
416+
val);
411417
}
412418
}
413419
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp