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

Close-to-zero timestamps are converted into zero upon aggregation

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.4(EOL), 10.5, 10.6, 10.7(EOL)
    • 10.5, 10.6
    • Temporal Types
    • None

    Description

      The block below actually contains two test cases, with different engines and somewhat different queries. Choose whichever is more representative, or both.

      For nearly-zero timestamps (1970-01-01 00:00:00 with milliseconds), certain queries return 0000-00-00 instead.

      --source include/have_innodb.inc
       
      SET TIME_ZONE='+00:00';
       
      CREATE OR REPLACE TABLE t (b TIMESTAMP(2)) ENGINE=MyISAM;
      INSERT INTO t VALUES
        ('1970-01-01 00:00:00.01'),
        ('1985-01-23 06:27:59.00');
       
      SELECT MIN(b) FROM t;
       
      CREATE OR REPLACE TABLE t (a INT, b TIMESTAMP(2), KEY idx(a)) ENGINE=InnoDB;
      INSERT INTO t VALUES
        (1,'1970-01-01 00:00:00.01'),
        (2,'1985-01-23 06:27:59.00');
       
      SELECT MIN(b), a FROM t GROUP BY a;
      SELECT MIN(b), a FROM t IGNORE INDEX (idx) GROUP BY a;
       
      DROP TABLE t;
      

      10.4 20f22dfa

      SELECT MIN(b) FROM t;
      MIN(b)
      0000-00-00 00:00:00.00
      

      SELECT MIN(b), a FROM t GROUP BY a;
      MIN(b)	a
      0000-00-00 00:00:00.00	1
      1985-01-23 06:27:59.00	2
      SELECT MIN(b), a FROM t IGNORE INDEX (idx) GROUP BY a;
      MIN(b)	a
      1970-01-01 00:00:00.01	1
      1985-01-23 06:27:59.00	2
      

      Reproducible on 10.4+, with at least InnoDB and MyISAM, but it depends on the query/data.
      Not reproducible on 102-10.3.

      Attachments

        Activity

          People

            bar Alexander Barkov
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.