]> granicus.if.org Git - postgresql/commitdiff
Minor correction for previous SQLSTATE patch: I changed dsqrt() to emit the
authorNeil Conway <neilc@samurai.com>
Wed, 19 May 2004 04:32:26 +0000 (04:32 +0000)
committerNeil Conway <neilc@samurai.com>
Wed, 19 May 2004 04:32:26 +0000 (04:32 +0000)
right error code previously, and this patch applies an analogous change
to numeric_sqrt().

src/backend/utils/adt/numeric.c

index 9307ba5e6ecfaca4b0b89b8c1333818be80e3834..242c7cf9d359bfebc99378eca6485ea25a9a2453 100644 (file)
@@ -14,7 +14,7 @@
  * Copyright (c) 1998-2003, PostgreSQL Global Development Group
  *
  * 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)
                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)
                ereport(ERROR,
-                               (errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
+                               (errcode(ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION),
                                 errmsg("cannot take square root of a negative number")));
 
        init_var(&tmp_arg);