summaryrefslogtreecommitdiff
path: root/mysql-test/r/select.result
diff options
context:
space:
mode:
authorunknown <timour@mysql.com>2005-09-20 14:00:39 +0300
committerunknown <timour@mysql.com>2005-09-20 14:00:39 +0300
commit5968baf82259d9a71b131a658fbece754fbab316 (patch)
treed031eaf7feabd68d99d14853fcc0997336db1054 /mysql-test/r/select.result
parent12830fe6b73b591be496bbbcfd71494196d6873d (diff)
downloadmariadb-git-5968baf82259d9a71b131a658fbece754fbab316.tar.gz
Fix for BUG#13127.
The problem was in the way table references are pre-filtered when resolving a qualified field. When resolving qualified table references we search recursively in the operands of the join. If there is natural/using join with a merge view, the first call to find_field_in_table_ref makes a recursive call to itself with the view as the new table reference to search for the column. However the view has both nested_join and join_columns != NULL so it skipped the test whether the view name matches the field qualifier. As a result the field was found in the view since the view already has a field with the same name. Thus the field was incorrectly resolved as the view field. mysql-test/r/select.result: Test for BUG#13127. mysql-test/t/select.test: Test for BUG#13127. sql/sql_base.cc: The patch contains two independent changes: - When searching for qualified fields, include merge views and information schema tables used with SHOW (both using TABLE_LIST::field_translation to represent result fields) in the test that compares the qualifying table with the name of the table reference being searched. This change fixes the bug. - Do not search the materialized list of columns of a NATURAL/USING join if 'table_list' is a stored table or merge view. Instead search directly in the table or view as if it is not under a natural join. This is a performance improvement since if 'table_list' is a stored table, then the search can utilize the name hash for table names.
Diffstat (limited to 'mysql-test/r/select.result')
-rw-r--r--mysql-test/r/select.result69
1 files changed, 69 insertions, 0 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index e3af75a4573..eeb6e227c6a 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2960,3 +2960,72 @@ x x
4 4
4 5
drop table t1,t2,t3;
+create table t1 (id char(16) not null default '', primary key (id));
+insert into t1 values ('100'),('101'),('102');
+create table t2 (id char(16) default null);
+insert into t2 values (1);
+create view v1 as select t1.id from t1;
+create view v2 as select t2.id from t2;
+create view v3 as select (t1.id+2) as id from t1 natural left join t2;
+select t1.id from t1 left join v2 using (id);
+id
+100
+101
+102
+select t1.id from v2 right join t1 using (id);
+id
+100
+101
+102
+select t1.id from t1 left join v3 using (id);
+id
+100
+101
+102
+select * from t1 left join v2 using (id);
+id
+100
+101
+102
+select * from v2 right join t1 using (id);
+id
+100
+101
+102
+select * from t1 left join v3 using (id);
+id
+100
+101
+102
+select v1.id from v1 left join v2 using (id);
+id
+100
+101
+102
+select v1.id from v2 right join v1 using (id);
+id
+100
+101
+102
+select v1.id from v1 left join v3 using (id);
+id
+100
+101
+102
+select * from v1 left join v2 using (id);
+id
+100
+101
+102
+select * from v2 right join v1 using (id);
+id
+100
+101
+102
+select * from v1 left join v3 using (id);
+id
+100
+101
+102
+drop table t1, t2;
+drop view v1, v2, v3;