Update C comments to mention SQL:2003 handling of power return values.
This commit is contained in:
parent
c5f42ce8d5
commit
6e3e60095d
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -1331,7 +1331,8 @@ dpow(PG_FUNCTION_ARGS)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The SQL spec requires that we emit a particular SQLSTATE error code for
|
* 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) ||
|
if ((arg1 == 0 && arg2 < 0) ||
|
||||||
(arg1 < 0 && floor(arg2) != arg2))
|
(arg1 < 0 && floor(arg2) != arg2))
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* Copyright (c) 1998-2008, PostgreSQL Global Development Group
|
* Copyright (c) 1998-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -1893,8 +1893,9 @@ numeric_power(PG_FUNCTION_ARGS)
|
||||||
trunc_var(&arg2_trunc, 0);
|
trunc_var(&arg2_trunc, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return special SQLSTATE error codes for a few conditions mandated by
|
* The SQL spec requires that we emit a particular SQLSTATE error code for
|
||||||
* the standard.
|
* certain error conditions. Specifically, we don't return a divide-by-zero
|
||||||
|
* error code for 0 ^ -1.
|
||||||
*/
|
*/
|
||||||
if ((cmp_var(&arg1, &const_zero) == 0 &&
|
if ((cmp_var(&arg1, &const_zero) == 0 &&
|
||||||
cmp_var(&arg2, &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
|
* While 0 ^ 0 can be either 1 or indeterminate (error), we
|
||||||
* treat it as 1 because most programming languages do this.
|
* 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
|
* http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_zero_power
|
||||||
*/
|
*/
|
||||||
set_var_from_var(&const_one, result);
|
set_var_from_var(&const_one, result);
|
||||||
|
|
Loading…
Reference in New Issue