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

Partial dates validation doesn't keep into account leap years

    XMLWordPrintable

Details

    Description

      MariaDB supports dates with zero-components:

      MariaDB [(none)]> SELECT @@sql_mode;
      +------------+
      | @@sql_mode |
      +------------+
      |            |
      +------------+
      1 row in set (0.000 sec)
       
      MariaDB [(none)]> SELECT '2000-01-00';
      +------------+
      | 2000-01-00 |
      +------------+
      | 2000-01-00 |
      +------------+
      1 row in set (0.000 sec)
      

      Date validation is made based on the available information. For example, if the month is missing, MariaDB will only check that the day part is <= 31:

      MariaDB [(none)]> SELECT DATE '2000-00-31'; 
      +-------------------+
      | DATE '2000-00-31' |
      +-------------------+
      | 2000-00-31        |
      +-------------------+
      1 row in set (0.000 sec)
       
      MariaDB [(none)]> SELECT DATE '2000-00-32';
      ERROR 1525 (HY000): Incorrect DATE value: '2000-00-32'
      

      If the month is February and the year is zero, I'd expect that the day can be 29, to accomodate leap years. But it's not the case:

      MariaDB [(none)]> SELECT DATE '0000-02-29'; 
      ERROR 1525 (HY000): Incorrect DATE value: '0000-02-29'
      

      In my opinion, this is a bug.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              f_razzoli Federico Razzoli
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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