Skip to content

Commit 4fe1a12

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 lower units for MS.
1 parent 37a2293 commit 4fe1a12

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/17 01:51:42 momjian Exp $
4+
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.128 2007/02/17 03: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
#ifdef HAVE_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
#ifdef HAVE_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)
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