Re: pgsql: Fix NUMERIC modulus to properly truncate

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Fix NUMERIC modulus to properly truncate
Date: 2005-06-05 04:51:43
Message-ID: 911.1117947103@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> writes:
>> No, I don't think so. It doesn't seem to be something that enough
>> people use to risk the change in behavior --- it might break something
>> that was working. But, if folks want it backported we can do it. It is
>> only a change to properly do modulus for numeric.

> Well, from my point of view it's an absolute mathematical error - i'd
> backport it. I can't see anyone relying on it :)

Doesn't this patch break the basic theorem that

a = trunc(a / b) * b + (a mod b)

? If division rounds and mod doesn't, you've got pretty serious issues.

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2005-06-05 22:32:58 pgsql: Remove planner's private fields from Query struct, and put them
Previous Message Christopher Kings-Lynne 2005-06-05 04:02:07 Re: pgsql: Fix NUMERIC modulus to properly truncate

Browse pgsql-hackers by date

  From Date Subject
Next Message Dennis Bjorklund 2005-06-05 05:49:42 Re: lastval()
Previous Message John Hansen 2005-06-05 04:51:36 Re: Unicode characters above 0x10000 #2