Re: to_char(OF) is broken - Mailing list pgsql-bugs

From Thomas Munro
Subject Re: to_char(OF) is broken
Date
Msg-id CAEepm=2qtgGwMqJN8yZo572J3_rr1oWGYsCzOYj0-cB6=QHZnw@mail.gmail.com
Whole thread Raw
In response to Re: to_char(OF) is broken  (Thomas Munro <thomas.munro@enterprisedb.com>)
Responses Re: to_char(OF) is broken
List pgsql-bugs
On Thu, Mar 17, 2016 at 3:23 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Thu, Mar 17, 2016 at 3:02 AM, David Fetter <david@fetter.org> wrote:
>> Folks,
>>
>> In to_char(), the new-in-9.4 'OF' feature is straight-up broken, to
>> wit:
>>
>> set timezone to 'America/Caracas'; select to_char(now(), 'OF');
>> SET
>>  to_char
>> ─────────
>>  -04:-30
>>  ^OK ^NOT OK
>>
>> Interestingly, in git master as of yesterday, it's broken in an
>> entirely different way:
>>
>> set timezone to 'America/Caracas'; select to_char(now(), 'OF');
>> SET
>>  to_char
>> ─────────
>>  -004:30
>>   ^ What's this extra zero doing here?
>> (1 row)
>>
>> Fractional offset time zones should probably be in our regression test
>> suite for this feature.
>
> It looks like 2d87eedc made adjustments in accounting for padding
> negative numbers in several places, but the case of OF is different
> than the other places because it also has a sign for positive numbers,
> so no adjustment was necessary there.  See attached.

... and 9.4 has a different bug as you showed (missing abs).  Here's a
patch for 9.4 that uses the same code as master for that switch case
(and adds the same regression test).

9.5 doesn't have either of the bugs, but might as well have the same
regression test just to show that.

--
Thomas Munro
http://www.enterprisedb.com

Attachment

pgsql-bugs by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: [HACKERS] pgbench -C -M prepared gives an error
Next
From: Fabien COELHO
Date:
Subject: Re: [HACKERS] pgbench -C -M prepared gives an error