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

Inconsistency in to-integer conversion in DOUBLE UNSIGNED vs DECIMAL UNSIGNED

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
    • 10.3(EOL)
    • Data types
    • None

    Description

      CREATE OR REPLACE TABLE t1 (a BIGINT UNSIGNED, b DOUBLE UNSIGNED, c DECIMAL(30,0) UNSIGNED);
      INSERT INTO t1 VALUES(18446744073709551615,18446744073709551615,18446744073709551615);
      SELECT a, b, c, a << 0, b << 0, c << 0 FROM t1\G
      

      MariaDB [test]> SELECT a, b, c, a << 0, b << 0, c << 0 FROM t1\G
      *************************** 1. row ***************************
           a: 18446744073709551615
           b: 1.8446744073709552e19
           c: 18446744073709551615
      a << 0: 18446744073709551615
      b << 0: 9223372036854775807
      c << 0: 18446744073709551615
      1 row in set, 1 warning (0.00 sec)
      

      Notice, the result for `b << 0` is probably wrong.

      This happens because Field_double::val_int() does not take into accoung the UNSIGNED flag, while Field_new_decimal does.

      Note, this problem is repeatable with any function calling val_int(). The left shift operation is used only for demonstration purposes.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: