Re: Rounding to even for numeric data type

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Pedro Gimeno <pgsql-004(at)personal(dot)formauri(dot)es>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Rounding to even for numeric data type
Date: 2015-04-22 12:46:35
Message-ID: CAB7nPqQuZL8XGiDDxZREkpiLJTDKGQODrfZvsNDDRJ=f9wjoFw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 22, 2015 at 9:30 PM, Pedro Gimeno
<pgsql-004(at)personal(dot)formauri(dot)es> wrote:
> Dean Rasheed wrote, On 2015-03-28 10:01:
>> On 28 March 2015 at 05:16, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
>>>>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>>>
>>> Tom> I think the concern over backwards compatibility here is probably
>>> Tom> overblown; but if we're sufficiently worried about it, a possible
>>> Tom> compromise is to invent a numeric_rounding_mode GUC, so that
>>> Tom> people could get back the old behavior if they really care.
>>>
>>> I only see one issue with this, but it's a nasty one: do we really want
>>> to make all numeric operations that might do rounding stable rather than
>>> immutable?
>>>
>>
>> Yeah, making all numeric functions non-immutable seems like a really bad idea.
>
> Would it be possible to make it an unchangeable per-cluster or
> per-database setting, kinda like how encoding behaves? Wouldn't that
> allow to keep the functions immutable?

Rounding is not something that can be enforced at the database or
server level but at data type level, see for example the differences
already present for double precision and numeric as mentioned
upthread. In short, you could keep rounding functions immutable by
having one data type with a different rounding method. At least that's
an idea.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2015-04-22 12:48:00 Re: Parallel Seq Scan
Previous Message Pedro Gimeno 2015-04-22 12:30:52 Re: Rounding to even for numeric data type