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

CAST(date_sp_variable AS TIME) returns a wrong result

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.5.35, 10.0.8
    • Fix Version/s: 10.0, 5.5
    • Component/s: None
    • Labels:
      None

      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.

        Gliffy Diagrams

          Attachments

            Activity

            There are no comments yet on this issue.

              People

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

                Dates

                • Created:
                  Updated: