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

Integer type columns silently truncate fractional digits

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.1, 10.0, 5.5
    • Fix Version/s: 10.1
    • Component/s: OTHER
    • Labels:

      Description

      This script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (10.1)
      

      produces no warnings or notes though truncation happens.

      The DECIMAL data type in the same scenario does produce a note:

       DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DECIMAL(10,0));
      INSERT INTO t1 VALUES (10.1);
      SHOW WARNINGS;
      
      +-------+------+----------------------------------------+
      | Level | Code | Message                                |
      +-------+------+----------------------------------------+
      | Note  | 1265 | Data truncated for column 'a' at row 1 |
      +-------+------+----------------------------------------+
      

      CAST from DECIMAL to INT on SELECT also does not produce warnings:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DECIMAL(10,1));
      INSERT INTO t1 VALUES (10.1);
      SELECT CAST(a AS SIGNED) FROM t1;
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            bar Alexander Barkov added a comment -

            Repeatable in MySQL-5.7

            Show
            bar Alexander Barkov added a comment - Repeatable in MySQL-5.7

              People

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

                Dates

                • Created:
                  Updated: