mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug #21302: Result not properly sorted when using an ORDER BY on a second
table in a join The optimizer removes redundant columns in ORDER BY. It is considering redundant every reference to const table column, e.g b in : create table t1 (a int, b int, primary key(a)); select 1 from t1 order by b where a = 1 But it must not remove references to const table columns if the const table is an outer table because there still can be 2 values : the const value and NULL. e.g.: create table t1 (a int, b int, primary key(a)); select t2.b c from t1 left join t1 t2 on (t1.a = t2.a and t2.a = 5) order by c; mysql-test/r/join_outer.result: Bug #21302: Result not properly sorted when using an ORDER BY on a second table in a join - don't remove columns of const tables in ORDER BY if the const table is an outer table. mysql-test/r/order_by.result: Bug #21302: Result not properly sorted when using an ORDER BY on a second table in a join - test case mysql-test/t/order_by.test: Bug #21302: Result not properly sorted when using an ORDER BY on a second table in a join - test case sql/sql_select.cc: Bug #21302: Result not properly sorted when using an ORDER BY on a second table in a join - don't remove columns of const tables in ORDER BY if the const table is an outer table.
This commit is contained in:
@ -735,7 +735,7 @@ explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from
|
||||
(t2 s left join t1 m on m.match_id = 1)
|
||||
order by m.match_id desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE s ALL NULL NULL NULL NULL 10
|
||||
1 SIMPLE s ALL NULL NULL NULL NULL 10 Using temporary; Using filesort
|
||||
1 SIMPLE m const match_id,match_id_2 match_id 1 const 1
|
||||
explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from
|
||||
(t2 s left join t1 m on m.match_id = 1)
|
||||
|
Reference in New Issue
Block a user