Commit 48c3c329 authored by unknown's avatar unknown

Fix for bug#12905 show fields from view behaving erratically with current database

  use saved view db name in case of view

parent a777907a
...@@ -979,3 +979,14 @@ WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE'); ...@@ -979,3 +979,14 @@ WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL t1 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
DROP TABLE t1,t2;
create table t1(f1 int);
create view v1 (c) as select f1 from t1;
select database();
database()
NULL
show fields from test.v1;
Field Type Null Key Default Extra
c int(11) YES NULL
drop view v1;
drop table t1;
...@@ -665,4 +665,16 @@ SHOW TABLE STATUS FROM test ...@@ -665,4 +665,16 @@ SHOW TABLE STATUS FROM test
WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE'); WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
DROP TABLE t1,t2 DROP TABLE t1,t2;
#
# Bug #12905 show fields from view behaving erratically with current database
#
create table t1(f1 int);
create view v1 (c) as select f1 from t1;
connect (con5,localhost,root,,*NO-ONE*);
select database();
show fields from test.v1;
connection default;
drop view v1;
drop table t1;
...@@ -1988,9 +1988,19 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -1988,9 +1988,19 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
/* /*
get_all_tables() returns 1 on failure and 0 on success thus get_all_tables() returns 1 on failure and 0 on success thus
return only these and not the result code of ::process_table() return only these and not the result code of ::process_table()
We should use show_table_list->alias instead of
show_table_list->table_name because table_name
could be changed during opening of I_S tables. It's safe
to use alias because alias contains original table name
in this case(this part of code is used only for
'show columns' & 'show statistics' commands).
*/ */
error= test(schema_table->process_table(thd, show_table_list, error= test(schema_table->process_table(thd, show_table_list,
table, res, show_table_list->db, table, res,
(show_table_list->view ?
show_table_list->view_db.str :
show_table_list->db),
show_table_list->alias)); show_table_list->alias));
close_thread_tables(thd); close_thread_tables(thd);
show_table_list->table= 0; show_table_list->table= 0;
...@@ -2092,6 +2102,13 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2092,6 +2102,13 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
lex->derived_tables= 0; lex->derived_tables= 0;
res= open_normal_and_derived_tables(thd, show_table_list, res= open_normal_and_derived_tables(thd, show_table_list,
MYSQL_LOCK_IGNORE_FLUSH); MYSQL_LOCK_IGNORE_FLUSH);
/*
We should use show_table_list->alias instead of
show_table_list->table_name because table_name
could be changed during opening of I_S tables. It's safe
to use alias because alias contains original table name
in this case.
*/
res= schema_table->process_table(thd, show_table_list, table, res= schema_table->process_table(thd, show_table_list, table,
res, base_name, res, base_name,
show_table_list->alias); show_table_list->alias);
......
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