diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-03-11 21:01:33 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-03-11 21:01:33 +0000 |
commit | 31e69ccb210cf49712f77facbf90661d8bc2eed5 (patch) | |
tree | ec6e0c1a656051db532cdef53a84309d6180c4a1 /src/backend/utils/adt/float.c | |
parent | 6261c75014c9948837d9d025493ef18b8f833f70 (diff) | |
download | postgresql-31e69ccb210cf49712f77facbf90661d8bc2eed5.tar.gz postgresql-31e69ccb210cf49712f77facbf90661d8bc2eed5.zip |
Add explicit tests for division by zero to all user-accessible integer
division and modulo functions, to avoid problems on OS X (which fails to
trap 0 divide at all) and Windows (which traps it in some bizarre
nonstandard fashion). Standardize on 'division by zero' as the one true
spelling of this error message. Add regression tests as suggested by
Neil Conway.
Diffstat (limited to 'src/backend/utils/adt/float.c')
-rw-r--r-- | src/backend/utils/adt/float.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index c0acc554b8e..4220b4775a9 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.83 2002/11/08 17:37:52 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.84 2003/03/11 21:01:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -505,7 +505,7 @@ float4div(PG_FUNCTION_ARGS) double result; if (arg2 == 0.0) - elog(ERROR, "float4div: divide by zero error"); + elog(ERROR, "division by zero"); /* Do division in float8, then check for overflow */ result = (float8) arg1 / (float8) arg2; @@ -567,7 +567,7 @@ float8div(PG_FUNCTION_ARGS) float8 result; if (arg2 == 0.0) - elog(ERROR, "float8div: divide by zero error"); + elog(ERROR, "division by zero"); result = arg1 / arg2; @@ -1753,7 +1753,7 @@ float48div(PG_FUNCTION_ARGS) float8 result; if (arg2 == 0.0) - elog(ERROR, "float48div: divide by zero"); + elog(ERROR, "division by zero"); result = arg1 / arg2; CheckFloat8Val(result); @@ -1813,7 +1813,7 @@ float84div(PG_FUNCTION_ARGS) float8 result; if (arg2 == 0.0) - elog(ERROR, "float84div: divide by zero"); + elog(ERROR, "division by zero"); result = arg1 / arg2; |