]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix integer-overflow edge case detection in interval_mul and pgbench.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Nov 2019 16:22:52 +0000 (11:22 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Nov 2019 16:23:06 +0000 (11:23 -0500)
commit8d380864a523362777d325872997ae706d1d34e1
treedd08113ba32e223e410f4997becd7daa8c7590d4
parent1accf997482122d69493f942a6aa89cf34b3fd75
Fix integer-overflow edge case detection in interval_mul and pgbench.

This patch adopts the overflow check logic introduced by commit cbdb8b4c0
into two more places.  interval_mul() failed to notice if it computed a
new microseconds value that was one more than INT64_MAX, and pgbench's
double-to-int64 logic had the same sorts of edge-case problems that
cbdb8b4c0 fixed in the core code.

To make this easier to get right in future, put the guts of the checks
into new macros in c.h, and add commentary about how to use the macros
correctly.

Back-patch to all supported branches, as we did with the previous fix.

Yuya Watari

Discussion: https://postgr.es/m/CAJ2pMkbkkFw2hb9Qb1Zj8d06EhWAQXFLy73St4qWv6aX=vqnjw@mail.gmail.com
src/backend/utils/adt/float.c
src/backend/utils/adt/int8.c
src/backend/utils/adt/timestamp.c
src/include/c.h
src/test/regress/expected/interval.out
src/test/regress/sql/interval.sql