Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
-
10.1.15, 10.1.17-1
Description
Description:
Output:
=====
mysql> create table t1(c1 int, c2 int, c3 int); |
Query OK, 0 rows affected (0.00 sec) |
|
mysql> insert into t1 values(1,1,1),(2,2,2),(3,3,3); |
Query OK, 3 rows affected (0.00 sec) |
Records: 3 Duplicates: 0 Warnings: 0 |
|
mysql> select * from t1;
|
+------+------+------+
|
| c1 | c2 | c3 |
|
+------+------+------+
|
| 1 | 1 | 1 | |
| 2 | 2 | 2 | |
| 3 | 3 | 3 | |
+------+------+------+
|
3 rows in set (0.00 sec) |
|
mysql> create table t2(c1 int, c2 int); |
Query OK, 0 rows affected (0.00 sec) |
|
mysql> insert into t2 values(2,2); |
Query OK, 1 row affected (0.00 sec) |
|
mysql> select * from t2;
|
+------+------+
|
| c1 | c2 |
|
+------+------+
|
| 2 | 2 | |
+------+------+
|
1 row in set (0.00 sec) |
|
mysql> select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+c) from t2 tt));
|
Empty set (0.00 sec) |
|
mysql> select version();
|
+-----------------+
|
| version() |
|
+-----------------+
|
| 10.1.10-MariaDB | |
+-----------------+
|
1 row in set (0.00 sec) |
|
Problem:
=====
Since (select t.c1 as c from t2 ...) can only produce one value 2, the condition c1 > 2 should not produce `Empty Set` result.
How to repeat:
drop table if exists t1,t2; |
create table t1(c1 int, c2 int, c3 int); |
insert into t1 values(1,1,1),(2,2,2),(3,3,3); |
select * from t1;
|
create table t2(c1 int, c2 int); |
insert into t2 values(2,2); |
select * from t2;
|
select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+c) from t2 tt));
|
|
Suggested fix:
Non empty set is returned for the query.
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Status | Open [ 1 ] | Confirmed [ 10101 ] |
Component/s | Optimizer [ 10200 ] | |
Fix Version/s | 10.1 [ 16100 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Affects Version/s | 5.5 [ 15800 ] | |
Affects Version/s | 10.0 [ 16000 ] | |
Affects Version/s | 10.1 [ 16100 ] | |
Affects Version/s | 10.2 [ 14601 ] | |
Assignee | Sergei Petrunia [ psergey ] | |
Labels | upstream |
Sprint | 10.1.15 [ 75 ] |
Rank | Ranked lower |
Assignee | Sergei Petrunia [ psergey ] | Oleksandr Byelkin [ sanja ] |
Status | Confirmed [ 10101 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Sprint | 10.1.15 [ 75 ] | 10.1.15, 10.1.16 [ 75, 76 ] |
Status | In Progress [ 3 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Sprint | 10.1.15, 1.0.2 [ 75, 76 ] | 10.1.15 [ 75 ] |
Rank | Ranked higher |
Sprint | 10.1.15 [ 75 ] | 10.1.15, 10.1.17-1 [ 75, 87 ] |
Status | In Progress [ 3 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Assignee | Oleksandr Byelkin [ sanja ] | Igor Babaev [ igor ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Fix Version/s | 10.2.2 [ 22013 ] | |
Fix Version/s | 10.1.19 [ 22111 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Fix Version/s | 10.1 [ 16100 ] | |
Resolution | Fixed [ 1 ] | |
Status | In Review [ 10002 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 75514 ] | MariaDB v4 [ 150395 ] |
Thanks for the report and the test case.
Setting the sql_mode to ONLY_FULL_GROUP_BY makes the query fail with the error:
query 'select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+c) from t2 tt))' failed: 1463: Non-grouping field 'c1' is used in HAVING clause
or, the MySQL version of the error is
query 'select c1 from t1 having c1 >= (select t.c1 as c from t2 t order by (select min(t1.c1+c) from t2 tt))' failed: 1140: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.t1.c1'; this is incompatible with sql_mode=only_full_group_by
The result is the same with MariaDB 5.1 - 10.2 and MySQL 5.5-5.6.
MySQL 5.7 has ONLY_FULL_GROUP_BY by default, so the query fails by default. Unsetting sql_mode makes it produce the same empty set.