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

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.4
    • Fix Version/s: 10.4.0
    • Component/s: Parser
    • Labels:
      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

              Assignee:
              igor Igor Babaev
              Reporter:
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration