diff options
author | konstantin@mysql.com <> | 2004-11-05 22:02:07 +0300 |
---|---|---|
committer | konstantin@mysql.com <> | 2004-11-05 22:02:07 +0300 |
commit | fe5889dee55f57045bc5180662003871d7911205 (patch) | |
tree | 6506efd1bf1a077deccfa6ecc196387ffbc38906 /sql/sql_prepare.cc | |
parent | ff1e31532aadaf20820be88510c847deae495f70 (diff) | |
download | mariadb-git-fe5889dee55f57045bc5180662003871d7911205.tar.gz |
A fix and test case for Bug#6102 "Server crash with prepared statement
and blank after function name".
Crop fruits of copy-paste programming: pre-caching of stored functions
wasn't performed for prepared statements just because implementation
of prepared statements is done as an add-on to the main execution flow,
and the preload was originally implemented for main execution branch
only (mysql_execute_command).
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r-- | sql/sql_prepare.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index bb2362dd562..ed8a28b8b07 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -72,6 +72,7 @@ Long data handling: #include "sql_select.h" // for JOIN #include <m_ctype.h> // for isspace() #include "sp_head.h" +#include "sp.h" #ifdef EMBEDDED_LIBRARY /* include MYSQL_BIND headers */ #include <mysql.h> @@ -1409,6 +1410,20 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) lex->first_lists_tables_same(); tables= lex->query_tables; + /* + Preopen 'proc' system table and cache all functions used in this + statement. We must do that before we open ordinary tables to avoid + deadlocks. We can't open and lock any table once query tables were + opened. + */ + if (lex->sql_command != SQLCOM_CREATE_PROCEDURE && + lex->sql_command != SQLCOM_CREATE_SPFUNCTION) + { + /* the error is print inside */ + if (sp_cache_functions(thd, lex)) + DBUG_RETURN(1); + } + switch (sql_command) { case SQLCOM_REPLACE: case SQLCOM_INSERT: |