Thread: Re: [COMMITTERS] pgsql: Check for ERANGE in exp() as well.

Re: [COMMITTERS] pgsql: Check for ERANGE in exp() as well.

From
Stefan Kaltenbrunner
Date:
Bruce Momjian wrote:
> Log Message:
> -----------
> Check for ERANGE in exp() as well.

this broke the regression tests on a number of boxes:

http://buildfarm.postgresql.org/cgi-bin/show_status.pl

example:

http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sponge&dt=2007-01-06%2015:30:02


Stefan


Re: [COMMITTERS] pgsql: Check for ERANGE in exp()

From
Bruce Momjian
Date:
Stefan Kaltenbrunner wrote:
> Bruce Momjian wrote:
> > Log Message:
> > -----------
> > Check for ERANGE in exp() as well.
>
> this broke the regression tests on a number of boxes:
>
> http://buildfarm.postgresql.org/cgi-bin/show_status.pl
>
> example:
>
> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sponge&dt=2007-01-06%2015:30:02

Thanks.  This is something I wanted to ask Tom about today.  I was
worried that ERANGE could be generated by underflow as well as overflow,
and setting result to Inf would not work for underflow.  I have applied
the following patch to test for != 0 and != Inf, which should elimintate
the underflow case.

Tom, on HPPA, does ERANGE get set for both overflow and underflow?  I
assume only overflow.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/utils/adt/float.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/float.c,v
retrieving revision 1.145
diff -c -c -r1.145 float.c
*** src/backend/utils/adt/float.c    6 Jan 2007 15:18:02 -0000    1.145
--- src/backend/utils/adt/float.c    6 Jan 2007 20:15:22 -0000
***************
*** 1459,1465 ****
          else
              result = 1;
      }
!     else if (errno == ERANGE && !isinf(result))
          result = get_float8_infinity();

      CHECKFLOATVAL(result, isinf(arg1) || isinf(arg2), arg1 == 0);
--- 1459,1465 ----
          else
              result = 1;
      }
!     else if (errno == ERANGE && result != 0 && !isinf(result))
          result = get_float8_infinity();

      CHECKFLOATVAL(result, isinf(arg1) || isinf(arg2), arg1 == 0);
***************
*** 1478,1484 ****

      errno = 0;
      result = exp(arg1);
!     if (errno == ERANGE && !isinf(result))
          result = get_float8_infinity();

      CHECKFLOATVAL(result, isinf(arg1), false);
--- 1478,1484 ----

      errno = 0;
      result = exp(arg1);
!     if (errno == ERANGE && result != 0 && !isinf(result))
          result = get_float8_infinity();

      CHECKFLOATVAL(result, isinf(arg1), false);

Re: [COMMITTERS] pgsql: Check for ERANGE in exp()

From
Tom Lane
Date:
Bruce Momjian <bruce@momjian.us> writes:
> Tom, on HPPA, does ERANGE get set for both overflow and underflow?  I
> assume only overflow.

Yeah, AFAICT exp() just returns zero for underflow cases.  I get

regression=# select exp(-2000);
ERROR:  value out of range: underflow

but I was getting that before your last patch, too.
        regards, tom lane


Re: [COMMITTERS] pgsql: Check for ERANGE in exp()

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Tom, on HPPA, does ERANGE get set for both overflow and underflow?  I
> > assume only overflow.
> 
> Yeah, AFAICT exp() just returns zero for underflow cases.  I get
> 
> regression=# select exp(-2000);
> ERROR:  value out of range: underflow
> 
> but I was getting that before your last patch, too.

Uh, if you were getting that before my last patch, then I don't think
you return ERANGE for underflow.

--  Bruce Momjian   bruce@momjian.us EnterpriseDB    http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +