diff options
-rw-r--r-- | mysql-test/r/sp.result | 13 | ||||
-rw-r--r-- | mysql-test/t/sp.test | 22 | ||||
-rw-r--r-- | sql/item.cc | 3 |
3 files changed, 37 insertions, 1 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index e788d30a14b..dea51bb4c2c 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -6672,6 +6672,19 @@ select substr(`str`, `pos`+ 1 ) into `str`; end $ call `p2`('s s s s s s'); drop procedure `p2`; +drop table if exists t1; +drop procedure if exists p1; +create procedure p1() begin select * from t1; end$ +call p1$ +ERROR 42S02: Table 'test.t1' doesn't exist +create table t1 (a integer)$ +call p1$ +a +alter table t1 add b integer; +call p1$ +a +drop table t1; +drop procedure p1; # ------------------------------------------------------------------ # -- End of 5.0 tests # ------------------------------------------------------------------ diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 21ca2528e4f..6d7a4b96167 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -7836,6 +7836,28 @@ delimiter ;$ call `p2`('s s s s s s'); drop procedure `p2`; +# +# Bug#38823: Invalid memory access when a SP statement does wildcard expansion +# + +--disable_warnings +drop table if exists t1; +drop procedure if exists p1; +--enable_warnings + +delimiter $; +create procedure p1() begin select * from t1; end$ +--error ER_NO_SUCH_TABLE +call p1$ +create table t1 (a integer)$ +call p1$ +alter table t1 add b integer; +call p1$ +delimiter ;$ + +drop table t1; +drop procedure p1; + --echo # ------------------------------------------------------------------ --echo # -- End of 5.0 tests --echo # ------------------------------------------------------------------ diff --git a/sql/item.cc b/sql/item.cc index e49de88cea7..182f4abdfe6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1759,7 +1759,8 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg, be allocated in the statement memory, not in table memory (the table structure can go away and pop up again between subsequent executions of a prepared statement or after the close_tables_for_reopen() call - in mysql_multi_update_prepare()). + in mysql_multi_update_prepare() or due to wildcard expansion in stored + procedures). */ { if (db_name) |