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

Wrong result caused by UNSIGNED column and UNION ALL

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.2.12, 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
    • N/A
    • Data types

    Description

      SELECT returns wrong data when UNION ALL is used and first table has unsigned column and second table has signed data in this column.

      Example:

      CREATE TABLE `pokus` (
        `id` INT NOT NULL,
        `unsigned_column` SMALLINT UNSIGNED NOT NULL,
        PRIMARY KEY (`id`));
       
      INSERT INTO `pokus` (`id`, `unsigned_column`) VALUES ('1', '5');
       
      SELECT id, unsigned_column FROM pokus
      UNION ALL
      SELECT id, -unsigned_column FROM pokus;
      

      result:

      '1', '5'
      '1', '0'
      

      Second row has 0 in second column, it should have -5.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              PavelCibulka Pavel Cibulka
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.