From 31e69ccb210cf49712f77facbf90661d8bc2eed5 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 11 Mar 2003 21:01:33 +0000 Subject: 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. --- src/backend/utils/adt/cash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/backend/utils/adt/cash.c') 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); -- cgit v1.2.3