postgresql/src/backend
Tom Lane 5ed20a689e Prevent internal overflows in date-vs-timestamp and related comparisons.
The date-vs-timestamp, date-vs-timestamptz, and timestamp-vs-timestamptz
comparators all worked by promoting the first type to the second and
then doing a simple same-type comparison.  This works fine, except
when the conversion result is out of range, in which case we throw an
entirely avoidable error.  The sources of such failures are
(a) type date can represent dates much farther in the future than
the timestamp types can;
(b) timezone rotation might cause a just-in-range timestamp value to
become a just-out-of-range timestamptz value.

Up to now we just ignored these corner-case issues, but now we have
an actual user complaint (bug #16657 from Huss EL-Sheikh), so let's
do something about it.

It turns out that commit 52ad1e659 already built all the necessary
infrastructure to support error-free comparisons, but neglected to
actually use it in the main-line code paths.  Fix that, do a little
bit of code style review, and remove the now-duplicate logic in
jsonpath_exec.c.

Back-patch to v13 where 52ad1e659 came in.  We could take this back
further by back-patching said infrastructure, but given the small
number of complaints so far, I don't feel a great need to.

Discussion: https://postgr.es/m/16657-cde2f876d8cc7971@postgresql.org
2020-10-07 17:10:26 -04:00
..
access Fix missing fsync of SLRU directories. 2020-09-24 10:27:22 +12:00
bootstrap Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
catalog Update copyright year 2020-09-11 12:55:19 -03:00
commands Reword partitioning error message 2020-09-30 18:25:22 -03:00
executor Change LogicalTapeSetBlocks() to use nBlocksWritten. 2020-09-15 21:47:47 -07:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit Fix a few typos in JIT comments and README 2020-08-21 09:34:47 +12:00
lib Use pg_bitutils for HyperLogLog. 2020-07-30 09:17:00 -07:00
libpq Message fixes and style improvements 2020-09-14 06:42:07 +02:00
main Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nodes Add for_each_from, to simplify loops starting from non-first list cells. 2020-09-28 20:32:53 -04:00
optimizer Build EC members for child join rels in the right memory context. 2020-10-06 11:43:53 -04:00
parser Add for_each_from, to simplify loops starting from non-first list cells. 2020-09-28 20:32:53 -04:00
partitioning Clean up some code and comments in partbounds.c. 2020-09-10 18:00:01 +09:00
po Translation updates 2020-09-21 10:06:30 +02:00
port Spelling adjustments 2020-06-07 15:06:51 +02:00
postmaster Use _exit(2) for SIGQUIT during ProcessStartupPacket, too. 2020-09-10 12:06:26 -04:00
regex Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
replication Archive timeline history files in standby if archive_mode is set to "always". 2020-09-29 16:23:57 +09:00
rewrite Add missing invocations to object access hooks 2020-05-23 14:03:04 +09:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Run pgindent with new pg_bsd_indent version 2.1.1. 2020-05-16 11:54:51 -04:00
storage Message fixes and style improvements 2020-09-14 06:42:07 +02:00
tcop Fix bogus completion tag usage in walsender 2020-09-16 21:16:25 -03:00
tsearch Avoid possible dangling-pointer access in tsearch_readline_callback. 2020-09-23 11:36:13 -04:00
utils Prevent internal overflows in date-vs-timestamp and related comparisons. 2020-10-07 17:10:26 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
nls.mk Translation updates 2020-09-14 13:14:53 +02:00