BUG #14681: Erroneous modulo (%) result

Started by Marc Daelemansalmost 9 years ago6 messagesbugs
Jump to latest
#1Marc Daelemans
marc@daelemans.com

The following bug has been logged on the website:

Bug reference: 14681
Logged by: Marc Daelemans
Email address: marc@daelemans.com
PostgreSQL version: 9.6.3
Operating system: Win8.1 x64
Description:

select i, i&11 as j from generate_series ( 1, 100 ) i ;

generates correct results on Win7 SP1, x64; 16GB machine, and

erroneous results on another PC (Win8.1, x64, GB RAM).

The Win8.1 PC has Postgresql 9.6.3 and the Win7SP1 PC has Postgresql 9.6.0,
both with PGAdmin3 1.21.1 and identical installation parameters. The only
obvious difference is that the Win8.1 PG installation has Python3.3
installed as an extension (plpython3u), while the Win7 installation does
not. The error remains even after rebooting the Win8.1 PC, and starting PG
without other applications running. I can send a screenshot to show the
problem.
Very strange.
Marc Daelemans +32 475 421 413

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

#2Thomas Munro
thomas.munro@gmail.com
In reply to: Marc Daelemans (#1)
Re: BUG #14681: Erroneous modulo (%) result

On Thu, Jun 1, 2017 at 9:45 AM, <marc@daelemans.com> wrote:

select i, i&11 as j from generate_series ( 1, 100 ) i ;

That's bitwise AND, not modulo.

--
Thomas Munro
http://www.enterprisedb.com

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Marc Daelemans (#1)
Re: BUG #14681: Erroneous modulo (%) result

marc@daelemans.com wrote:

The following bug has been logged on the website:

Bug reference: 14681
Logged by: Marc Daelemans
Email address: marc@daelemans.com
PostgreSQL version: 9.6.3
Operating system: Win8.1 x64
Description:

select i, i&11 as j from generate_series ( 1, 100 ) i ;

Note that you're using the & operator (bitwise and) rather than % here.

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

#4Andres Freund
andres@anarazel.de
In reply to: Marc Daelemans (#1)
Re: BUG #14681: Erroneous modulo (%) result

On 2017-05-31 21:45:47 +0000, marc@daelemans.com wrote:

The following bug has been logged on the website:

Bug reference: 14681
Logged by: Marc Daelemans
Email address: marc@daelemans.com
PostgreSQL version: 9.6.3
Operating system: Win8.1 x64
Description:

select i, i&11 as j from generate_series ( 1, 100 ) i ;

Thats not the modulo operator? You're binary bitwise and-ing i and the
number 11 here.

generates correct results on Win7 SP1, x64; 16GB machine, and
erroneous results on another PC (Win8.1, x64, GB RAM).

Which results are you getting, and what you expecting?

Greetings,

Andres Freund

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

#5David G. Johnston
david.g.johnston@gmail.com
In reply to: Marc Daelemans (#1)
Re: BUG #14681: Erroneous modulo (%) result

On Wed, May 31, 2017 at 2:45 PM, <marc@daelemans.com> wrote:

The Win8.1 PC has Postgresql 9.6.3 and the Win7SP1 PC has Postgresql 9.6.0,
both with PGAdmin3 1.21.1 and identical installation parameters.

​Might want to run the same under psql to see if pgAdmin or the server is
the source of the discrepancy.

David J.​

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marc Daelemans (#1)
Re: BUG #14681: Erroneous modulo (%) result

marc@daelemans.com writes:

select i, i&11 as j from generate_series ( 1, 100 ) i ;
generates correct results on Win7 SP1, x64; 16GB machine, and
erroneous results on another PC (Win8.1, x64, GB RAM).

I'm suspicious that you have some extension that redefines the & operator
and is installed on just one of the two machines. Running "\do &" in
psql on both systems would be informative.

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs