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

UNION treat same alias name column as different and return two columns in Oracle Mode

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.11.18
    • N/A
    • Optimizer
    • None
    • RHEL 8
      MariaDB 10.11.18
    • Not for Release Notes

    Description

      After Upgrade from 10.5.29 to 10.11.18, the SQL execution behaviour changed in Oracle mode, UNION treat same alias name column as different and returned two columns.

      Version 10.11.18:

      SET SQL_MODE='ORACLE';
      SELECT '1' AS NEWCOLUMN, T.* FROM TABLE_A T
      UNION
      SELECT '2' AS NEWCOLUMN, T.* FROM TABLE_A T;
       
      +-----------+-----------+-------------+-----+
      | NEWCOLUMN | NEWCOLUMN | FUNC_ID     | GRP |
      +-----------+-----------+-------------+-----+
      | 1         | 1         |      100    | S   |
      | 1         | 1         |      200    | S   |
      | 1         | 1         |      300    | S   |
      | 2         | 2         |      100    | S   |
      | 2         | 2         |      200    | S   |
      | 2         | 2         |      300    | S   |
      +-----------+-----------+-------------+-----+
      

      Version 10.5.29:

      SET SQL_MODE='ORACLE';
      SELECT '1' AS NEWCOLUMN, T.* FROM TABLE_A T
      UNION
      SELECT '2' AS NEWCOLUMN, T.* FROM TABLE_A T;
       
      +-----------+-------------+-----+
      | NEWCOLUMN | FUNC_ID     | GRP |
      +-----------+-------------+-----+
      | 1         |      100    | S   |
      | 1         |      200    | S   |
      | 1         |      300    | S   |
      | 2         |      100    | S   |
      | 2         |      200    | S   |
      | 2         |      300    | S   |
      +-----------+-------------+-----+
      

      The same SQL return only one NEWCOLUMN in non-Oracle mode for both 10.5.29 and 10.11.18, is it a bug or known issue?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kevinlkc Kevin
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.