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

Warnings for EDOM vs truncation in val_int, val_real, val_decimal

    Details

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

      Description

      When a string value is insterted into an INT, DOUBLE or DECIMAL column, it send different warnings in case of EDOM errors (when they could not find any digits) and truncation errors:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (''),('123x');
      SHOW WARNINGS;
      
      +---------+------+-----------------------------------------------------+
      | Level   | Code | Message                                             |
      +---------+------+-----------------------------------------------------+
      | Warning | 1366 | Incorrect integer value: '' for column 'a' at row 1 |
      | Warning | 1265 | Data truncated for column 'a' at row 2              |
      +---------+------+-----------------------------------------------------+
      

      If I force implicit string-to-number conversion the other way around:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARCHAR(10));
      INSERT INTO t1 VALUES (''),('123x');
      SELECT a+1 FROM t1;
      SHOW WARNINGS;
      

      it does not distinguish between EDOM and truncation:

      +---------+------+------------------------------------------+
      | Level   | Code | Message                                  |
      +---------+------+------------------------------------------+
      | Warning | 1292 | Truncated incorrect DOUBLE value: ''     |
      | Warning | 1292 | Truncated incorrect DOUBLE value: '123x' |
      +---------+------+------------------------------------------+
      

      Functions and literals also do not distinguish between EDOM and truncation:

      SELECT ''+1,'123x'+1;
      SHOW WARNINGS;
      
      +---------+------+------------------------------------------+
      | Level   | Code | Message                                  |
      +---------+------+------------------------------------------+
      | Warning | 1292 | Truncated incorrect DOUBLE value: ''     |
      | Warning | 1292 | Truncated incorrect DOUBLE value: '123x' |
      +---------+------+------------------------------------------+
      

      In case of EDOM the warning tells about truncation, which is not true.

        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:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: