diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-02-22 00:33:11 +0300 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-02-22 00:33:11 +0300 |
commit | 8c31c4d16cfe9c3bbafcb30d0cd70210f6f230d3 (patch) | |
tree | 94830ebea81e944773f55fcb501055d762e3db1d /sql/sql_trigger.cc | |
parent | b3e01b6da86dca93764ea67673c8d34f63e94cd2 (diff) | |
parent | ae12a723605f5059d73ee9284fd78ecc7583fac2 (diff) | |
download | mariadb-git-8c31c4d16cfe9c3bbafcb30d0cd70210f6f230d3.tar.gz |
Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r-- | sql/sql_trigger.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index aa2ed498de1..1b63d8493be 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -327,6 +327,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) TABLE *table; bool result= TRUE; String stmt_query; + Query_tables_list backup; bool need_start_waiting= FALSE; DBUG_ENTER("mysql_create_or_drop_trigger"); @@ -393,6 +394,12 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) { bool if_exists= thd->lex->drop_if_exists; + /* + Protect the query table list from the temporary and potentially + destructive changes necessary to open the trigger's table. + */ + thd->lex->reset_n_backup_query_tables_list(&backup); + if (add_table_for_trigger(thd, thd->lex->spname, if_exists, & tables)) goto end; @@ -512,6 +519,10 @@ end: VOID(pthread_mutex_unlock(&LOCK_open)); + /* Restore the query table list. Used only for drop trigger. */ + if (!create) + thd->lex->restore_backup_query_tables_list(&backup); + if (need_start_waiting) start_waiting_global_read_lock(thd); @@ -1625,10 +1636,6 @@ bool add_table_for_trigger(THD *thd, if (load_table_name_for_trigger(thd, trg_name, &trn_path, &tbl_name)) DBUG_RETURN(TRUE); - /* We need to reset statement table list to be PS/SP friendly. */ - lex->query_tables= 0; - lex->query_tables_last= &lex->query_tables; - *table= sp_add_to_query_tables(thd, lex, trg_name->m_db.str, tbl_name.str, TL_IGNORE); |