From a7e352b54ddfaf91c92951d605cb02a4ffd2676b Mon Sep 17 00:00:00 2001 From: Monty Date: Sun, 7 Jan 2018 18:03:44 +0200 Subject: Changed database, tablename and alias to be LEX_CSTRING This was done in, among other things: - thd->db and thd->db_length - TABLE_LIST tablename, db, alias and schema_name - Audit plugin database name - lex->db - All db and table names in Alter_table_ctx - st_select_lex db Other things: - Changed a lot of functions to take const LEX_CSTRING* as argument for db, table_name and alias. See init_one_table() as an example. - Changed some function arguments from LEX_CSTRING to const LEX_CSTRING - Changed some lists from LEX_STRING to LEX_CSTRING - threads_mysql.result changed because process list_db wasn't always correctly updated - New append_identifier() function that takes LEX_CSTRING* as arguments - Added new element tmp_buff to Alter_table_ctx to separate temp name handling from temporary space - Ensure we store the length after my_casedn_str() of table/db names - Removed not used version of rename_table_in_stat_tables() - Changed Natural_join_column::table_name and db_name() to never return NULL (used for print) - thd->get_db() now returns db as a printable string (thd->db.str or "") --- sql/sql_udf.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'sql/sql_udf.cc') diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 7b2d041a094..ecf05d86193 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -52,7 +52,7 @@ static bool initialized = 0; static MEM_ROOT mem; static HASH udf_hash; static mysql_rwlock_t THR_LOCK_udf; - +static LEX_CSTRING MYSQL_FUNC_NAME= {STRING_WITH_LEN("func") }; static udf_func *add_udf(LEX_CSTRING *name, Item_result ret, const char *dl, Item_udftype typ); @@ -142,7 +142,6 @@ void udf_init() TABLE *table; int error; DBUG_ENTER("ufd_init"); - char db[]= "mysql"; /* A subject to casednstr, can't be constant */ if (initialized || opt_noacl) DBUG_VOID_RETURN; @@ -167,9 +166,9 @@ void udf_init() initialized = 1; new_thd->thread_stack= (char*) &new_thd; new_thd->store_globals(); - new_thd->set_db(db, sizeof(db)-1); + new_thd->set_db(&MYSQL_SCHEMA_NAME); - tables.init_one_table(db, sizeof(db)-1, "func", 4, "func", TL_READ); + tables.init_one_table(&new_thd->db, &MYSQL_FUNC_NAME, 0, TL_READ); if (open_and_lock_tables(new_thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) { @@ -504,8 +503,7 @@ int mysql_create_function(THD *thd,udf_func *udf) if (check_ident_length(&udf->name)) DBUG_RETURN(1); - tables.init_one_table(STRING_WITH_LEN("mysql"), STRING_WITH_LEN("func"), - "func", TL_WRITE); + tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_FUNC_NAME, 0, TL_WRITE); table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT); mysql_rwlock_wrlock(&THR_LOCK_udf); @@ -623,8 +621,7 @@ int mysql_drop_function(THD *thd, const LEX_CSTRING *udf_name) DBUG_RETURN(1); } - tables.init_one_table(STRING_WITH_LEN("mysql"), STRING_WITH_LEN("func"), - "func", TL_WRITE); + tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_FUNC_NAME, 0, TL_WRITE); table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT); mysql_rwlock_wrlock(&THR_LOCK_udf); -- cgit v1.2.1