Thread: [BUGS] BUG #14681: Erroneous modulo (%) result

[BUGS] BUG #14681: Erroneous modulo (%) result

From
marc@daelemans.com
Date:
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

Re: [BUGS] BUG #14681: Erroneous modulo (%) result

From
Thomas Munro
Date:
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

Re: [BUGS] BUG #14681: Erroneous modulo (%) result

From
Alvaro Herrera
Date:
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

Re: [BUGS] BUG #14681: Erroneous modulo (%) result

From
Andres Freund
Date:
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

Re: [BUGS] BUG #14681: Erroneous modulo (%) result

From
"David G. Johnston"
Date:
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.​

Re: [BUGS] BUG #14681: Erroneous modulo (%) result

From
Tom Lane
Date:
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