"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Andy Balholm <andy@balholm.com> wrote:
>> On Jun 21, 2010, at 11:47 AM, Kevin Grittner wrote:
>> I deleted the excess comments and moved some lines around. Here it
>> is with the changes.
> I ran pgindent to standardize the white space. (No changes of
> substance.) Patch attached.
> I'll mark it "Ready for Committer".
Applied with some editorial changes. The noncosmetic changes were:
* I didn't like this bit in cash_numeric():
result->n_sign_dscale = NUMERIC_SIGN(result) | fpoint;
Not only is that unwarranted chumminess with the implementation of
numeric, it's flat-out wrong. If the result isn't exactly the right
number of digits (say, it's 12.33999999 instead of the desired 12.34)
this just hides the extra digits, it doesn't make the result correct.
The right way is to use numeric_round(), which not only sets the dscale
where we want it but rounds off any inaccuracy that might have crept in
from the division.
* The cast functions were marked immutable, which is wrong because they
depend on the setting of lc_monetary. The right marking is "stable".
It struck me in connection with the latter that cash_in and cash_out
were also improperly marked as immutable --- they also depend on
lc_monetary and so can be no better than stable. I changed that
in this commit. I'm not sure if it's worth trying to back-patch;
in practice people probably aren't changing lc_monetary on the fly,
and the volatility of I/O functions is usually not that interesting
anyway.
regards, tom lane