summaryrefslogtreecommitdiff
path: root/sql/sql_udf.cc
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2009-12-08 12:57:07 +0300
committerKonstantin Osipov <kostja@sun.com>2009-12-08 12:57:07 +0300
commita66a2608ae4d70a3f9b3d41e38cfb97eb616bed3 (patch)
treeb2b94a32418f0728974d2bad4d3fa70acc2d75ef /sql/sql_udf.cc
parent4a8a1c568d8785dc608cc111e74e1ed389f1353e (diff)
downloadmariadb-git-a66a2608ae4d70a3f9b3d41e38cfb97eb616bed3.tar.gz
Backport of:
---------------------------------------------------------- revno: 2617.69.20 committer: Konstantin Osipov <kostja@sun.com> branch nick: 5.4-4284-1-assert timestamp: Thu 2009-08-13 18:29:55 +0400 message: WL#4284 "Transactional DDL locking" A review fix. Since WL#4284 implementation separated MDL_request and MDL_ticket, MDL_request becamse a utility object necessary only to get a ticket. Store it by-value in TABLE_LIST with the intent to merge MDL_request::key with table_list->table_name and table_list->db in future. Change the MDL subsystem to not require MDL_requests to stay around till close_thread_tables(). Remove the list of requests from the MDL context. Requests for shared metadata locks acquired in open_tables() are only used as a list in recover_from_failed_open_table_attempt(), which calls mdl_context.wait_for_locks() for this list. To keep such list for recover_from_failed_open_table_attempt(), introduce a context class (Open_table_context), that collects all requests. A lot of minor cleanups and simplications that became possible with this change.
Diffstat (limited to 'sql/sql_udf.cc')
-rw-r--r--sql/sql_udf.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 7e557c3ce68..d27473c1959 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -138,11 +138,7 @@ void udf_init()
lex_start(new_thd);
new_thd->set_db(db, sizeof(db)-1);
- bzero((uchar*) &tables,sizeof(tables));
- tables.alias= tables.table_name= (char*) "func";
- tables.lock_type = TL_READ;
- tables.db= db;
- alloc_mdl_requests(&tables, new_thd->mem_root);
+ tables.init_one_table(db, sizeof(db)-1, "func", 4, "func", TL_READ);
if (simple_open_n_lock_tables(new_thd, &tables))
{
@@ -483,10 +479,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
/* create entry in mysql.func table */
- bzero((char*) &tables,sizeof(tables));
- tables.db= (char*) "mysql";
- tables.table_name= tables.alias= (char*) "func";
- alloc_mdl_requests(&tables, thd->mem_root);
+ tables.init_one_table("mysql", 5, "func", 4, "func", TL_WRITE);
/* Allow creation of functions even if we can't open func table */
if (!(table = open_ltable(thd, &tables, TL_WRITE, 0)))
goto err;
@@ -562,10 +555,8 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
if (udf->dlhandle && !find_udf_dl(udf->dl))
dlclose(udf->dlhandle);
- bzero((char*) &tables,sizeof(tables));
- tables.db=(char*) "mysql";
- tables.table_name= tables.alias= (char*) "func";
- alloc_mdl_requests(&tables, thd->mem_root);
+ tables.init_one_table("mysql", 5, "func", 4, "func", TL_WRITE);
+
if (!(table = open_ltable(thd, &tables, TL_WRITE, 0)))
goto err;
table->use_all_columns();
@@ -579,15 +570,16 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
if ((error = table->file->ha_delete_row(table->record[0])))
table->file->print_error(error, MYF(0));
}
- close_thread_tables(thd);
-
rw_unlock(&THR_LOCK_udf);
- /* Binlog the drop function. */
+ /*
+ Binlog the drop function. Keep the table open and locked
+ while binlogging, to avoid binlog inconsistency.
+ */
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
DBUG_RETURN(0);
- err:
+err:
rw_unlock(&THR_LOCK_udf);
DBUG_RETURN(1);
}