Skip to content

Commit 132d090

Browse files
author
Neil Conway
committed
Minor correction for previous SQLSTATE patch: I changed dsqrt() to emit the
right error code previously, and this patch applies an analogous change to numeric_sqrt().
1 parent f16874c commit 132d090

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/utils/adt/numeric.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Copyright (c) 1998-2003, PostgreSQL Global Development Group
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.75 2004/05/16 23:18:55 neilc Exp $
17+
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.76 2004/05/19 04:32:26 neilc Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -4210,9 +4210,13 @@ sqrt_var(NumericVar *arg, NumericVar *result, int rscale)
42104210
return;
42114211
}
42124212

4213+
/*
4214+
* SQL2003 defines sqrt() in terms of power, so we need to emit
4215+
* the right SQLSTATE error code if the operand is negative.
4216+
*/
42134217
if (stat < 0)
42144218
ereport(ERROR,
4215-
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
4219+
(errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
42164220
errmsg("cannot take square root of a negative number")));
42174221

42184222
init_var(&tmp_arg);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy