From: | "John Dickson" <jdickson(at)tnsi(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #5975: Incorrect result from mod function with cast |
Date: | 2011-04-13 00:30:12 |
Message-ID: | 201104130030.p3D0UCSZ076614@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 5975
Logged by: John Dickson
Email address: jdickson(at)tnsi(dot)com
PostgreSQL version: 8.3.11
Operating system: RedHat EL 5.6
Description: Incorrect result from mod function with cast
Details:
The mod function (and the % operator) can return an incorrect result when
combined with a cast().
The following SQL (executed on 8.3.11) shows a result one higher than the
maximum permissible remainder when combined with a cast:
-----
select 1129590 % 66,
cast(1129590 as numeric(21, 0)) % 66;
?column? | ?column?
----------+----------
0 | 66
(1 row)
-----
When executed on Postgres 8.2.5 (on Centos 4.6), the results are:
-----
?column? | ?column?
----------+----------
0 | 0
(1 row)
-----
We're using the cast here to demonstrate the bug, but we actually strike the
problem when operating on values from a numeric(21, 0) column rather than
using cast().
We haven't tested this on later releases of 8.3, but didn't see any likely
fixes in the changelog.
From | Date | Subject | |
---|---|---|---|
Next Message | Vlad Arkhipov | 2011-04-13 03:52:07 | BUG #5976: Corrupted pages on the production database |
Previous Message | Craig Ringer | 2011-04-12 23:26:29 | Re: BUG #5973: erreur SERIAL 4 |