https://github.com/postgres/postgres
Revision fe3b1b575e24748ddb9b3b67394fa10c279090ac authored by Tom Lane on 28 February 2024, 19:00:30 UTC, committed by Tom Lane on 28 February 2024, 19:00:30 UTC
In the case where the target timestamp is before the origin timestamp
and their difference is already an exact multiple of the stride, the
code incorrectly subtracted the stride anyway.

Also detect several integer-overflow cases that previously produced
bogus results.  (The submitted patch tried to avoid overflow, but
I'm not convinced it's right, and problematic cases are so far out of
the plausibly-useful range that they don't seem worth sweating over.
Let's just use overflow-detecting arithmetic and throw errors.)

timestamp_bin() and timestamptz_bin() are basically identical and
so had identical bugs.  Fix both.

Report and patch by Moaaz Assali, adjusted some by me.  Back-patch
to v14 where date_bin() was introduced.

Discussion: https://postgr.es/m/CALkF+nvtuas-2kydG-WfofbRSJpyODAJWun==W-yO5j2R4meqA@mail.gmail.com
1 parent 09f0988
History
Tip revision: fe3b1b575e24748ddb9b3b67394fa10c279090ac authored by Tom Lane on 28 February 2024, 19:00:30 UTC
Fix mis-rounding and overflow hazards in date_bin().
Tip revision: fe3b1b5
File Mode Size
config
contrib
doc
src
.dir-locals.el -rw-r--r-- 730 bytes
.editorconfig -rw-r--r-- 183 bytes
.git-blame-ignore-revs -rw-r--r-- 9.1 KB
.gitattributes -rw-r--r-- 1.5 KB
.gitignore -rw-r--r-- 515 bytes
COPYRIGHT -rw-r--r-- 1.2 KB
GNUmakefile.in -rw-r--r-- 4.2 KB
HISTORY -rw-r--r-- 277 bytes
Makefile -rw-r--r-- 1.6 KB
README -rw-r--r-- 1.2 KB
README.git -rw-r--r-- 721 bytes
aclocal.m4 -rw-r--r-- 445 bytes
configure -rwxr-xr-x 581.1 KB
configure.ac -rw-r--r-- 84.7 KB

README

back to top