mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
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.
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.33 2002/06/20 20:29:36 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.34 2003/03/11 21:01:33 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -150,6 +150,9 @@ chardiv(PG_FUNCTION_ARGS)
|
||||
char arg1 = PG_GETARG_CHAR(0);
|
||||
char arg2 = PG_GETARG_CHAR(1);
|
||||
|
||||
if (arg2 == 0)
|
||||
elog(ERROR, "division by zero");
|
||||
|
||||
PG_RETURN_CHAR((int8) arg1 / (int8) arg2);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user