Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.4(EOL)
-
None
Description
The following query
SELECT ((SELECT a FROM t1 LIMIT 2) UNION (SELECT a FROM t2 LIMIT 2) LIMIT 1) AS r FROM t1 AS t; |
returns syntax error message in 10.4:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION (SELECT a FROM t2 LIMIT 2) LIMIT 1) AS r FROM t1 AS t' at line 1
|
Reprodicible in with the following test case
CREATE TABLE t1 (a int); |
INSERT INTO t1 VALUES(1),(2),(3),(4); |
CREATE TABLE t2 (a int); |
INSERT INTO t2 VALUES (4),(5),(6),(7); |
SELECT ((SELECT a FROM t1 LIMIT 2) UNION (SELECT a FROM t2 LIMIT 2) LIMIT 1) AS r FROM t1 AS t; |
10.3 and probably all prior versions return the same error message.
MySQL-8.0 returns a proper result:
mysql> SELECT ((SELECT a FROM t1 LIMIT 2) UNION (SELECT a FROM t2 LIMIT 2) LIMIT 1) AS r FROM t1 AS t;
|
+------+
|
| r |
|
+------+
|
| 1 |
|
| 1 |
|
| 1 |
|
| 1 |
|
+------+
|
This query with a subquery in the WHERE clause also failed to be parsed:
MariaDB [test]> SELECT * FROM t1 WHERE t1.a IN ((SELECT a FROM t1) UNION (SELECT a FROM t2));
|
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION (SELECT a FROM t2))' at line 1
|
10.3 returns the same error message.
MySQL-8.0 is ok with the above query:
mysql> SELECT * FROM t1 WHERE t1.a IN ((SELECT a FROM t1) UNION (SELECT a FROM t2));
|
+------+
|
| a |
|
+------+
|
| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
+------+
|
Attachments
Issue Links
- is blocked by
-
MDEV-19996 Bison grammar: turn singe-character operators into <kwd>
- Closed
-
MDEV-20634 Report disallowed subquery errors as such (instead of parse error)
- Closed