Re: Zero-padding and zero-masking fixes for to_char(float)

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Zero-padding and zero-masking fixes for to_char(float)
Date: 2015-03-22 05:04:52
Message-ID: CAApHDvoRDz8kCdfYzgRCPDEfLMqK0F6U_78nJ-JajxyJ7ufvHA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 22 March 2015 at 14:46, Bruce Momjian <bruce(at)momjian(dot)us> wrote:

> On Wed, Mar 18, 2015 at 05:52:44PM -0400, Bruce Momjian wrote:
> > In September, while researching the to_char() buffer overflow bugs fixed
> > in 9.4.1 (commit 0150ab567bcf5e5913e2b62a1678f84cc272441f), I found an
> > inconsistency in how to_char() does zero-padding for float4/8 values.
> > Now that 9.4.1 is released and I am home for a while, I am ready to
> > address this.
> ...
> > float4/8 are padding to the internal precision, while int4/numeric are
> > padding based on the requested precision. This is inconsistent.
> >
> > The first attached patch fixes this, and also zeros the "junk" digits
> > which exceed the precision of the underlying type:
>
> Patch applied.
>
>
This seems to have broken jacana. Looks like MSVC by default has a 3 digit
exponent.

Going by this:
https://msdn.microsoft.com/en-us/library/0fatw238(v=vs.80).aspx it seems
that it can quite easily be set back to 2.

I've attached a patch which seems to fix the issue.

Regards

David Rowley

Attachment Content-Type Size
2digit_exponent.diff text/plain 659 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-03-22 05:17:28 Re: Using 128-bit integers for sum, avg and statistics aggregates
Previous Message Pavel Stehule 2015-03-22 04:45:54 Re: [PATCH] Add transforms feature