Commit 5e7cbbcb authored by unknown's avatar unknown
Browse files

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:
  Fix for bug#15533 crash, information_schema, function, view
    test case
mysql-test/t/information_schema.test:
  Fix for bug#15533 crash, information_schema, function, view
    test case
parent 168a6104
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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;
+23 −0
Original line number Diff line number Diff line
@@ -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;
+3 −0
Original line number Diff line number Diff line
@@ -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 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
  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);