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

2015-04-02 Thread Bruce Momjian
On Wed, Apr 1, 2015 at 11:48:37AM -0400, Bruce Momjian wrote: > This should return something like 16.000... (per Oracle > output at the URL above, float4 has 6 significant digits on my compiler) > but I can't seem to figure how to get printf() to round non-fractional > parts. I am afr

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

2015-04-01 Thread Bruce Momjian
On Tue, Mar 24, 2015 at 09:47:56AM -0400, Noah Misch wrote: > On Sun, Mar 22, 2015 at 10:53:12PM -0400, Bruce Momjian wrote: > > On Sun, Mar 22, 2015 at 04:41:19PM -0400, Noah Misch wrote: > > > On Wed, Mar 18, 2015 at 05:52:44PM -0400, Bruce Momjian wrote: > > > > This "junk" digit zeroing matches

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

2015-03-24 Thread Noah Misch
On Tue, Mar 24, 2015 at 03:08:26PM -0400, Bruce Momjian wrote: > On Tue, Mar 24, 2015 at 10:05:12AM -0400, Bruce Momjian wrote: > > On Tue, Mar 24, 2015 at 09:47:56AM -0400, Noah Misch wrote: > > > On Sun, Mar 22, 2015 at 10:53:12PM -0400, Bruce Momjian wrote: > > > > On Sun, Mar 22, 2015 at 04:41:

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

2015-03-24 Thread Noah Misch
On Tue, Mar 24, 2015 at 09:26:10AM -0700, Jeff Anton wrote: > The issue of significant (decimal) digits to and from floating point > representation is a complex one. > > What 'significant' means may depend upon the intent. True. I meant simply that Oracle TO_CHAR emits no more than 17 nonzero di

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

2015-03-24 Thread
essage- > From: pgsql-hackers-ow...@postgresql.org [mailto:pgsql-hackers- > ow...@postgresql.org] On Behalf Of Bruce Momjian > Sent: Tuesday, March 24, 2015 3:08 PM > To: Noah Misch > Cc: PostgreSQL-development > Subject: Re: [HACKERS] Zero-padding and zero-masking fixes for > t

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

2015-03-24 Thread Bruce Momjian
On Tue, Mar 24, 2015 at 10:05:12AM -0400, Bruce Momjian wrote: > On Tue, Mar 24, 2015 at 09:47:56AM -0400, Noah Misch wrote: > > On Sun, Mar 22, 2015 at 10:53:12PM -0400, Bruce Momjian wrote: > > > On Sun, Mar 22, 2015 at 04:41:19PM -0400, Noah Misch wrote: > > > > On Wed, Mar 18, 2015 at 05:52:44P

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

2015-03-24 Thread Andrew Gierth
> "Jeff" == Jeff Anton writes: Jeff> Postgresql seems to be using the first interpretation and Jeff> reporting fewer digits. I've noticed this with pg_dump. That a Jeff> dump and restore of floating point values does not produce the Jeff> same floating point values. To me, that is inex

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

2015-03-24 Thread Jeff Anton
The issue of significant (decimal) digits to and from floating point representation is a complex one. What 'significant' means may depend upon the intent. There are (at least) two different tests which may need to be used. * How many digits can be stored and then accurately returned? or * How

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

2015-03-24 Thread Bruce Momjian
On Tue, Mar 24, 2015 at 09:47:56AM -0400, Noah Misch wrote: > On Sun, Mar 22, 2015 at 10:53:12PM -0400, Bruce Momjian wrote: > > On Sun, Mar 22, 2015 at 04:41:19PM -0400, Noah Misch wrote: > > > On Wed, Mar 18, 2015 at 05:52:44PM -0400, Bruce Momjian wrote: > > > > This "junk" digit zeroing matches

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

2015-03-24 Thread Noah Misch
On Sun, Mar 22, 2015 at 10:53:12PM -0400, Bruce Momjian wrote: > On Sun, Mar 22, 2015 at 04:41:19PM -0400, Noah Misch wrote: > > On Wed, Mar 18, 2015 at 05:52:44PM -0400, Bruce Momjian wrote: > > > This "junk" digit zeroing matches the Oracle behavior: > > > > > > SELECT to_char(1.12345678912345

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

2015-03-23 Thread Bruce Momjian
On Mon, Mar 23, 2015 at 12:36:25AM -0400, Tom Lane wrote: > Bruce Momjian writes: > > On Sun, Mar 22, 2015 at 12:46:08PM -0400, Noah Misch wrote: > >> I recommend adding a "configure" test to use our snprintf.c replacements if > >> sprintf("%.*f", 65536, 999.0) gives unexpected output. >

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

2015-03-22 Thread Noah Misch
On Mon, Mar 23, 2015 at 12:36:25AM -0400, Tom Lane wrote: > Bruce Momjian writes: > > On Sun, Mar 22, 2015 at 12:46:08PM -0400, Noah Misch wrote: > >> I recommend adding a "configure" test to use our snprintf.c replacements if > >> sprintf("%.*f", 65536, 999.0) gives unexpected output. >

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

2015-03-22 Thread Tom Lane
Bruce Momjian writes: > On Sun, Mar 22, 2015 at 12:46:08PM -0400, Noah Misch wrote: >> I recommend adding a "configure" test to use our snprintf.c replacements if >> sprintf("%.*f", 65536, 999.0) gives unexpected output. > Do we really want to go to our /port snprintf just to handle 512+

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

2015-03-22 Thread Bruce Momjian
On Sun, Mar 22, 2015 at 10:53:12PM -0400, Bruce Momjian wrote: > > > *** int4_to_char(PG_FUNCTION_ARGS) > > > *** 5214,5221 > > > /* we can do it easily because float8 won't lose any > > > precision */ > > > float8 val = (float8) value;

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

2015-03-22 Thread Bruce Momjian
On Sun, Mar 22, 2015 at 04:41:19PM -0400, Noah Misch wrote: > When you posted this, I made a note to review it. > > On Wed, Mar 18, 2015 at 05:52:44PM -0400, Bruce Momjian wrote: > > This "junk" digit zeroing matches the Oracle behavior: > > > > SELECT to_char(1.123456789123456789123456789d,

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

2015-03-22 Thread Bruce Momjian
On Sun, Mar 22, 2015 at 12:46:08PM -0400, Noah Misch wrote: > On Sun, Mar 22, 2015 at 11:22:26AM -0400, Bruce Momjian wrote: > > What has me more concerned is the Solaris 10 failure. This query: > > > > SELECT to_char(float8 '999', 'D' || repeat('9', > > 1000)); > >

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

2015-03-22 Thread Noah Misch
When you posted this, I made a note to review it. On Wed, Mar 18, 2015 at 05:52:44PM -0400, Bruce Momjian wrote: > This "junk" digit zeroing matches the Oracle behavior: > > SELECT to_char(1.123456789123456789123456789d, > '9.9') as x from dual; >

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

2015-03-22 Thread Noah Misch
On Sun, Mar 22, 2015 at 11:22:26AM -0400, Bruce Momjian wrote: > What has me more concerned is the Solaris 10 failure. This query: > > SELECT to_char(float8 '999', 'D' || repeat('9', > 1000)); > > expects this: > > 999.000... > > but on Sola

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

2015-03-22 Thread Bruce Momjian
On Sun, Mar 22, 2015 at 01:42:56AM -0400, Tom Lane wrote: > David Rowley writes: > > This seems to have broken jacana. Looks like MSVC by default has a 3 digit > > exponent. > > jacana was broken before this patch; but some other Windows critters > are now unhappy as well. > > > Going by this:

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

2015-03-21 Thread Tom Lane
David Rowley writes: > This seems to have broken jacana. Looks like MSVC by default has a 3 digit > exponent. jacana was broken before this patch; but some other Windows critters are now unhappy as well. > Going by this: > https://msdn.microsoft.com/en-us/library/0fatw238(v=vs.80).aspx it seems

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

2015-03-21 Thread David Rowley
On 22 March 2015 at 14:46, Bruce Momjian 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

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

2015-03-21 Thread Bruce Momjian
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.