pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix integer-overflow edge case detection in interval_mul and pgb
Date: Thu, 07 Nov 2019 16:23:20 +0000
Message-ID: <E1iSkZ6-0005R4-Bu@gemulon.postgresql.org> (raw)

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

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/15783d057543edde84b537815a8f22cf99d4beaa

Modified Files
--------------
src/backend/utils/adt/float.c          | 44 +++++++---------------------------
src/backend/utils/adt/int8.c           | 22 ++++-------------
src/backend/utils/adt/timestamp.c      |  2 +-
src/bin/pgbench/pgbench.c              |  5 ++--
src/include/c.h                        | 24 +++++++++++++++++++
src/test/regress/expected/interval.out |  3 +++
src/test/regress/sql/interval.sql      |  3 +++
7 files changed, 46 insertions(+), 57 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1iSkZ6-0005R4-Bu@gemulon.postgresql.org>
Permalink:  ../E1iSkZ6-0005R4-Bu@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iSkZ6-0005R4-Bu@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix integer-overflow edge case detection in interval_mul and pgb
  In-Reply-To: <E1iSkZ6-0005R4-Bu@gemulon.postgresql.org>
  References: <E1iSkZ6-0005R4-Bu@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox