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

CAST(date_sp_variable AS TIME) returns a wrong result

    XMLWordPrintable

Details

    Description

      mysql> SELECT CAST(DATE'2001-01-01' AS TIME);
      +--------------------------------+
      | CAST(DATE'2001-01-01' AS TIME) |
      +--------------------------------+
      | 00:00:00                       |
      +--------------------------------+
      1 row in set (0.00 sec)
       
      mysql> DROP PROCEDURE IF EXISTS p1;
      Query OK, 0 rows affected (0.02 sec)
       
      mysql> DELIMITER |;
      mysql> create procedure p1()
          -> begin
          ->   declare t date;
          ->   set t=date'2001-01-01';
          ->   select cast(t as time);
          -> end|;
      Query OK, 0 rows affected (0.04 sec)
       
      mysql> CALL p1|;
      +-----------------+
      | cast(t as time) |
      +-----------------+
      | 00:20:01        |
      +-----------------+
      1 row in set (0.00 sec)
       
      Query OK, 0 rows affected, 1 warning (0.00 sec)

      The two SELECT queries should return the same result.

      The problem happens because Item_splocal::get_date() points
      to the generic Item::get_date(), so the conversion happens through a
      temporary string value: time -> string -> date.

      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.