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/cash.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/cash.c')
-rw-r--r-- | src/backend/utils/adt/cash.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index c33bca654e8..f210f4258f0 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -9,7 +9,7 @@ * workings can be found in the book "Software Solutions in C" by * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.56 2002/09/04 20:31:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.57 2003/03/11 21:01:33 tgl Exp $ */ #include "postgres.h" @@ -442,7 +442,7 @@ cash_div_flt8(PG_FUNCTION_ARGS) Cash result; if (f == 0.0) - elog(ERROR, "cash_div: divide by 0.0 error"); + elog(ERROR, "division by zero"); result = rint(c / f); PG_RETURN_CASH(result); @@ -492,7 +492,7 @@ cash_div_flt4(PG_FUNCTION_ARGS) Cash result; if (f == 0.0) - elog(ERROR, "cash_div: divide by 0.0 error"); + elog(ERROR, "division by zero"); result = rint(c / f); PG_RETURN_CASH(result); @@ -543,7 +543,7 @@ cash_div_int4(PG_FUNCTION_ARGS) Cash result; if (i == 0) - elog(ERROR, "cash_div_int4: divide by 0 error"); + elog(ERROR, "division by zero"); result = rint(c / i); @@ -593,7 +593,7 @@ cash_div_int2(PG_FUNCTION_ARGS) Cash result; if (s == 0) - elog(ERROR, "cash_div: divide by 0 error"); + elog(ERROR, "division by zero"); result = rint(c / s); PG_RETURN_CASH(result); |