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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Improve handling of INT_MIN / -1 and related cases.
Дата
Msg-id E1TadTu-00049V-2W@gemulon.postgresql.org
обсуждение исходный текст
Список 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.

Back-patch of commit 1f7cb5c30983752ff8de833de30afcaee63536d0.

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

Branch
------
REL8_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/3352e25e85b28ee1f21e0a759c0c49e399cb032a

Modified Files
--------------
src/backend/utils/adt/int.c                        |  113 +++++++++++---------
src/backend/utils/adt/int8.c                       |   59 +++++++----
src/test/regress/expected/int2.out                 |   11 ++
src/test/regress/expected/int4.out                 |   21 ++++
.../regress/expected/int8-exp-three-digits.out     |   21 ++++
src/test/regress/expected/int8.out                 |   21 ++++
src/test/regress/sql/int2.sql                      |    4 +
src/test/regress/sql/int4.sql                      |    8 ++
src/test/regress/sql/int8.sql                      |    8 ++
9 files changed, 198 insertions(+), 68 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Improve handling of INT_MIN / -1 and related cases.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Improve handling of INT_MIN / -1 and related cases.