diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-07-06 20:29:23 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-07-06 20:29:23 +0000 |
commit | 47386fed461d7726743de39efa2da042eca22575 (patch) | |
tree | d9d4cf1266d36f0d60e53a7406710974651a4b70 /src | |
parent | 44886bd878a2098d7bef6413e669d4ec59b17f71 (diff) | |
download | postgresql-47386fed461d7726743de39efa2da042eca22575.tar.gz postgresql-47386fed461d7726743de39efa2da042eca22575.zip |
Use floor() not rint() when reducing precision of fractional seconds in
timestamp_trunc, timestamptz_trunc, and interval_trunc(). This change
only affects the float-datetime case; the integer-datetime case already
behaved like truncation instead of rounding. Per gripe from Mario Splivalo.
This is a pre-existing issue but I'm choosing not to backpatch, because
it's such a corner case and there have not been prior complaints. The
issue is largely moot anyway given the trend towards integer datetimes.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index f4687d4ea9c..9c020f2d10a 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.201 2009/06/11 14:49:04 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.202 2009/07/06 20:29:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3338,13 +3338,13 @@ timestamp_trunc(PG_FUNCTION_ARGS) #ifdef HAVE_INT64_TIMESTAMP fsec = (fsec / 1000) * 1000; #else - fsec = rint(fsec * 1000) / 1000; + fsec = floor(fsec * 1000) / 1000; #endif break; case DTK_MICROSEC: #ifndef HAVE_INT64_TIMESTAMP - fsec = rint(fsec * 1000000) / 1000000; + fsec = floor(fsec * 1000000) / 1000000; #endif break; @@ -3494,12 +3494,12 @@ timestamptz_trunc(PG_FUNCTION_ARGS) #ifdef HAVE_INT64_TIMESTAMP fsec = (fsec / 1000) * 1000; #else - fsec = rint(fsec * 1000) / 1000; + fsec = floor(fsec * 1000) / 1000; #endif break; case DTK_MICROSEC: #ifndef HAVE_INT64_TIMESTAMP - fsec = rint(fsec * 1000000) / 1000000; + fsec = floor(fsec * 1000000) / 1000000; #endif break; @@ -3591,12 +3591,12 @@ interval_trunc(PG_FUNCTION_ARGS) #ifdef HAVE_INT64_TIMESTAMP fsec = (fsec / 1000) * 1000; #else - fsec = rint(fsec * 1000) / 1000; + fsec = floor(fsec * 1000) / 1000; #endif break; case DTK_MICROSEC: #ifndef HAVE_INT64_TIMESTAMP - fsec = rint(fsec * 1000000) / 1000000; + fsec = floor(fsec * 1000000) / 1000000; #endif break; |