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

Wrong result on INSERT..SELECT when converting from SIGNED to UNSIGNED

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4
    • Fix Version/s: 10.3.18, 10.4.8
    • Component/s: Data types
    • Labels:
      None

      Description

      CREATE OR REPLACE TABLE t1 (a TINYINT UNSIGNED);
      CREATE OR REPLACE TABLE t2 (a TINYINT);
      INSERT INTO t1 VALUES (255);
      INSERT IGNORE INTO t2 SELECT a FROM t1;
      SELECT * FROM t2;
      

      +------+
      | a    |
      +------+
      |   -1 |
      +------+
      

      Notice, an out of range unsigned value of 255 was silently converted to its negative complement.

      The expected result is 127 with a warning.

        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: