diff options
author | unknown <gluh@gluh.mysql.r18.ru> | 2005-02-22 14:42:44 +0300 |
---|---|---|
committer | unknown <gluh@gluh.mysql.r18.ru> | 2005-02-22 14:42:44 +0300 |
commit | b8adcb3bef7490a8ce95df8fe1b84335a1832369 (patch) | |
tree | cfe65024d212aa681601403acc0d7ee47157f64f | |
parent | 17cca96ec9c613a0e25cf78f7230bd9ebfb72010 (diff) | |
download | mariadb-git-b8adcb3bef7490a8ce95df8fe1b84335a1832369.tar.gz |
Fix for bug #7476: crash on SELECT * FROM INFORMATION_SCHEMA.TABLES(after review)
-rw-r--r-- | mysql-test/r/information_schema.result | 5 | ||||
-rw-r--r-- | mysql-test/t/information_schema.test | 27 | ||||
-rw-r--r-- | sql/sql_show.cc | 8 |
3 files changed, 38 insertions, 2 deletions
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index e8ec4f70139..a201aa3ed63 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -610,3 +610,8 @@ create view v1 as select * from t1, t2; set @got_val= (select count(*) from information_schema.columns); drop view v1; drop table t1, t2; +CREATE TABLE t_crashme ( f1 BIGINT); +CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1; +CREATE VIEW a2 AS SELECT t_CRASHME FROM a1; +drop view a2, a1; +drop table t_crashme; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index baf817b7c84..99fbc181136 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -363,3 +363,30 @@ create view v1 as select * from t1, t2; set @got_val= (select count(*) from information_schema.columns); drop view v1; drop table t1, t2; + +# +# Bug #7476: crash on SELECT * FROM INFORMATION_SCHEMA.TABLES +# + +CREATE TABLE t_crashme ( f1 BIGINT); +CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1; +CREATE VIEW a2 AS SELECT t_CRASHME FROM a1; +let $tab_count= 65; +--disable_query_log +while ($tab_count) +{ + EVAL CREATE TABLE t_$tab_count (f1 BIGINT); + dec $tab_count ; +} +--disable_result_log +SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES; +--enable_result_log +let $tab_count= 65; +while ($tab_count) +{ + EVAL DROP TABLE t_$tab_count; + dec $tab_count ; +} +--enable_query_log +drop view a2, a1; +drop table t_crashme; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e46ad024f70..e95b20c29c9 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1778,6 +1778,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) LEX *lex= thd->lex; TABLE *table= tables->table; SELECT_LEX *select_lex= &lex->select_lex; + SELECT_LEX *old_all_select_lex= lex->all_selects_list; SELECT_LEX *lsel= tables->schema_select_lex; ST_SCHEMA_TABLE *schema_table= tables->schema_table; SELECT_LEX sel; @@ -1790,6 +1791,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) List<char> bases; List_iterator_fast<char> it(bases); COND *partial_cond; + uint derived_tables= lex->derived_tables; int error= 1; DBUG_ENTER("get_all_tables"); @@ -1814,7 +1816,6 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) goto err; } - lex->all_selects_list= &sel; schema_table_idx= get_schema_table_idx(schema_table); lock_type= TL_UNLOCK; @@ -1911,6 +1912,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) goto err; TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first; show_table_list->lock_type= lock_type; + lex->all_selects_list= &sel; + lex->derived_tables= 0; res= open_and_lock_tables(thd, show_table_list); if (schema_table->process_table(thd, show_table_list, table, res, base_name, @@ -1930,7 +1933,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) error= 0; err: - lex->all_selects_list= select_lex; + lex->derived_tables= derived_tables; + lex->all_selects_list= old_all_select_lex; DBUG_RETURN(error); } |