Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
10.2.5, 10.2(EOL), 10.3(EOL), 10.4(EOL)
-
None
Description
The testcase comes from David.Hall.
Load the dataset: source mysql-test/include/dbt3_s001.inc
Then run the two queries:
select *
|
from region
|
where (r_regionkey+1) in (select min(n_regionkey) over() + 1
|
from nation
|
where r_regionkey=n_regionkey);
|
select *
|
from region
|
where (r_regionkey+1) in (select min(n_regionkey) + 1
|
from nation
|
where r_regionkey=n_regionkey);
|
and see that they produce different results:
MariaDB [test]> select *
|
-> from region
|
-> where (r_regionkey+1) in (select min(n_regionkey) over() + 1
|
-> from nation
|
-> where r_regionkey=n_regionkey);
|
+-------------+--------+-------------------------------------------------------------+
|
| r_regionkey | r_name | r_comment |
|
+-------------+--------+-------------------------------------------------------------+
|
| 0 | AFRICA | special Tiresias about the furiously even dolphins are furi |
|
+-------------+--------+-------------------------------------------------------------+
|
MariaDB [test]> select *
|
-> from region
|
-> where (r_regionkey+1) in (select min(n_regionkey) + 1
|
-> from nation
|
-> where r_regionkey=n_regionkey);
|
+-------------+-------------+-----------------------------------------------------------------------------------------------------------------+
|
| r_regionkey | r_name | r_comment |
|
+-------------+-------------+-----------------------------------------------------------------------------------------------------------------+
|
| 0 | AFRICA | special Tiresias about the furiously even dolphins are furi |
|
| 1 | AMERICA | even, ironic theodolites according to the bold platelets wa |
|
| 2 | ASIA | silent, bold requests sleep slyly across the quickly sly dependencies. furiously silent instructions alongside |
|
| 3 | EUROPE | special, bold deposits haggle foxes. platelet |
|
| 4 | MIDDLE EAST | furiously unusual packages use carefully above the unusual, exp |
|
+-------------+-------------+-----------------------------------------------------------------------------------------------------------------+
|
Attachments
Issue Links
- duplicates
-
MDEV-16064 Wrong result set from query with in subquery that uses window function
-
- Confirmed
-
- relates to
-
MDEV-16064 Wrong result set from query with in subquery that uses window function
-
- Confirmed
-
EXPLAIN for the query with window function:
*************************** 1. row ***************************
EXPLAIN: {
"query_block": {
"select_id": 1,
"table": {
"table_name": "region",
"access_type": "ALL",
"rows": 5,
"filtered": 100,
"attached_condition": "<in_optimizer>(region.r_regionkey + 1,<exists>(subquery#2))"
},
"subqueries": [
{
"query_block": {
"select_id": 2,
"having_condition": "<cache>(region.r_regionkey + 1) = <ref_null_helper>(min(nation.n_regionkey) over () + 1)",
"window_functions_computation": {
"sorts": {
"filesort": {
"sort_key": "tmp_field"
}
},
"temporary_table": {
"table": {
"table_name": "nation",
"access_type": "ref",
"possible_keys": ["i_n_regionkey"],
"key": "i_n_regionkey",
"key_length": "5",
"used_key_parts": ["n_regionkey"],
"ref": ["test.region.r_regionkey"],
"rows": 1,
"filtered": 100,
"using_index": true
}
}
}
}
}
]
}
}