]> granicus.if.org Git - postgresql/commit
Avoid unexpected conversion overflow in planner for distant date values.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 29 Dec 2010 03:49:57 +0000 (22:49 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 29 Dec 2010 03:50:44 +0000 (22:50 -0500)
commitdcb2b356b01a2c7192f507c3570e6b5bbad93c24
tree011ae8e9bcdf1763da77673fd1e4467e8a30de45
parenta6a77ae407be6decaf4d630b546bc66a6737216c
Avoid unexpected conversion overflow in planner for distant date values.

The "date" type supports a wider range of dates than int64 timestamps do.
However, there is pre-int64-timestamp code in the planner that assumes that
all date values can be converted to timestamp with impunity.  Fortunately,
what we really need out of the conversion is always a double (float8)
value; so even when the date is out of timestamp's range it's possible to
produce a sane answer.  All we need is a code path that doesn't try to
force the result into int64.  Per trouble report from David Rericha.

Back-patch to all supported versions.  Although this is surely a corner
case, there's not much point in advertising a date range wider than
timestamp's if we will choke on such values in unexpected places.
src/backend/utils/adt/date.c
src/backend/utils/adt/selfuncs.c
src/include/utils/date.h