postgresql/src/backend/utils/adt
Tom Lane a9632830bb Reject "23:59:60.nnn" in datetime input.
It's intentional that we don't allow values greater than 24 hours,
while we do allow "24:00:00" as well as "23:59:60" as inputs.
However, the range check was miscoded in such a way that it would
accept "23:59:60.nnn" with a nonzero fraction.  For time or timetz,
the stored result would then be greater than "24:00:00" which would
fail dump/reload, not to mention possibly confusing other operations.

Fix by explicitly calculating the result and making sure it does not
exceed 24 hours.  (This calculation is redundant with what will happen
later in tm2time or tm2timetz.  Maybe someday somebody will find that
annoying enough to justify refactoring to avoid the duplication; but
that seems too invasive for a back-patched bug fix, and the cost is
probably unmeasurable anyway.)

Note that this change also rejects such input as the time portion
of a timestamp(tz) value.

Back-patch to v10.  The bug is far older, but to change this pre-v10
we'd need to ensure that the logic behaves sanely with float timestamps,
which is possibly nontrivial due to roundoff considerations.
Doesn't really seem worth troubling with.

Per report from Christoph Berg.

Discussion: https://postgr.es/m/20200520125807.GB296739@msg.df7cb.de
2020-06-04 16:42:23 -04:00
..
.gitignore Revert "Add gitignore entries for jsonpath_gram.h" 2019-03-23 00:19:34 +01:00
Makefile Introduce xid8-based functions to replace txid_XXX. 2020-04-07 12:04:32 +12:00
acl.c Remove ACLDEBUG #define and associated code. 2020-04-23 15:38:04 -04:00
amutils.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
array_expanded.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
array_selfuncs.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
array_typanalyze.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
array_userfuncs.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
arrayfuncs.c Fix minor violations of FunctionCallInvoke usage protocol. 2020-04-21 14:23:53 -04:00
arrayutils.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
ascii.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
bool.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
cash.c Fix loss of fractional digits for large values in cash_numeric(). 2019-07-26 11:59:00 -04:00
char.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
cryptohashes.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
date.c Reject "23:59:60.nnn" in datetime input. 2020-06-04 16:42:23 -04:00
datetime.c Reject "23:59:60.nnn" in datetime input. 2020-06-04 16:42:23 -04:00
datum.c Add equalimage B-Tree support functions. 2020-02-26 11:28:25 -08:00
dbsize.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
domains.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
encode.c Adjust bytea get_bit/set_bit to use int8 not int4 for bit numbering. 2020-04-07 15:57:58 -04:00
enum.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
expandeddatum.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
expandedrecord.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
float.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
format_type.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
formatting.c Run pgindent with new pg_bsd_indent version 2.1.1. 2020-05-16 11:54:51 -04:00
genfile.c Teach pg_ls_dir_files() to ignore ENOENT failures from stat(). 2020-03-31 12:57:55 -04:00
geo_ops.c Fix circle_in to accept "(x,y),r" as it's advertised to do. 2020-04-07 20:50:28 -04:00
geo_selfuncs.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
geo_spgist.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
inet_cidr_ntop.c Avoid conflicts with library versions of inet_net_ntop() and friends. 2019-08-18 19:27:23 -04:00
inet_net_pton.c Avoid conflicts with library versions of inet_net_ntop() and friends. 2019-08-18 19:27:23 -04:00
int.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
int8.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
json.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
jsonb.c Introduce "anycompatible" family of polymorphic types. 2020-03-19 11:43:11 -04:00
jsonb_gin.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
jsonb_op.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
jsonb_util.c Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
jsonfuncs.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
jsonpath.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jsonpath_exec.c Make SQL/JSON error code names match SQL standard 2020-04-30 09:34:54 +02:00
jsonpath_gram.y Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jsonpath_scan.l Add lcov exclusion markers to jsonpath scanner 2020-05-26 14:09:36 +02:00
levenshtein.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
like.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
like_match.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
like_support.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
lockfuncs.c Change locktype "speculative token" to "spectoken". 2020-05-15 21:47:34 -04:00
mac.c Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
mac8.c Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
misc.c Revert 0f5ca02f53 2020-04-08 11:37:27 +03:00
name.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
network.c Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
network_gist.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
network_selfuncs.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
network_spgist.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
numeric.c Run pgindent with new pg_bsd_indent version 2.1.1. 2020-05-16 11:54:51 -04:00
numutils.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
oid.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
oracle_compat.c Add CHECK_FOR_INTERRUPTS() to the repeat() function 2020-05-28 13:19:00 -04:00
orderedsetaggs.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
partitionfuncs.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_locale.c Fix the MSVC build for versions 2015 and later. 2020-05-14 09:24:33 +05:30
pg_lsn.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_upgrade_support.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
pgstatfuncs.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
pseudotypes.c Introduce "anycompatible" family of polymorphic types. 2020-03-19 11:43:11 -04:00
quote.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
rangetypes.c Remove RangeIOData->typiofunc 2020-03-05 11:35:02 -03:00
rangetypes_gist.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
rangetypes_selfuncs.c Fix edge-case crashes and misestimation in range containment selectivity. 2020-01-12 14:36:59 -05:00
rangetypes_spgist.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
rangetypes_typanalyze.c Clean up newlines following left parentheses 2020-01-30 13:42:14 -03:00
regexp.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
regproc.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
ri_triggers.c Add object names to partition integrity violations. 2020-03-23 08:09:15 +05:30
rowtypes.c Fix minor violations of FunctionCallInvoke usage protocol. 2020-04-21 14:23:53 -04:00
ruleutils.c Run pgindent with new pg_bsd_indent version 2.1.1. 2020-05-16 11:54:51 -04:00
selfuncs.c Allow matchingsel() to be used with operators that might return NULL. 2020-04-21 12:56:55 -04:00
tid.c Fix use-after-release mistake in currtid() and currtid2() for views 2020-06-01 14:41:18 +09:00
timestamp.c Reject "23:59:60.nnn" in datetime input. 2020-06-04 16:42:23 -04:00
trigfuncs.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tsginidx.c Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
tsgistidx.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
tsquery.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tsquery_cleanup.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tsquery_gist.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tsquery_op.c Clean up newlines following left parentheses 2020-01-30 13:42:14 -03:00
tsquery_rewrite.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tsquery_util.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tsrank.c Fix typo in comment 2020-05-03 12:19:31 +03:00
tsvector.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tsvector_op.c Fix YA text phrase search bug. 2020-05-07 15:59:51 -04:00
tsvector_parser.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
uuid.c Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
varbit.c Run pgindent with new pg_bsd_indent version 2.1.1. 2020-05-16 11:54:51 -04:00
varchar.c Run pgindent with new pg_bsd_indent version 2.1.1. 2020-05-16 11:54:51 -04:00
varlena.c Adjust bytea get_bit/set_bit to use int8 not int4 for bit numbering. 2020-04-07 15:57:58 -04:00
version.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
windowfuncs.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
xid.c Add SQL type xid8 to expose FullTransactionId to users. 2020-04-07 12:03:59 +12:00
xid8funcs.c Rename SLRU structures and associated LWLocks. 2020-05-15 14:28:25 -04:00
xml.c Allow Unicode escapes in any server encoding, not only UTF-8. 2020-03-06 14:17:43 -05:00