Re: Bug in numeric_power() if exponent is INT_MIN - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Bug in numeric_power() if exponent is INT_MIN
Date
Msg-id 3160982.1609783162@sss.pgh.pa.us
Whole thread Raw
In response to Bug in numeric_power() if exponent is INT_MIN  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-hackers
Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> The issue is in this line from power_var_int():
>     sig_digits += (int) log(Abs(exp)) + 8;
> because "exp" is a signed int, so Abs(exp) leaves INT_MIN unchanged.
> The most straightforward fix is to use fabs() instead, so that "exp"
> is cast to double *before* the absolute value is taken, as in the
> attached patch.

Nice catch, and the fix seems appropriate.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Proposed patch for key management
Next
From: Michael Banck
Date:
Subject: data_checksums enabled by default (was: Move --data-checksums to common options in initdb --help)