Fix time_part and timetz_part (ie, EXTRACT() for those datatypes) to
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 29 Jul 2009 22:19:18 +0000 (22:19 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 29 Jul 2009 22:19:18 +0000 (22:19 +0000)
commitc1374e3c277e272405bfa80949bae1d16b6b6747
tree0fcd22b810b22c582919020483bd54af1a7a72ac
parent576b0fac11e853810ac12ca47e9aa3a215ff7983
Fix time_part and timetz_part (ie, EXTRACT() for those datatypes) to
include a fractional part in the output for MILLISECOND and SECOND cases,
rather than truncating the source value.  This is what the float-timestamp
code has always done, and it was clearly the code author's intent to do
the same for integer timestamps, but he forgot about integer division in C.
The other datatypes supported by EXTRACT() already do this correctly.

Backpatch to 8.4, so that the default (integer) behavior of that branch will
match the default (float) behavior of older branches.  Arguably we should
patch further back, but it's possible that applications are expecting the
broken behavior in older branches.  8.4 is new enough that expectations
shouldn't be too settled.

Per report from Greg Stark.
src/backend/utils/adt/date.c