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

after changing YEAR function the value unexpectedly change

    XMLWordPrintable

Details

    Description

      after changing YEAR function the value unexpectedly change

      the problem is the same as MDEV-38577 and MDEV-38576,but the function is different

      mysql> SELECT YEAR(dkw78.c5) AS col_1 FROM  t3 AS dkw78;
      +-------+
      | col_1 |
      +-------+
      |  2026 |
      +-------+
      1 row in set (0.00 sec)
       
      mysql> SELECT YEAR(dkw78.c5 + INTERVAL '1' YEAR) - 1 AS col_1 FROM t3 AS dkw78;
      +-------+
      | col_1 |
      +-------+
      |  NULL |
      +-------+
      1 row in set, 1 warning (0.00 sec)
      

      How to repeat

      DROP DATABASE IF EXISTS test;
      CREATE DATABASE IF NOT EXISTS test;
      USE test;
       
      CREATE TABLE t3 (
          c5 TIME NULL
      );
       
      INSERT INTO t3 (c5) VALUES ( '2023-01-01 22:44:35');
       
      SELECT YEAR(dkw78.c5) AS col_1 FROM  t3 AS dkw78;
      SELECT YEAR(dkw78.c5 + INTERVAL '1' YEAR) - 1 AS col_1 FROM t3 AS dkw78;
      
      

      Version

      mysql> select version();
      +------------------------+
      | version()              |
      +------------------------+
      | 12.1.2-MariaDB-ubu2404 |
      +------------------------+
      1 row in set (0.00 sec)
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              chen7897 cl hl
              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.