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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
    • 10.3.18, 10.4.8
    • Data types
    • 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

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

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.