Re: Fix number skipping in to_number

From: Oliver Ford <ojford(at)gmail(dot)com>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix number skipping in to_number
Date: 2017-08-17 09:48:33
Message-ID: CAGMVOdtMSdaRPV0Nw7pOUoyFhjMrNi9XmFyC5-PTD78LGUokzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> The tests you added pass for me but the int8 test now fails with the
> following (this is from regression.diff after running
> 'PG_REGRESS_DIFF_OPTS="-dU10" make check'). It looks like some new
> whitespace is appearing on the right in the output of to_char(). I
> didn't try to understand why.
>
> @@ -453,34 +453,34 @@
> ------------------+------------------
> 4567890123456789 | 4567890123456789
> (1 row)
>
> -- TO_CHAR()
> --
> SELECT '' AS to_char_1, to_char(q1, '9G999G999G999G999G999'),
> to_char(q2, '9,999,999,999,999,999')
> FROM INT8_TBL;
> to_char_1 | to_char | to_char
> -----------+------------------------+------------------------
> - | 123 | 456
> + | 123 | 456
> | 123 | 4,567,890,123,456,789
> - | 4,567,890,123,456,789 | 123
> + | 4,567,890,123,456,789 | 123
> | 4,567,890,123,456,789 | 4,567,890,123,456,789
> | 4,567,890,123,456,789 | -4,567,890,123,456,789
> (5 rows)
>
> SELECT '' AS to_char_2, to_char(q1, '9G999G999G999G999G999D999G999'),
> to_char(q2, '9,999,999,999,999,999.999,999')
> FROM INT8_TBL;
> to_char_2 | to_char | to_char
> -----------+--------------------------------+--------------------------------
> - | 123.000,000 | 456.000,000
> + | 123.000,000 | 456.000,000
> | 123.000,000 | 4,567,890,123,456,789.000,000
> - | 4,567,890,123,456,789.000,000 | 123.000,000
> + | 4,567,890,123,456,789.000,000 | 123.000,000
> | 4,567,890,123,456,789.000,000 | 4,567,890,123,456,789.000,000
> | 4,567,890,123,456,789.000,000 | -4,567,890,123,456,789.000,000
> (5 rows)
>
> SELECT '' AS to_char_3, to_char( (q1 * -1), '9999999999999999PR'),
> to_char( (q2 * -1), '9999999999999999.999PR')
> FROM INT8_TBL;
> to_char_3 | to_char | to_char
> -----------+--------------------+------------------------
> | <123> | <456.000>
> | <123> | <4567890123456789.000>
>

That's strange, I can't replicate that issue on my Windows build. I've
tried with 'PG_REGRESS_DIFF_OPTS="-dU10" make check' and all the tests
(including int8) pass fine. The spacing in the results is perfectly
normal. I wonder if something else on your build is causing this? I've
also tried several "make check" options for different locales
mentioned in the docs and they pass fine.

>
> One superficial comment after first glimpse at the patch:
>
> + if(!strncmp(Np->inout_p, Np->L_thousands_sep, separator_len))
>
> I believe the usual coding around here would be if (strncmp(...) == 0)
>

Yes you're right, that is the coding standard. I've changed it to that
in the attached v2.

Attachment Content-Type Size
0001-apply-number-v2.patch application/octet-stream 3.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2017-08-17 09:55:45 Re: [HACKERS] [postgresql 10 beta3] unrecognized node type: 90
Previous Message Simon Riggs 2017-08-17 09:24:23 Re: recovery_target_time = 'now' is not an error but still impractical setting