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

Conversion from string to number is inconsistent

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.5.36, 10.0.9
    • 5.5(EOL)
    • None
    • None

    Description

      This SQL script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES ('10.6');
      SELECT a, CAST('10.6' AS SIGNED) FROM t1;
      SHOW WARNINGS;

      returns:

      +------+------------------------+
      | a    | CAST('10.6' AS SIGNED) |
      +------+------------------------+
      |   11 |                     10 |
      +------+------------------------+
      1 row in set, 1 warning (0.00 sec)
      +---------+------+-------------------------------------------+
      | Level   | Code | Message                                   |
      +---------+------+-------------------------------------------+
      | Warning | 1292 | Truncated incorrect INTEGER value: '10.6' |
      +---------+------+-------------------------------------------+
      1 row in set (0.00 sec)

      Notice, when converting to a field, it rounds silently.
      When converting in CAST, it truncates with a warning.

      It should be fixed to expose similar behaviour in both cases.

      The questions is: which of them is correct?

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.