Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.1(EOL), 10.2(EOL)
-
None
Description
10.1 disallowed use of non-parenthesized UNION parts that have ORDER or LIMIT clauses, according to the SQL Standard. That was a merge from MySQL-5.6.
This script:
DROP TABLE IF EXISTS t1; |
CREATE TABLE t1 (a INT); |
INSERT INTO t1 VALUES (10),(10); |
SELECT * FROM t1 LIMIT 1 |
UNION
|
SELECT * FROM t1 LIMIT 1; |
returns an error starting from 10.1:
ERROR 1221 (HY000): Incorrect usage of UNION and LIMIT
|
However, if I use LIMIT in combination with ROWS EXAMINED:
SELECT * FROM t1 LIMIT ROWS EXAMINED 1 |
UNION
|
SELECT * FROM t1 LIMIT ROWS EXAMINED 1; |
it returns a result instead of an error:
+------+
|
| a |
|
+------+
|
| 10 |
|
+------+
|
1 row in set, 1 warning (0.00 sec)
|
It should be fixed to require parentheses as well, like in case of a "normal" LIMIT clause.
Most likely, LIMIT ROWS EXAMINED was just forgotten during the merge.
The documentation at:
https://mariadb.com/kb/en/mariadb/union/
says:
Individual selects can contain their own ORDER BY and LIMIT clauses. In that case, the individual queries need to be wrapped between parenthesis.
Attachments
Issue Links
- blocks
-
MDEV-8909 union parser cleanup
- Closed