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

Commit47386fe

Browse files
committed
Use floor() not rint() when reducing precision of fractional seconds in
timestamp_trunc, timestamptz_trunc, and interval_trunc(). This changeonly affects the float-datetime case; the integer-datetime case alreadybehaved like truncation instead of rounding. Per gripe from Mario Splivalo.This is a pre-existing issue but I'm choosing not to backpatch, becauseit's such a corner case and there have not been prior complaints. Theissue is largely moot anyway given the trend towards integer datetimes.
1 parent44886bd commit47386fe

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.201 2009/06/11 14:49:04 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.202 2009/07/06 20:29:23 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3338,13 +3338,13 @@ timestamp_trunc(PG_FUNCTION_ARGS)
33383338
#ifdefHAVE_INT64_TIMESTAMP
33393339
fsec= (fsec /1000)*1000;
33403340
#else
3341-
fsec=rint(fsec*1000) /1000;
3341+
fsec=floor(fsec*1000) /1000;
33423342
#endif
33433343
break;
33443344

33453345
caseDTK_MICROSEC:
33463346
#ifndefHAVE_INT64_TIMESTAMP
3347-
fsec=rint(fsec*1000000) /1000000;
3347+
fsec=floor(fsec*1000000) /1000000;
33483348
#endif
33493349
break;
33503350

@@ -3494,12 +3494,12 @@ timestamptz_trunc(PG_FUNCTION_ARGS)
34943494
#ifdefHAVE_INT64_TIMESTAMP
34953495
fsec= (fsec /1000)*1000;
34963496
#else
3497-
fsec=rint(fsec*1000) /1000;
3497+
fsec=floor(fsec*1000) /1000;
34983498
#endif
34993499
break;
35003500
caseDTK_MICROSEC:
35013501
#ifndefHAVE_INT64_TIMESTAMP
3502-
fsec=rint(fsec*1000000) /1000000;
3502+
fsec=floor(fsec*1000000) /1000000;
35033503
#endif
35043504
break;
35053505

@@ -3591,12 +3591,12 @@ interval_trunc(PG_FUNCTION_ARGS)
35913591
#ifdefHAVE_INT64_TIMESTAMP
35923592
fsec= (fsec /1000)*1000;
35933593
#else
3594-
fsec=rint(fsec*1000) /1000;
3594+
fsec=floor(fsec*1000) /1000;
35953595
#endif
35963596
break;
35973597
caseDTK_MICROSEC:
35983598
#ifndefHAVE_INT64_TIMESTAMP
3599-
fsec=rint(fsec*1000000) /1000000;
3599+
fsec=floor(fsec*1000000) /1000000;
36003600
#endif
36013601
break;
36023602

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp