Commit 132d0905 authored by Neil Conway's avatar Neil Conway

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().
parent f16874c2
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* Copyright (c) 1998-2003, PostgreSQL Global Development Group * Copyright (c) 1998-2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.75 2004/05/16 23:18:55 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.76 2004/05/19 04:32:26 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -4210,9 +4210,13 @@ sqrt_var(NumericVar *arg, NumericVar *result, int rscale) ...@@ -4210,9 +4210,13 @@ sqrt_var(NumericVar *arg, NumericVar *result, int rscale)
return; return;
} }
/*
* SQL2003 defines sqrt() in terms of power, so we need to emit
* the right SQLSTATE error code if the operand is negative.
*/
if (stat < 0) if (stat < 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION), (errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
errmsg("cannot take square root of a negative number"))); errmsg("cannot take square root of a negative number")));
init_var(&tmp_arg); init_var(&tmp_arg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment