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

pgsql: Fix the int8 and int2 cases of (minimum possible integer) %(-1)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix the int8 and int2 cases of (minimum possible integer) %(-1)
Date: 2012-11-14 22:30:46
Message-ID: E1TYlTq-0005Yu-HW@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Fix the int8 and int2 cases of (minimum possible integer) % (-1).

The correct answer for this (or any other case with arg2 = -1) is zero,
but some machines throw a floating-point exception instead of behaving
sanely.  Commit f9ac414c35ea084ff70c564ab2c32adb06d5296f dealt with this
in int4mod, but overlooked the fact that it also happens in int8mod
(at least on my Linux x86_64 machine).  Protect int2mod as well; it's
not clear whether any machines fail there (mine does not) but since the
test is so cheap it seems better safe than sorry.  While at it, simplify
the original guard in int4mod: we need only check for arg2 == -1, we
don't need to check arg1 explicitly.

Xi Wang, with some editing by me.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/2e06d52529ae52b7c56f18e451e896cb8680aac9

Modified Files
--------------
src/backend/utils/adt/int.c  |   17 +++++++++++++++--
src/backend/utils/adt/int8.c |    8 ++++++++
2 files changed, 23 insertions(+), 2 deletions(-)

pgsql-committers by date

Next:From: Bruce MomjianDate: 2012-11-14 22:32:12
Subject: pgsql: In pg_upgrade, copy fsm, vm,and extent files by checking for fi
Previous:From: Bruce MomjianDate: 2012-11-14 02:10:48
Subject: pgsql: Mark pg_upgrade's free_db_and_rel_infos() as a static function.

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