Re: Improve performance of pg_strtointNN functions

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>, John Naylor <john.naylor@enterprisedb.com>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2022-12-04T23:03:26Z
Lists: pgsql-hackers
On Sun, 4 Dec 2022 at 22:53, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
> Ah, I see that you changed the overflow test, and I realise that I
> forgot to answer your question about why I wrote that as 1 - INT_MIN /
> 10 over on the other thread.
>
> The reason is that we need to detect whether tmp * base will exceed
> -INT_MIN, not INT_MAX, since we're accumulating the absolute value of
> a signed integer.

I think I'd been too focused on the simplicity of that expression and
also the base 10 part. I saw that everything worked in base 10 and
failed to give enough forward thought to other bases.

I now see that it was wrong-headed to code it the way I had it.
Thanks for pointing this out. I've just pushed a fix.

David



Commits

  1. Fix thinko introduced in 6b423ec67

  2. Improve performance of pg_strtointNN functions