index 2ee2455089e3f2186853f52d564ff706e5af8946..3df08cc6a3463da536704f7cb48ddb7ce4484de1 100644 (file)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.155 2008年04月21日 00:26:45 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.156 2008年05月09日 15:36:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* The SQL spec requires that we emit a particular SQLSTATE error code for
- * certain error conditions.
+ * certain error conditions. Specifically, we don't return a divide-by-zero
+ * error code for 0 ^ -1.
*/
if ((arg1 == 0 && arg2 < 0) ||
(arg1 < 0 && floor(arg2) != arg2))
index a8cd22611d3bb434999edbfa65ddb9edf0fa99e1..b4022a7ccf18cee1207ddcd1e7300e26c9b5e0b6 100644 (file)
* Copyright (c) 1998-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.112 2008年05月08日 22:17:54 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.113 2008年05月09日 15:36:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
trunc_var(&arg2_trunc, 0);
/*
- * Return special SQLSTATE error codes for a few conditions mandated by
- * the standard.
+ * The SQL spec requires that we emit a particular SQLSTATE error code for
+ * certain error conditions. Specifically, we don't return a divide-by-zero
+ * error code for 0 ^ -1.
*/
if ((cmp_var(&arg1, &const_zero) == 0 &&
cmp_var(&arg2, &const_zero) < 0) ||
@@ -5283,6 +5284,7 @@ power_var_int(NumericVar *base, int exp, NumericVar *result, int rscale)
/*
* While 0 ^ 0 can be either 1 or indeterminate (error), we
* treat it as 1 because most programming languages do this.
+ * SQL:2003 also requires a return value of 1.
* http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_zero_power
*/
set_var_from_var(&const_one, result);