diff options
author | unknown <gkodinov/kgeorge@macbook.gmz> | 2006-08-14 15:45:48 +0300 |
---|---|---|
committer | unknown <gkodinov/kgeorge@macbook.gmz> | 2006-08-14 15:45:48 +0300 |
commit | 06a302eff231c27cc71d9714d87b34560945fe8e (patch) | |
tree | 209c40e5f7efe0a27fe2cf952cf84e34811ed103 /sql | |
parent | 1cf65f311dbf09615bea443b041a78db34d7e2ea (diff) | |
download | mariadb-git-06a302eff231c27cc71d9714d87b34560945fe8e.tar.gz |
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.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2f16b350d04..adb7b66df8a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5976,7 +5976,8 @@ eq_ref_table(JOIN *join, ORDER *start_order, JOIN_TAB *tab) if (tab->cached_eq_ref_table) // If cached return tab->eq_ref_table; tab->cached_eq_ref_table=1; - if (tab->type == JT_CONST) // We can skip const tables + /* We can skip const tables only if not an outer table */ + if (tab->type == JT_CONST && !tab->first_inner) return (tab->eq_ref_table=1); /* purecov: inspected */ if (tab->type != JT_EQ_REF || tab->table->maybe_null) return (tab->eq_ref_table=0); // We must use this |