Skip to content

Commit 4171bb8

Browse files
committed
Detect overflow in integer arithmetic operators (integer, smallint, and
bigint variants). Clean up some inconsistencies in error message wording. Fix scanint8 to allow trailing whitespace in INT64_MIN case. Update int8-exp-three-digits.out, which seems to have been ignored by the last couple of people to modify the int8 regression test, and remove int8-exp-three-digits-win32.out which is thereby exposed as redundant.
1 parent 24201b4 commit 4171bb8

File tree

18 files changed

+702
-524
lines changed

18 files changed

+702
-524
lines changed

doc/src/sgml/release.sgml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.298 2004/10/01 02:00:43 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.299 2004/10/04 14:42:46 tgl Exp $
33
-->
44

55
<appendix id="release">
@@ -256,6 +256,13 @@ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.298 2004/10/01 02:00:43 neilc E
256256
</para>
257257
</listitem>
258258

259+
<listitem>
260+
<para>
261+
Overflow in integer arithmetic operations is now detected and
262+
reported as an error.
263+
</para>
264+
</listitem>
265+
259266
<listitem>
260267
<para>
261268
The server now warns of empty strings passed to
@@ -1228,6 +1235,12 @@ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.298 2004/10/01 02:00:43 neilc E
12281235
</para>
12291236
</listitem>
12301237

1238+
<listitem>
1239+
<para>
1240+
Overflow in integer arithmetic operations is now detected (Tom)
1241+
</para>
1242+
</listitem>
1243+
12311244
<listitem>
12321245
<para>
12331246
Syntax checking of array input values considerably tightened up (Joe)

src/backend/utils/adt/float.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.110 2004/09/02 17:12:50 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.111 2004/10/04 14:42:46 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1147,7 +1147,7 @@ dtoi2(PG_FUNCTION_ARGS)
11471147
if ((num < SHRT_MIN) || (num > SHRT_MAX))
11481148
ereport(ERROR,
11491149
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1150-
errmsg("integer out of range")));
1150+
errmsg("smallint out of range")));
11511151

11521152
result = (int16) rint(num);
11531153
PG_RETURN_INT16(result);
@@ -1213,7 +1213,7 @@ ftoi2(PG_FUNCTION_ARGS)
12131213
if ((num < SHRT_MIN) || (num > SHRT_MAX))
12141214
ereport(ERROR,
12151215
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1216-
errmsg("integer out of range")));
1216+
errmsg("smallint out of range")));
12171217

12181218
result = (int16) rint(num);
12191219
PG_RETURN_INT16(result);

0 commit comments

Comments
 (0)