Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Committers > Re: pgsql: Have...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 11 of 11 Topic 16074 of 18152
Post > Topic >>

Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather

by bruce@[EMAIL PROTECTED] (Bruce Momjian) May 9, 2008 at 05:32 PM

--ELM1210368746-7832-0_
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UNKNOWN-8BIT"

Tom Lane wrote:
> Bruce Momjian <bruce@[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  <bruce@[EMAIL PROTECTED]
>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

--ELM1210368746-7832-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/x-diff
Content-Disposition: inline; filename="/rtmp/diff"

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))
  		ere****t(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)
  		ere****t(ERROR,
  				(errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
! 				 errmsg("zero raised to a negative power is undefined")));
! 	if (arg1 < 0 && floor(arg2) != arg2)
! 		ere****t(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))
  		ere****t(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)
  		ere****t(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)
! 		ere****t(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

--ELM1210368746-7832-0_
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


-- 
Sent via pgsql-committers mailing list (pgsql-committers@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

--ELM1210368746-7832-0_--
 




 11 Posts in Topic:
pgsql: Have numeric 0 ^ 4.3 return 1, rather than an error, and
momjian@[EMAIL PROTECTED]  2008-05-08 19:25:38 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than
neilc@[EMAIL PROTECTED]   2008-05-08 14:00:35 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-08 18:18:00 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than an error,
tgl@[EMAIL PROTECTED] (T  2008-05-08 18:23:31 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-08 18:34:20 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than
simon@[EMAIL PROTECTED]   2008-05-09 09:00:36 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than an error,
tgl@[EMAIL PROTECTED] (T  2008-05-09 10:37:07 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-09 11:36:07 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather than an error,
tgl@[EMAIL PROTECTED] (T  2008-05-09 11:57:42 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-09 11:58:41 
Re: pgsql: Have numeric 0 ^ 4.3 return 1, rather
bruce@[EMAIL PROTECTED]   2008-05-09 17:32:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 0:27:16 CST 2008.