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

Commit4fe1a12

Browse files
committed
Remove rint() for to_char MS and US output. We can't us rint() because
we can't overflow to the next higher units, and we might print the lowerunits for MS.
1 parent37a2293 commit4fe1a12

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -----------------------------------------------------------------------
22
* formatting.c
33
*
4-
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.127 2007/02/1701:51:42 momjian Exp $
4+
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.128 2007/02/1703:11:32 momjian Exp $
55
*
66
*
77
* Portions Copyright (c) 1999-2007, PostgreSQL Global Development Group
@@ -2000,7 +2000,8 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval,
20002000
#ifdefHAVE_INT64_TIMESTAMP
20012001
sprintf(inout,"%03d", (int) (tmtc->fsec /INT64CONST(1000)));
20022002
#else
2003-
sprintf(inout,"%03d", (int)rint(tmtc->fsec*1000));
2003+
/* No rint() because we can't overflow and we might print US */
2004+
sprintf(inout,"%03d", (int) (tmtc->fsec*1000));
20042005
#endif
20052006
if (S_THth(suf))
20062007
str_numth(p_inout,inout,S_TH_TYPE(suf));
@@ -2041,7 +2042,8 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval,
20412042
#ifdefHAVE_INT64_TIMESTAMP
20422043
sprintf(inout,"%06d", (int)tmtc->fsec);
20432044
#else
2044-
sprintf(inout,"%06d", (int)rint(tmtc->fsec*1000000));
2045+
/* don't use rint() because we can't overflow 1000 */
2046+
sprintf(inout,"%06d", (int) (tmtc->fsec*1000000));
20452047
#endif
20462048
if (S_THth(suf))
20472049
str_numth(p_inout,inout,S_TH_TYPE(suf));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp