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

Field of type FLOAT does not cast well to integer

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.3.12, 5.5.36, 10.0.9
    • Fix Version/s: 10.0, 5.5
    • Component/s: None
    • Labels:
      None

      Description

      This SQL script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DOUBLE, b FLOAT);
      INSERT INTO t1 VALUES (1.1e30,1.2e30);
      SELECT CAST(a AS SIGNED),CAST(b as SIGNED) FROM t1;
      SHOW WARNINGS;
      

      returns a wrong result for the FLOAT field:

      +---------------------+----------------------+
      | CAST(a AS SIGNED)   | CAST(b as SIGNED)    |
      +---------------------+----------------------+
      | 9223372036854775807 | -9223372036854775808 |
      +---------------------+----------------------+
      1 row in set, 1 warning (0.00 sec)
      

      The expected result should be 9223372036854775807,
      the same with the DOUBLE field.

      Also, a warning is not generated for the FLOAT field.
      It is generated for the DOUBLE field only:

      +---------+------+---------------------------------------------+
      | Level   | Code | Message                                     |
      +---------+------+---------------------------------------------+
      | Warning | 1292 | Truncated incorrect INTEGER value: '1.1e30' |
      +---------+------+---------------------------------------------+
      1 row in set (0.00 sec)
      

      FLOAT should be fixed to generate warnings, like DOUBLE does.

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

                Dates

                • Created:
                  Updated: