Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-17274

Split Field_temporal_with_date::store*() for Field_date_common and Field_datetime

    XMLWordPrintable

Details

    Description

      This task is to do the following:

      • Remove Field_temporal_with_date::store_TIME_with_warning() and add Field_date_common::store_TIME_with_warning() and Field_datetime::store_TIME_with_warning() instead.
      • Remove Field_temporal_with_date's methods store(), store_time_dec(), store_decimal(), and add them in Field_date_common and Field_datetime instead.

      Rationale:

      1. We're adding an option to choose between temporal rounding vs truncation soon (MDEV-16991). There will be a difference in rounding behavior when storing data into a DATE vs a DATETIME field. DATE won't do rounding in many cases where DATETIME will. To make the code simpler, it's good to split the DATE and the DATETIME logic. To make the main patch for MDEV-16991 simple, it's a good idea to split these methods in a separate self-sufficient commit.

      2. As an additional argument: MYSQL_TIME is too redundant for DATE and TIME. It's size is 40 bytes. In many places of the server code MYSQL_TIME can be replaced to smaller structures consisting of only YYYYMMDD for DATE (4 bytes should be enough) and hhmmssff for TIME (8 bytes should be enough, or even less). Some examples of places places where MYSQL_TIME can be replaced in favor of DATE/TIME smaller structures:

      • The ltime argument of Field_date::store_TIME() and Field_time::store_TIME()
      • The output data type for Item_datefunc::get_date() and Item_timefunc::get_date().
      • Item_date_literal, Item_time_literal
      • Item_cache_date, Item_cache_time
        Btw, MYSQL_TIME is even redundant for DATETIME because it uses unsigned int and unsigned long members excessively, as well as four bytes for timesamp_type. So even to handle DATETIME values, it will be good to replace MYSQL_TIME time (at some point in the future) to some new smaller structures. So we'll end up in three new classes Time,Date and Datetime (which won't derive from MYSQL_TIME any more). In this approach, Field_date_common::store_TIME_with_warning and Field_datetime::store_TIME_with_warning() will use different data types (Date vs Datetime) anyway. Splitting the mentioned methods of Field_temporal_with_date is a good step to this.

      As a bad side there will be some (very small) amount of similar code in Field_date_common::store*() and Field_datetime::store*(). But only before MDEV-16991 is done. After MDEV-16991 the code will be too different.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.