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

Integer type columns silently truncate fractional digits

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.3.4, 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
    • 10.2(EOL)
    • OTHER

    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;

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.