Commit 3c5ae70e authored by unknown's avatar unknown

Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0

into  mysql.com:/usr/home/ram/work/mysql-5.0

parents 3a806cd6 7acbea3f
...@@ -1375,3 +1375,31 @@ groupid price ...@@ -1375,3 +1375,31 @@ groupid price
6 9900 6 9900
DROP VIEW v1,v2; DROP VIEW v1,v2;
DROP TABLE t1,t2,t3,t4; DROP TABLE t1,t2,t3,t4;
CREATE TABLE t1(a int);
CREATE TABLE t2(b int);
CREATE TABLE t3(c int, d int);
CREATE TABLE t4(d int);
CREATE TABLE t5(e int, f int);
CREATE TABLE t6(f int);
CREATE VIEW v1 AS
SELECT e FROM t5 JOIN t6 ON t5.e=t6.f;
CREATE VIEW v2 AS
SELECT e FROM t5 NATURAL JOIN t6;
SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d);
a
SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d);
ERROR 42S22: Unknown column 't1.x' in 'field list'
SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4;
a
SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4;
ERROR 42S22: Unknown column 't1.x' in 'field list'
SELECT v1.e FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
e
SELECT v1.x FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
ERROR 42S22: Unknown column 'v1.x' in 'field list'
SELECT v2.e FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
e
SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
ERROR 42S22: Unknown column 'v2.x' in 'field list'
DROP VIEW v1, v2;
DROP TABLE t1, t2, t3, t4, t5, t6;
...@@ -801,3 +801,34 @@ SELECT * FROM ...@@ -801,3 +801,34 @@ SELECT * FROM
DROP VIEW v1,v2; DROP VIEW v1,v2;
DROP TABLE t1,t2,t3,t4; DROP TABLE t1,t2,t3,t4;
#
# Bug #13545: problem with NATURAL/USING joins.
#
CREATE TABLE t1(a int);
CREATE TABLE t2(b int);
CREATE TABLE t3(c int, d int);
CREATE TABLE t4(d int);
CREATE TABLE t5(e int, f int);
CREATE TABLE t6(f int);
CREATE VIEW v1 AS
SELECT e FROM t5 JOIN t6 ON t5.e=t6.f;
CREATE VIEW v2 AS
SELECT e FROM t5 NATURAL JOIN t6;
SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d);
--error 1054
SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c JOIN t4 USING(d);
SELECT t1.a FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4;
--error 1054
SELECT t1.x FROM t1 JOIN t2 ON a=b JOIN t3 ON a=c NATURAL JOIN t4;
SELECT v1.e FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
--error 1054
SELECT v1.x FROM v1 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
SELECT v2.e FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
--error 1054
SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
DROP VIEW v1, v2;
DROP TABLE t1, t2, t3, t4, t5, t6;
...@@ -2988,7 +2988,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, ...@@ -2988,7 +2988,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
are the same as the table reference we are going to search for the field. are the same as the table reference we are going to search for the field.
We exclude from the test below NATURAL/USING joins and any nested join We exclude from the test below NATURAL/USING joins and any nested join
that is an operand of NATURAL/USING join, because each column in such because each column in such
joins may potentially originate from a different table. However, base joins may potentially originate from a different table. However, base
tables and views that are under some NATURAL/USING join are searched tables and views that are under some NATURAL/USING join are searched
as usual base tables/views. as usual base tables/views.
...@@ -3001,8 +3001,8 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, ...@@ -3001,8 +3001,8 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
TODO: Ensure that table_name, db_name and tables->db always points to TODO: Ensure that table_name, db_name and tables->db always points to
something ! something !
*/ */
if (/* Exclude natural joins and nested joins underlying natural joins. */ if (/* Exclude nested joins. */
(!(table_list->nested_join && table_list->join_columns) || (!table_list->nested_join ||
/* Include merge views and information schema tables. */ /* Include merge views and information schema tables. */
table_list->field_translation) && table_list->field_translation) &&
/* /*
...@@ -3025,13 +3025,10 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, ...@@ -3025,13 +3025,10 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
register_tree_change))) register_tree_change)))
*actual_table= table_list; *actual_table= table_list;
} }
else if (!(table_list->nested_join && table_list->join_columns)) else if (!table_list->nested_join)
{ {
/* /* 'table_list' is a stored table. */
'table_list' is a stored table. It is so because the only type of nested DBUG_ASSERT(table_list->table);
join passed to this procedure is a NATURAL/USING join or an operand of a
NATURAL/USING join.
*/
if ((fld= find_field_in_table(thd, table_list->table, name, length, if ((fld= find_field_in_table(thd, table_list->table, name, length,
check_grants_table, allow_rowid, check_grants_table, allow_rowid,
cached_field_index_ptr))) cached_field_index_ptr)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment