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

Inconsistent warnings when inserting a DATETIME-alike data into a TIME column

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.1.67, 5.2.14, 5.3.12, 5.5.36, 10.0.10
    • Fix Version/s: 10.0
    • Component/s: None
    • Labels:
      None

      Description

      mysql> DROP TABLE IF EXISTS t1;
      Query OK, 0 rows affected (0.03 sec)
      
      mysql> CREATE TABLE t1 (from_str TIME, from_int TIME,from_dec TIME, from_double TIME);
      Query OK, 0 rows affected (0.15 sec)
      
      mysql> INSERT INTO t1 VALUES ('2001-01-01 10:20:30',20010101102030,20010101102030.0,20010101102030e0);
      Query OK, 1 row affected, 4 warnings (0.01 sec)
      
      mysql> SHOW WARNINGS;
      +---------+------+--------------------------------------------------+
      | Level   | Code | Message                                          |
      +---------+------+--------------------------------------------------+
      | Note    | 1265 | Data truncated for column 'from_str' at row 1    |
      | Warning | 1265 | Data truncated for column 'from_int' at row 1    |
      | Warning | 1265 | Data truncated for column 'from_dec' at row 1    |
      | Warning | 1265 | Data truncated for column 'from_double' at row 1 |
      +---------+------+--------------------------------------------------+
      4 rows in set (0.00 sec)
      
      mysql> SELECT * FROM t1;
      +----------+----------+----------+-------------+
      | from_str | from_int | from_dec | from_double |
      +----------+----------+----------+-------------+
      | 10:20:30 | 10:20:30 | 10:20:30 | 10:20:30    |
      +----------+----------+----------+-------------+
      1 row in set (0.00 sec)
      

      Notice, string gives a note while the numeric types give warnings.

      A note seems to be the most appropriate in all cases.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            what versions are affected?

            Show
            serg Sergei Golubchik added a comment - what versions are affected?
            Hide
            elenst Elena Stepanova added a comment -

            All MariaDB versions are affected, although in a different way.
            5.3, 5.5, 10.0 produce the result from the description.

            5.1 and 5.2 (and MySQL 5.5) produce the following:

            +---------+------+------------------------------------------------------+
            | Level   | Code | Message                                              |
            +---------+------+------------------------------------------------------+
            | Warning | 1264 | Out of range value for column 'from_int' at row 1    |
            | Warning | 1264 | Out of range value for column 'from_dec' at row 1    |
            | Warning | 1264 | Out of range value for column 'from_double' at row 1 |
            +---------+------+------------------------------------------------------+
            
            MariaDB [test]> SELECT * FROM t1;
            +----------+-----------+-----------+-------------+
            | from_str | from_int  | from_dec  | from_double |
            +----------+-----------+-----------+-------------+
            | 10:20:30 | 838:59:59 | 838:59:59 | 838:59:59   |
            +----------+-----------+-----------+-------------+
            

            MySQL 5.6 returns 'Note' and '10:20:30' for all columns.

            Show
            elenst Elena Stepanova added a comment - All MariaDB versions are affected, although in a different way. 5.3, 5.5, 10.0 produce the result from the description. 5.1 and 5.2 (and MySQL 5.5) produce the following: +---------+------+------------------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------------------+ | Warning | 1264 | Out of range value for column 'from_int' at row 1 | | Warning | 1264 | Out of range value for column 'from_dec' at row 1 | | Warning | 1264 | Out of range value for column 'from_double' at row 1 | +---------+------+------------------------------------------------------+ MariaDB [test]> SELECT * FROM t1; +----------+-----------+-----------+-------------+ | from_str | from_int | from_dec | from_double | +----------+-----------+-----------+-------------+ | 10:20:30 | 838:59:59 | 838:59:59 | 838:59:59 | +----------+-----------+-----------+-------------+ MySQL 5.6 returns 'Note' and '10:20:30' for all columns.

              People

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

                Dates

                • Created:
                  Updated: