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

BINARY, VARBINARY and BLOB return different warnings on CAST to DECIMAL

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.1, 10.0
    • Fix Version/s: 10.0.21
    • Component/s: OTHER
    • Labels:
      None

      Description

      • BINARY

        SET NAMES utf8;
        DROP TABLE IF EXISTS t1;
        CREATE TABLE t1 (a BINARY(30));
        INSERT INTO t1 VALUES ('1äÖüß@µ*$');
        SELECT CAST(a AS DECIMAL) FROM t1;
        SHOW WARNINGS;

        +---------+------+---------------------------------------------------------------------------------------------------------------------------------------------------+
        | Level   | Code | Message                                                                                                                                           |
        +---------+------+---------------------------------------------------------------------------------------------------------------------------------------------------+
        | Warning | 1292 | Truncated incorrect DECIMAL value: '1\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
        +---------+------+---------------------------------------------------------------------------------------------------------------------------------------------------+

      • VARBINARY

        SET NAMES utf8;
        DROP TABLE IF EXISTS t1;
        CREATE TABLE t1 (a VARBINARY(30));
        INSERT INTO t1 VALUES ('1äÖüß@µ*$');
        SELECT CAST(a AS DECIMAL) FROM t1;
        SHOW WARNINGS;

        +---------+------+-----------------------------------------------------+
        | Level   | Code | Message                                             |
        +---------+------+-----------------------------------------------------+
        | Warning | 1292 | Truncated incorrect DECIMAL value: '1äÖüß@µ*$'      |
        +---------+------+-----------------------------------------------------+

      • BLOB

        SET NAMES utf8;
        DROP TABLE IF EXISTS t1;
        CREATE TABLE t1 (a BLOB);
        INSERT INTO t1 VALUES ('1äÖüß@µ*$');
        SELECT CAST(a AS DECIMAL) FROM t1;
        SHOW WARNINGS;

        Empty set (0.00 sec)

      BINARY looks the most correct.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: