From 8ce6f3e6ca7fedd2142e784e9aeab72ec2e49951 Mon Sep 17 00:00:00 2001 From: "gluh@eagle.intranet.mysql.r18.ru" <> Date: Tue, 3 Jan 2006 14:25:19 +0400 Subject: [PATCH] Fix for bug#15533 crash, information_schema, function, view enable view prepared mode during getting metedata for I_S table --- mysql-test/r/information_schema.result | 16 ++++++++++++++++ mysql-test/t/information_schema.test | 23 +++++++++++++++++++++++ sql/sql_show.cc | 3 +++ 3 files changed, 42 insertions(+) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index e8d343ad711..05f2118a8c7 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1074,3 +1074,19 @@ character_maximum_length character_octet_length 32 32 64 64 drop table t1; +CREATE TABLE t1 (f1 BIGINT, f2 VARCHAR(20), f3 BIGINT); +INSERT INTO t1 SET f1 = 1, f2 = 'Schoenenbourg', f3 = 1; +CREATE FUNCTION func2() RETURNS BIGINT RETURN 1; +CREATE FUNCTION func1() RETURNS BIGINT +BEGIN +RETURN ( SELECT COUNT(*) FROM INFORMATION_SCHEMA.VIEWS); +END// +CREATE VIEW v1 AS SELECT 1 FROM t1 +WHERE f3 = (SELECT func2 ()); +SELECT func1(); +func1() +1 +DROP TABLE t1; +DROP VIEW v1; +DROP FUNCTION func1; +DROP FUNCTION func2; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index b05798b781f..f835a7148a2 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -767,3 +767,26 @@ create table t1(f1 binary(32), f2 varbinary(64)); select character_maximum_length, character_octet_length from information_schema.columns where table_name='t1'; drop table t1; + +# +# Bug#15533 crash, information_schema, function, view +# +CREATE TABLE t1 (f1 BIGINT, f2 VARCHAR(20), f3 BIGINT); +INSERT INTO t1 SET f1 = 1, f2 = 'Schoenenbourg', f3 = 1; + +CREATE FUNCTION func2() RETURNS BIGINT RETURN 1; + +delimiter //; +CREATE FUNCTION func1() RETURNS BIGINT +BEGIN + RETURN ( SELECT COUNT(*) FROM INFORMATION_SCHEMA.VIEWS); +END// +delimiter ;// + +CREATE VIEW v1 AS SELECT 1 FROM t1 + WHERE f3 = (SELECT func2 ()); +SELECT func1(); +DROP TABLE t1; +DROP VIEW v1; +DROP FUNCTION func1; +DROP FUNCTION func2; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1b31e8f7dc3..089314078a6 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2045,6 +2045,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) int error= 1; db_type not_used; Open_tables_state open_tables_state_backup; + bool save_view_prepare_mode= lex->view_prepare_mode; + lex->view_prepare_mode= TRUE; DBUG_ENTER("get_all_tables"); LINT_INIT(end); @@ -2230,6 +2232,7 @@ err: lex->derived_tables= derived_tables; lex->all_selects_list= old_all_select_lex; lex->query_tables_last= save_query_tables_last; + lex->view_prepare_mode= save_view_prepare_mode; *save_query_tables_last= 0; lex->sql_command= save_sql_command; DBUG_RETURN(error);