Re: bug in numeric log() on 7.1, 7.2.2, 7.2.3 - Mailing list pgsql-bugs

From Tom Lane
Subject Re: bug in numeric log() on 7.1, 7.2.2, 7.2.3
Date
Msg-id 12658.1047601332@sss.pgh.pa.us
Whole thread Raw
In response to bug in numeric log() on 7.1, 7.2.2, 7.2.3  (dmarin <dmarin@uclink.berkeley.edu>)
List pgsql-bugs
dmarin <dmarin@uclink.berkeley.edu> writes:
> This query never returns:
> select log(93094::numeric/92908::numeric);

The attached patch against 7.3 seems to take care of the problem.  You
should be able to apply it to 7.2, with possibly some tweaking (the code
needs to go into the loop in ln_var()).

I am unsure whether exp_var() needs a similar defense against roundoff
error.  Have you observed any problems there?

*** src/backend/utils/adt/numeric.c.orig    Tue Mar 11 16:01:33 2003
--- src/backend/utils/adt/numeric.c    Thu Mar 13 19:06:42 2003
***************
*** 3872,3877 ****
--- 3872,3880 ----
              break;

          add_var(result, &elem, result);
+
+         if (elem.weight < (result->weight - 2 * global_rscale))
+             break;
      }

      /* Compensate for argument range reduction, round to caller's rscale */



> P.S. Incidentally, on the solaris system, I also can't use pg_dump at all; no
> matter what database I try to dump, I get a bus error:

> [dmarin@boojum]$ pg_dump template1;
> Bus Error

> Is this a known problem, or would you like more information?)

Which pg_dump version is this?  Where is it crashing exactly (a stack
trace would help)?

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: now() and date_trunc() apparently corrupting data
Next
From: Joshua Moore-Oliva (by way of Joshua Moore-Oliva
Date:
Subject: Bug in AT TIME ZONE contruct between EST and INTERVAL '-05:00' (resubmit now that I am a member of this list)