diff options
author | unknown <pem@mysql.com> | 2005-10-26 15:34:57 +0200 |
---|---|---|
committer | unknown <pem@mysql.com> | 2005-10-26 15:34:57 +0200 |
commit | 9349f18b4491b55d8edc4a314131bd44108278ad (patch) | |
tree | 8438f02a4a9ed206e60f26923143418163c0ba22 /sql/sql_base.cc | |
parent | 10a889a577e1a09f29922ba20d7e8ad96449bb04 (diff) | |
download | mariadb-git-9349f18b4491b55d8edc4a314131bd44108278ad.tar.gz |
Fixed BUG#14233: Crash after tampering with the mysql.proc table
Added error checking for errors when attempting to use stored procedures
after the mysql.proc table has been dropped, corrupted, or tampered with.
Test cases were put in a separate file (sp-destruct.test).
mysql-test/t/sp.test:
Added comment.
sql/share/errmsg.txt:
New error message for corrupted mysql.proc table.
sql/sp.cc:
Check and return error code when caching stored routines.
In the case when no error message has been set, set one.
sql/sp.h:
Return error code from stored routine cache function.
sql/sql_base.cc:
Check for error from sp_cache_routines_* calls.
sql/sql_trigger.h:
Updated friend declaration for sp_cache_routines*.
mysql-test/r/sp-destruct.result:
New test file for destruction of the mysql.proc table.
mysql-test/t/sp-destruct.test:
New result file for destruction of the mysql.proc table.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 973fbca12f5..ed05dc6720a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1978,15 +1978,20 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) if (!thd->prelocked_mode && !thd->lex->requires_prelocking() && thd->lex->sroutines_list.elements) { - bool first_no_prelocking, need_prelocking; + bool first_no_prelocking, need_prelocking, tabs_changed; TABLE_LIST **save_query_tables_last= thd->lex->query_tables_last; DBUG_ASSERT(thd->lex->query_tables == *start); sp_get_prelocking_info(thd, &need_prelocking, &first_no_prelocking); - if ((sp_cache_routines_and_add_tables(thd, thd->lex, - first_no_prelocking) || - *start) && need_prelocking) + if (sp_cache_routines_and_add_tables(thd, thd->lex, + first_no_prelocking, + &tabs_changed) < 0) + { + result= -1; // Fatal error + goto err; + } + else if ((tabs_changed || *start) && need_prelocking) { query_tables_last_own= save_query_tables_last; *start= thd->lex->query_tables; @@ -2110,9 +2115,13 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) tables->lock_type >= TL_WRITE_ALLOW_WRITE) { if (!query_tables_last_own) - query_tables_last_own= thd->lex->query_tables_last; - sp_cache_routines_and_add_tables_for_triggers(thd, thd->lex, - tables->table->triggers); + query_tables_last_own= thd->lex->query_tables_last; + if (sp_cache_routines_and_add_tables_for_triggers(thd, thd->lex, + tables->table->triggers) < 0) + { + result= -1; // Fatal error + goto err; + } } free_root(&new_frm_mem, MYF(MY_KEEP_PREALLOC)); } @@ -2133,9 +2142,16 @@ process_view_routines: /* We have at least one table in TL here. */ if (!query_tables_last_own) query_tables_last_own= thd->lex->query_tables_last; - sp_cache_routines_and_add_tables_for_view(thd, thd->lex, tables->view); + if (sp_cache_routines_and_add_tables_for_view(thd, thd->lex, + tables->view) < 0) + { + result= -1; // Fatal error + goto err; + } } } + + err: thd->proc_info=0; free_root(&new_frm_mem, MYF(0)); // Free pre-alloced block |