From: Date: April 24 2006 9:34pm Subject: bk commit into 5.0 tree (evgen:1.2093) BUG#17199 List-Archive: http://lists.mysql.com/commits/5424 X-Bug: 17199 Message-Id: <20060424193407.0B95F22F85E@moonbone.moonbone.local> Below is the list of changes that have just been committed into a local 5.0 repository of evgen. When evgen does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2093 06/04/24 23:34:01 evgen@stripped +3 -0 Fixed bug#17199: "Table not found" error occurs if the query contains a call to a function from another database. When the mysql parser adds a table to the query table list it can set table db from the thd->db variable by simply copying address and not creating a copy for the table. If the statement contains a call of a stored procedure from another database then the thd->db value will be freed and all tables that have db set without a copy will contain a garbage in their db variables. This happens because when the procedure is being loaded it will change current database and thus change thd->db and freeing the old value. The st_select_lex::add_table_to_list() function is changed to always create a table own copy of thd->db variable. sql/sql_parse.cc 1.541 06/04/24 23:31:50 evgen@stripped +1 -1 Fixed bug#17199: "Table not found" error occurs if the query contains a call to a function from another database. mysql-test/r/sp.result 1.198 06/04/24 23:31:31 evgen@stripped +12 -0 Added test case for bug#17199: "Table not found" error occurs if the query contains a call to a function from another database. mysql-test/t/sp.test 1.186 06/04/24 23:28:42 evgen@stripped +15 -0 Added test case for bug#17199: "Table not found" error occurs if the query contains a call to a function from another database. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: evgen # Host: moonbone.local # Root: /work/17199-bug-5.0-mysql --- 1.540/sql/sql_parse.cc 2006-04-21 19:19:31 +04:00 +++ 1.541/sql/sql_parse.cc 2006-04-24 23:31:50 +04:00 @@ -5984,7 +5984,7 @@ ptr->db= empty_c_string; ptr->db_length= 0; } - if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute()) + if (ptr->db_length) ptr->db= thd->strdup(ptr->db); ptr->alias= alias_str; --- 1.197/mysql-test/r/sp.result 2006-04-21 18:54:57 +04:00 +++ 1.198/mysql-test/r/sp.result 2006-04-24 23:31:31 +04:00 @@ -4904,4 +4904,16 @@ select routine_name,routine_schema from information_schema.routines where routine_schema like 'bug18344%'| routine_name routine_schema +create database test1| +use test1| +CREATE FUNCTION bug17199 () +RETURNS VARCHAR(2) +DETERMINISTIC +BEGIN +RETURN 'ok'; +END;| +use test| +select *, test1.bug17199() from t1| +id data test1.bug17199() +drop database test1| drop table t1,t2; --- 1.185/mysql-test/t/sp.test 2006-04-21 18:54:57 +04:00 +++ 1.186/mysql-test/t/sp.test 2006-04-24 23:28:42 +04:00 @@ -5774,6 +5774,21 @@ # +# Bug#17199: "Table not found" error occurs if the query contains a call +# to a function from another database. +create database test1| +use test1| +CREATE FUNCTION bug17199 () + RETURNS VARCHAR(2) +DETERMINISTIC +BEGIN + RETURN 'ok'; +END;| +use test| +select *, test1.bug17199() from t1| +drop database test1| + +# # BUG#NNNN: New bug synopsis # #--disable_warnings