Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-6486

Phoenix uses inconsistent chronologies internally, breaking pre-Gregorian date handling

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.1.1, 4.16.1
    • 4.17.0, 5.2.0, 4.16.2, 5.1.3
    • core
    • None

    Description

      For context:
      This is only a problem when storing dates before the Gregorian cutover, ie.
      October 15, 1582.
      Dates after that time are not affected.

      Phoenix does a lot of internal Time processing using JodaTime.
      However, the default Chronology for JodaTime is ISO,
      while the default chronology used by the JDK is GregorianJulian
      https://www.joda.org/joda-time/cal_gj.html

      This causes pre-cutover date handling to fail spectacularly:

      > create table bubu (id integer primary key, ts timestamp);
      1 row affected (0.059 seconds)
      > upsert into bubu values (1, '1-1-1 0:0:0');
      1 row affected (0.007 seconds)
      > select * from bubu;
      +----+-----------------------+
      | ID |          TS           |
      +----+-----------------------+
      | 1  | 0001-01-03 01:00:00.0 |
      +----+-----------------------+
      1 row selected (0.014 seconds)
      > select id, year(ts), month(ts), dayofmonth(ts), hour(ts), minute(ts), second(ts) from bubu;
      +----+----------+-----------+----------------+----------+------------+------------+
      | ID | YEAR(TS) | MONTH(TS) | DAYOFMONTH(TS) | HOUR(TS) | MINUTE(TS) | SECOND(TS) |
      +----+----------+-----------+----------------+----------+------------+------------+
      | 1  | 1        | 1         | 1              | 0        | 0          | 0          |
      +----+----------+-----------+----------------+----------+------------+------------+
      1 row selected (0.014 seconds)
      

      The one hour difference is coming from my being in CET instead of GMT.
      This specific problem is the two day difference.

      Attachments

        Activity

          People

            richardantal Richárd Antal
            stoty Istvan Toth
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: