Re: add modulo (%) operator to pgbench

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: add modulo (%) operator to pgbench
Date: 2014-08-06 06:25:42
Message-ID: alpine.DEB.2.10.1408060814010.24380@sto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Robert,

>> The issue is that there are 3 definitions of modulo, two of which are fine
>> (Knuth floored division and Euclidian), and the last one much less useful.
>> Alas, C (%) & SQL (MOD) choose the bad definition:-( I really need any of
>> the other two. The attached patch adds all versions, with "%" and "mod"
>> consistent with their C and SQL unfortunate counterparts, and "fmod" and
>> "emod" the sane ones.
>
> Three different modulo operators seems like a lot for a language that
> doesn't even have a real expression syntax, but I'll yield to whatever
> the consensus is on this one.

I agree that it is overkill.

In fact there is a link: if there was a real expression syntax, the
remainder sign could be fixed afterwards, so the standard C/SQL version
would do. If it is not available, the modulo operator must be right.

If there is only one modulo added, I would rather have the Knuth version.
However I was afraid that someone would object if "%" does not return the
same result than the C/PostgreSQL versions (even if I think that nearly
nobody has a clue about what % returns when arguments are negative), hence
the 3 modulo version to counter this potential critic.

But I would prefer just one version with the Knuth (or Euclidian)
definitions.

--
Fabien.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2014-08-06 06:31:14 Re: add modulo (%) operator to pgbench
Previous Message Fujii Masao 2014-08-06 06:09:10 Re: postgresql.auto.conf and reload