Tom Lane wrote:
> Bruce Momjian <[EMAIL PROTECTED]> writes:
> >> b) If VB is 0 (zero) and VE is negative, then an exception condition is
> >> raised: data exception ? invalid argument for power function.
> 
> > Well, this indicates we shouldn't return "zero raised to a negative
> > power is undefined", but rather the power error we are giving now, or
> > are you saying we should return the "power" error code but an error
> > message mentioning zero?
> 
> The spec says what the SQLSTATE code should be.   We have always felt
> free to word the message text more specifically than that, though.

OK, error wording updated, attached, and applied.

-- 
  Bruce Momjian  <[EMAIL PROTECTED]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/utils/adt/float.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/float.c,v
retrieving revision 1.156
diff -c -c -r1.156 float.c
*** src/backend/utils/adt/float.c	9 May 2008 15:36:06 -0000	1.156
--- src/backend/utils/adt/float.c	9 May 2008 21:29:37 -0000
***************
*** 1334,1344 ****
  	 * 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))
  		ereport(ERROR,
  				(errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
! 				 errmsg("invalid argument for power function")));
  
  	/*
  	 * pow() sets errno only on some platforms, depending on whether it
--- 1334,1347 ----
  	 * certain error conditions.  Specifically, we don't return a divide-by-zero
  	 * error code for 0 ^ -1.
  	 */
! 	if (arg1 == 0 && arg2 < 0)
  		ereport(ERROR,
  				(errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
! 				 errmsg("zero raised to a negative power is undefined")));
! 	if (arg1 < 0 && floor(arg2) != arg2)
! 		ereport(ERROR,
! 				(errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
! 				 errmsg("a negative number raised to a non-integer power yields a complex result")));
  
  	/*
  	 * pow() sets errno only on some platforms, depending on whether it
Index: src/backend/utils/adt/numeric.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v
retrieving revision 1.113
diff -c -c -r1.113 numeric.c
*** src/backend/utils/adt/numeric.c	9 May 2008 15:36:06 -0000	1.113
--- src/backend/utils/adt/numeric.c	9 May 2008 21:29:37 -0000
***************
*** 1897,1909 ****
  	 * 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) ||
! 		(cmp_var(&arg1, &const_zero) < 0 &&
! 		 cmp_var(&arg2, &arg2_trunc) != 0))
  		ereport(ERROR,
  				(errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
! 				 errmsg("invalid argument for power function")));
  
  	/*
  	 * Call power_var() to compute and return the result; note it handles
--- 1897,1913 ----
  	 * 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)
  		ereport(ERROR,
  				(errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
! 				 errmsg("zero raised to a negative power is undefined")));
! 
! 	if (cmp_var(&arg1, &const_zero) < 0 &&
! 		cmp_var(&arg2, &arg2_trunc) != 0)
! 		ereport(ERROR,
! 				(errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
! 				 errmsg("a negative number raised to a non-integer power yields a complex result")));
  
  	/*
  	 * Call power_var() to compute and return the result; note it handles
-- 
Sent via pgsql-committers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

Reply via email to