Re: Numeric x^y for negative x

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Yugo NAGATA <nagata(at)sraoss(dot)co(dot)jp>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Dave Page <dpage(at)pgadmin(dot)org>
Subject: Re: Numeric x^y for negative x
Date: 2021-08-06 16:15:18
Message-ID: 2492411.1628266518@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> So the "test for overflow by reverse-conversion" obviously isn't
> working as intended, and it's going through power_var_int() when it
> shouldn't. I don't think there's anything wrong with that code, so I
> think this is a compiler bug.

Yeah, looks like one.

> I guess the best thing to do is just test the value against
> PG_INT32_MIN/MAX, which is what int84() does. There are 2 other places
> in numeric.c that use similar code to check for int16/32 overflow, so
> it's possible that they're broken in the same way on that platform,
> but they aren't covered by the regression tests, so it's also possible
> that they're OK. Anyway, something like the attached seems likely to
> be safer.

Looks plausible by eyeball (I've not tested).

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2021-08-06 16:27:36 Re: [BUG] wrong refresh when ALTER SUBSCRIPTION ADD/DROP PUBLICATION
Previous Message Dean Rasheed 2021-08-06 16:06:20 Re: Numeric x^y for negative x