Commit fb4bb8b9 authored by Bruce Momjian's avatar Bruce Momjian

Fix integral timestamps so the output is consistent in all cases to

round:

	select interval '0:0:0.7', interval '@ 0.70 secs', interval '0.7
		seconds';

Ron Mayer
parent 83c31214
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.193 2008/09/16 22:31:21 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.194 2008/09/24 19:46:44 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2888,7 +2888,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, ...@@ -2888,7 +2888,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
{ {
case DTK_MICROSEC: case DTK_MICROSEC:
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
*fsec += val + fval; *fsec += rint(val + fval);
#else #else
*fsec += (val + fval) * 1e-6; *fsec += (val + fval) * 1e-6;
#endif #endif
...@@ -2897,7 +2897,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, ...@@ -2897,7 +2897,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
case DTK_MILLISEC: case DTK_MILLISEC:
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
*fsec += (val + fval) * 1000; *fsec += rint((val + fval) * 1000);
#else #else
*fsec += (val + fval) * 1e-3; *fsec += (val + fval) * 1e-3;
#endif #endif
...@@ -2907,7 +2907,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, ...@@ -2907,7 +2907,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
case DTK_SECOND: case DTK_SECOND:
tm->tm_sec += val; tm->tm_sec += val;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
*fsec += fval * 1000000; *fsec += rint(fval * 1000000);
#else #else
*fsec += fval; *fsec += fval;
#endif #endif
...@@ -2932,7 +2932,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, ...@@ -2932,7 +2932,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
sec = fval; sec = fval;
tm->tm_sec += sec; tm->tm_sec += sec;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
*fsec += (fval - sec) * 1000000; *fsec += rint((fval - sec) * 1000000);
#else #else
*fsec += fval - sec; *fsec += fval - sec;
#endif #endif
...@@ -2950,7 +2950,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, ...@@ -2950,7 +2950,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
sec = fval; sec = fval;
tm->tm_sec += sec; tm->tm_sec += sec;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
*fsec += (fval - sec) * 1000000; *fsec += rint((fval - sec) * 1000000);
#else #else
*fsec += fval - sec; *fsec += fval - sec;
#endif #endif
...@@ -2969,7 +2969,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, ...@@ -2969,7 +2969,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
sec = fval; sec = fval;
tm->tm_sec += sec; tm->tm_sec += sec;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
*fsec += (fval - sec) * 1000000; *fsec += rint((fval - sec) * 1000000);
#else #else
*fsec += fval - sec; *fsec += fval - sec;
#endif #endif
...@@ -2995,7 +2995,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, ...@@ -2995,7 +2995,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
sec = fval; sec = fval;
tm->tm_sec += sec; tm->tm_sec += sec;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
*fsec += (fval - sec) * 1000000; *fsec += rint((fval - sec) * 1000000);
#else #else
*fsec += fval - sec; *fsec += fval - sec;
#endif #endif
...@@ -3022,7 +3022,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, ...@@ -3022,7 +3022,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
sec = fval; sec = fval;
tm->tm_sec += sec; tm->tm_sec += sec;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
*fsec += (fval - sec) * 1000000; *fsec += rint((fval - sec) * 1000000);
#else #else
*fsec += fval - sec; *fsec += fval - sec;
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment