Re: extend pgbench expressions with functions

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: extend pgbench expressions with functions
Date: 2016-02-02 02:46:23
Message-ID: CAB7nPqRVfTz_C0mfQK-gbBF8Kc8aA5OLFD_2SpdBYth=rvOQUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 1, 2016 at 10:34 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Sat, Jan 30, 2016 at 7:36 AM, Michael Paquier
> <michael(dot)paquier(at)gmail(dot)com> wrote:
>> On Fri, Jan 29, 2016 at 11:21 PM, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> wrote:
>>> + /* overflow check (needed for INT64_MIN) */
>>> + if (lval != 0 && (*retval < 0 == lval < 0))
>>>
>>> Why not use "if (lval == INT64_MIN)" instead of this complicated condition?
>>> If it is really needed for some reason, I think that a comment could help.
>>
>> Checking for PG_INT64_MIN only would be fine as well, so let's do so.
>> I thought honestly that we had better check if the result and the left
>> argument are not of the same sign, but well.
>
> Committed and back-patched to 9.5. Doesn't apply further back.

OK, here are patches for 9.1~9.4. The main differences are that in
9.3/9.4 int64 is used for the division operations, and in 9.2/9.1
that's int32. In the latter case pgbench blows up the same way with
that:
\set i -2147483648
\set i :i / -1
select :i;
In those patches INT32_MIN/INT64_MIN need to be explicitly set as well
at the top of pgbench.c. I thing that's fine.
--
Michael

Attachment Content-Type Size
pgbench-div-crash-92-91.patch text/x-diff 1.4 KB
pgbench-div-crash-94-93.patch text/x-diff 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-02-02 03:01:36 Re: Several problems in tab-completions for SET/RESET
Previous Message Masahiko Sawada 2016-02-02 02:42:16 Re: Freeze avoidance of very large table.