رد: BUG #16419: wrong parsing BC year in to_date() function

دار الآثار للنشر والتوزيع-صنعاء Dar Alathar-Yemen <dar_alathar@hotmail.com>

From: دار الآثار للنشر والتوزيع-صنعاء Dar Alathar-Yemen <dar_alathar@hotmail.com>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2020-05-07T10:23:35Z
Lists: pgsql-bugs, pgsql-hackers
To make "to_date" work as "make_date" with negative years these llines:
https://github.com/postgres/postgres/blob/fb544735f11480a697fcab791c058adc166be1fa/src/backend/utils/adt/formatting.c#L4559-L4560 :
                                            if (tmfc.bc && tm->tm_year > 0)
                                                           tm->tm_year = -(tm->tm_year - 1);
must be changed to:
                                            if (tmfc.bc && tm->tm_year > 0)
                                            {
                                                           tm->tm_year = -(tm->tm_year - 1);
                                            }
                                            else if (tm->tm_year < 0) {
                                                           tm->tm_year ++;
                                             }


Commits

  1. Fix handling of BC years in to_date/to_timestamp.

  2. Fix make_timestamp[tz] to accept negative years as meaning BC.

  3. doc: PG 13 relnotes, update TOAST item to mention decompression