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

CAST(field_bit AS TIME) does not work well

    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:

      Description

      The BIT field works well as a number in most cases,
      but not when casting it to temporal data types:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a BIT(8));
      INSERT INTO t1 VALUES (0xFF);
      SELECT a+0,CAST(255 AS TIME), CAST(a AS TIME) FROM t1;
      SHOW WARNINGS;
      

      returns

      +------+-------------------+-----------------+
      | a+0  | CAST(255 AS TIME) | CAST(a AS TIME) |
      +------+-------------------+-----------------+
      |  255 | 00:02:55          | 00:00:00        |
      +------+-------------------+-----------------+
      1 row in set, 1 warning (0.00 sec)
      
      +---------+------+----------------------------------------+
      | Level   | Code | Message                                |
      +---------+------+----------------------------------------+
      | Warning | 1292 | Truncated incorrect time value: '\xFF' |
      +---------+------+----------------------------------------+
      

      The expected result for CAST(a AS TIME) is '00:02:55'
      without warnings.

        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 -

            MySQL 5.5/5.6/5.7 are also affected (I don't know if there is a bug report about it).

            Show
            elenst Elena Stepanova added a comment - MySQL 5.5/5.6/5.7 are also affected (I don't know if there is a bug report about it).

              People

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

                Dates

                • Created:
                  Updated: