Make extract() do something more reasonable with infinite datetimes.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 647d87c56ab6da70adb753c08d7cdf7ee905ea8a
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2016-01-22T03:26:20Z
Releases: 9.6.0
Make extract() do something more reasonable with infinite datetimes.

Historically, extract() just returned zero for any case involving an
infinite timestamp[tz] input; even cases in which the unit name was
invalid.  This is not very sensible.  Instead, return infinity or
-infinity as appropriate when the requested field is one that is
monotonically increasing (e.g, year, epoch), or NULL when it is not
(e.g., day, hour).  Also, throw the expected errors for bad unit names.

BACKWARDS INCOMPATIBLE CHANGE

Vitaly Burovoy, reviewed by Vik Fearing

Files

PathChange+/−
doc/src/sgml/func.sgml modified +11 −0
src/backend/utils/adt/timestamp.c modified +99 −12
src/test/regress/expected/date.out modified +242 −0
src/test/regress/sql/date.sql modified +53 −0

Documentation touched