Skip site navigation (1) Skip section navigation (2)

pgsql: Improve handling of INT_MIN / -1 and related cases.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve handling of INT_MIN / -1 and related cases.
Date: 2012-11-19 17:24:40
Message-ID: E1TaV5M-0004fQ-FS@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Improve handling of INT_MIN / -1 and related cases.

Some platforms throw an exception for this division, rather than returning
a necessarily-overflowed result.  Since we were testing for overflow after
the fact, an exception isn't nice.  We can avoid the problem by treating
division by -1 as negation.

Add some regression tests so that we'll find out if any compilers try to
optimize away the overflow check conditions.

This ought to be back-patched, but I'm going to see what the buildfarm
reports about the regression tests first.

Per discussion with Xi Wang, though this is different from the patch he
submitted.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/1f7cb5c30983752ff8de833de30afcaee63536d0

Modified Files
--------------
src/backend/utils/adt/int.c                        |  108 ++++++++++----------
src/backend/utils/adt/int8.c                       |   90 +++++++++++------
src/test/regress/expected/int2.out                 |   11 ++
src/test/regress/expected/int4.out                 |   21 ++++
.../regress/expected/int8-exp-three-digits.out     |   31 ++++++
src/test/regress/expected/int8.out                 |   31 ++++++
src/test/regress/sql/int2.sql                      |    5 +
src/test/regress/sql/int4.sql                      |    8 ++
src/test/regress/sql/int8.sql                      |   11 ++
9 files changed, 233 insertions(+), 83 deletions(-)

pgsql-committers by date

Next:From: Bruce MomjianDate: 2012-11-19 21:42:03
Subject: pgsql: In pg_upgrade,report errno string if file existence check retur
Previous:From: Heikki LinnakangasDate: 2012-11-19 08:20:43
Subject: pgsql: Fix archive_cleanup_command.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group