|
14 | 14 | * Copyright (c) 1998-2008, PostgreSQL Global Development Group
|
15 | 15 | *
|
16 | 16 | * IDENTIFICATION
|
17 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.112 2008/05/08 22:17:54 momjian Exp $ |
| 17 | + * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.113 2008/05/09 15:36:06 momjian Exp $ |
18 | 18 | *
|
19 | 19 | *-------------------------------------------------------------------------
|
20 | 20 | */
|
@@ -1893,8 +1893,9 @@ numeric_power(PG_FUNCTION_ARGS)
|
1893 | 1893 | trunc_var(&arg2_trunc,0);
|
1894 | 1894 |
|
1895 | 1895 | /*
|
1896 |
| - * Return special SQLSTATE error codes for a few conditions mandated by |
1897 |
| - * the standard. |
| 1896 | + * The SQL spec requires that we emit a particular SQLSTATE error code for |
| 1897 | + * certain error conditions. Specifically, we don't return a divide-by-zero |
| 1898 | + * error code for 0 ^ -1. |
1898 | 1899 | */
|
1899 | 1900 | if ((cmp_var(&arg1,&const_zero)==0&&
|
1900 | 1901 | cmp_var(&arg2,&const_zero)<0)||
|
@@ -5283,6 +5284,7 @@ power_var_int(NumericVar *base, int exp, NumericVar *result, int rscale)
|
5283 | 5284 | /*
|
5284 | 5285 | *While 0 ^ 0 can be either 1 or indeterminate (error), we
|
5285 | 5286 | *treat it as 1 because most programming languages do this.
|
| 5287 | + *SQL:2003 also requires a return value of 1. |
5286 | 5288 | *http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_zero_power
|
5287 | 5289 | */
|
5288 | 5290 | set_var_from_var(&const_one,result);
|
|