|
1 | 1 | /* -----------------------------------------------------------------------
|
2 | 2 | * formatting.c
|
3 | 3 | *
|
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 $ |
5 | 5 | *
|
6 | 6 | *
|
7 | 7 | * 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,
|
2000 | 2000 | #ifdef HAVE_INT64_TIMESTAMP
|
2001 | 2001 | sprintf(inout, "%03d", (int) (tmtc->fsec / INT64CONST(1000)));
|
2002 | 2002 | #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)); |
2004 | 2005 | #endif
|
2005 | 2006 | if (S_THth(suf))
|
2006 | 2007 | 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,
|
2041 | 2042 | #ifdef HAVE_INT64_TIMESTAMP
|
2042 | 2043 | sprintf(inout, "%06d", (int) tmtc->fsec);
|
2043 | 2044 | #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)); |
2045 | 2047 | #endif
|
2046 | 2048 | if (S_THth(suf))
|
2047 | 2049 | str_numth(p_inout, inout, S_TH_TYPE(suf));
|
|
0 commit comments