Details
-
Bug
-
Status: In Review (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11
Description
Under ONLY_FULL_GROUP_BY, when a correlated subquery aggregates a column of an outer query, the server incorrectly raises ER_WRONG_FIELD_WITH_GROUP. For example:
CREATE TABLE t1 (a INT, b INT); |
CREATE TABLE t2 (c INT, d INT); |
INSERT INTO t1 VALUES (1,10),(2,10),(3,20); |
INSERT INTO t2 VALUES (1,100),(2,200),(3,300); |
|
|
SET SQL_MODE=ONLY_FULL_GROUP_BY; |
|
|
SELECT b, (SELECT SUM(t2.d) + SUM(t1.a) FROM t2) AS sub FROM t1 GROUP BY b; |
The query should be accepted since t1.a appears inside SUM() and thus is aggregated. In MySQL the query returns:
+------+------+
|
| b | sub |
|
+------+------+
|
| 10 | 603 |
|
| 20 | 603 |
|
+------+------+
|
But in MariaDB, we receive:
ERROR 1055 (42000) at line 8: 'db.t1.a' isn't in GROUP BY
|