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

LIMIT and ORDER BY clause is ignored on a query with UNION when using brackets

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.4
    • 10.4.0
    • Parser
    • None

    Description

      CREATE TABLE t1 (b int);
      INSERT INTO t1 VALUES(1),(2),(3),(4);
       
      CREATE TABLE t2 (b int);
      INSERT INTO t2 VALUES (4),(5),(6),(7);
       
      (select b from t1  UNION select b from t2) limit 1;
      (select b from t1  UNION select b from t2) order by b desc;
      

      MariaDB [test]> (select b from t1  UNION select b from t2) limit 1;
      +------+
      | b    |
      +------+
      |    1 |
      |    2 |
      |    3 |
      |    4 |
      |    5 |
      |    6 |
      |    7 |
      +------+
      7 rows in set (0.001 sec)
       
      MariaDB [test]> (select b from t1  UNION select b from t2) order by b desc;
      +------+
      | b    |
      +------+
      |    1 |
      |    2 |
      |    3 |
      |    4 |
      |    5 |
      |    6 |
      |    7 |
      +------+
      7 rows in set (0.001 sec)
       
      MariaDB [test]> (select b from t1  UNION select b from t2 limit 1);
      +------+
      | b    |
      +------+
      |    1 |
      |    2 |
      |    3 |
      |    4 |
      |    5 |
      |    6 |
      |    7 |
      +------+
      7 rows in set (0.002 sec)
      expected :
      MariaDB [test]> select b from t1  UNION select b from t2 limit 1;
      +------+
      | b    |
      +------+
      |    1 |
      +------+
      1 row in set (0.001 sec)
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              alice Alice Sherepa
              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.