mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-09 12:19:47 +02:00
df1a699e5b
When using integer timestamps, the interval-comparison functions tried
to compute the overall magnitude of an interval as an int64 number of
microseconds. As reported by Frazer McLean, this overflows for intervals
exceeding about 296000 years, which is bad since we nominally allow
intervals many times larger than that. That results in wrong comparison
results, and possibly in corrupted btree indexes for columns containing
such large interval values.
To fix, compute the magnitude as int128 instead. Although some compilers
have native support for int128 calculations, many don't, so create our
own support functions that can do 128-bit addition and multiplication
if the compiler support isn't there. These support functions are designed
with an eye to allowing the int128 code paths in numeric.c to be rewritten
for use on all platforms, although this patch doesn't do that, or even
provide all the int128 primitives that will be needed for it.
Back-patch as far as 9.4. Earlier releases did not guard against overflow
of interval values at all (commit
|
||
---|---|---|
.. | ||
adt | ||
cache | ||
error | ||
fmgr | ||
hash | ||
init | ||
mb | ||
misc | ||
mmgr | ||
resowner | ||
sort | ||
time | ||
.gitignore | ||
errcodes.txt | ||
Gen_dummy_probes.pl | ||
Gen_dummy_probes.sed | ||
Gen_fmgrtab.pl | ||
generate-errcodes.pl | ||
Makefile | ||
probes.d |