mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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 "")
This commit is contained in:
@ -168,9 +168,9 @@ static bool check_view_single_update(List<Item> &fields, List<Item> *values,
|
||||
if (!tbl->single_table_updatable())
|
||||
{
|
||||
if (insert)
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), view->alias, "INSERT");
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), view->alias.str, "INSERT");
|
||||
else
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), view->alias, "UPDATE");
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), view->alias.str, "UPDATE");
|
||||
return TRUE;
|
||||
}
|
||||
*map= tables;
|
||||
@ -210,7 +210,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
|
||||
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias.str, "INSERT");
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
|
||||
(table_list->view &&
|
||||
check_view_insertability(thd, table_list)))
|
||||
{
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias.str, "INSERT");
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
@ -742,11 +742,11 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
*/
|
||||
if (table_list->lock_type == TL_WRITE_DELAYED &&
|
||||
thd->locked_tables_mode &&
|
||||
find_locked_table(thd->open_tables, table_list->db,
|
||||
table_list->table_name))
|
||||
find_locked_table(thd->open_tables, table_list->db.str,
|
||||
table_list->table_name.str))
|
||||
{
|
||||
my_error(ER_DELAYED_INSERT_TABLE_LOCKED, MYF(0),
|
||||
table_list->table_name);
|
||||
table_list->table_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
@ -1381,7 +1381,7 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
|
||||
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias.str, "INSERT");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
@ -2262,8 +2262,8 @@ Delayed_insert *find_handler(THD *thd, TABLE_LIST *table_list)
|
||||
Delayed_insert *di;
|
||||
while ((di= it++))
|
||||
{
|
||||
if (!strcmp(table_list->db, di->table_list.db) &&
|
||||
!strcmp(table_list->table_name, di->table_list.table_name))
|
||||
if (!cmp(&table_list->db, &di->table_list.db) &&
|
||||
!cmp(&table_list->table_name, &di->table_list.table_name))
|
||||
{
|
||||
di->lock();
|
||||
break;
|
||||
@ -2327,7 +2327,7 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
|
||||
DBUG_ENTER("delayed_get_table");
|
||||
|
||||
/* Must be set in the parser */
|
||||
DBUG_ASSERT(table_list->db);
|
||||
DBUG_ASSERT(table_list->db.str);
|
||||
|
||||
/* Find the thread which handles this table. */
|
||||
if (!(di= find_handler(thd, table_list)))
|
||||
@ -2354,11 +2354,12 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
|
||||
*/
|
||||
di->thd.variables.binlog_annotate_row_events= 0;
|
||||
|
||||
di->thd.set_db(table_list->db, (uint) strlen(table_list->db));
|
||||
di->thd.set_query(my_strdup(table_list->table_name,
|
||||
MYF(MY_WME | ME_FATALERROR)),
|
||||
0, system_charset_info);
|
||||
if (di->thd.db == NULL || di->thd.query() == NULL)
|
||||
di->thd.set_db(&table_list->db);
|
||||
di->thd.set_query(my_strndup(table_list->table_name.str,
|
||||
table_list->table_name.length,
|
||||
MYF(MY_WME | ME_FATALERROR)),
|
||||
table_list->table_name.length, system_charset_info);
|
||||
if (di->thd.db.str == NULL || di->thd.query() == NULL)
|
||||
{
|
||||
/* The error is reported */
|
||||
delete di;
|
||||
@ -2366,7 +2367,8 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
|
||||
}
|
||||
di->table_list= *table_list; // Needed to open table
|
||||
/* Replace volatile strings with local copies */
|
||||
di->table_list.alias= di->table_list.table_name= di->thd.query();
|
||||
di->table_list.alias.str= di->table_list.table_name.str= di->thd.query();
|
||||
di->table_list.alias.length= di->table_list.table_name.length= di->thd.query_length();
|
||||
di->table_list.db= di->thd.db;
|
||||
/* We need the tickets so that they can be cloned in handle_delayed_insert */
|
||||
di->grl_protection.init(MDL_key::GLOBAL, "", "",
|
||||
@ -2848,7 +2850,7 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
|
||||
|
||||
if (!(table_list->table->file->ha_table_flags() & HA_CAN_INSERT_DELAYED))
|
||||
{
|
||||
my_error(ER_DELAYED_NOT_SUPPORTED, MYF(0), table_list->table_name);
|
||||
my_error(ER_DELAYED_NOT_SUPPORTED, MYF(0), table_list->table_name.str);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@ -4219,8 +4221,8 @@ TABLE *select_create::create_table_from_items(THD *thd,
|
||||
open_table().
|
||||
*/
|
||||
|
||||
if (!mysql_create_table_no_lock(thd, create_table->db,
|
||||
create_table->table_name,
|
||||
if (!mysql_create_table_no_lock(thd, &create_table->db,
|
||||
&create_table->table_name,
|
||||
create_info, alter_info, NULL,
|
||||
select_field_count, create_table))
|
||||
{
|
||||
@ -4246,8 +4248,8 @@ TABLE *select_create::create_table_from_items(THD *thd,
|
||||
*/
|
||||
if (open_table(thd, create_table, &ot_ctx))
|
||||
{
|
||||
quick_rm_table(thd, create_info->db_type, create_table->db,
|
||||
table_case_name(create_info, create_table->table_name),
|
||||
quick_rm_table(thd, create_info->db_type, &create_table->db,
|
||||
table_case_name(create_info, &create_table->table_name),
|
||||
0);
|
||||
}
|
||||
/* Restore */
|
||||
@ -4304,7 +4306,7 @@ TABLE *select_create::create_table_from_items(THD *thd,
|
||||
mysql_unlock_tables(thd, *lock);
|
||||
*lock= 0;
|
||||
}
|
||||
drop_open_table(thd, table, create_table->db, create_table->table_name);
|
||||
drop_open_table(thd, table, &create_table->db, &create_table->table_name);
|
||||
DBUG_RETURN(0);
|
||||
/* purecov: end */
|
||||
}
|
||||
@ -4692,16 +4694,14 @@ void select_create::abort_result_set()
|
||||
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
|
||||
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
|
||||
table->auto_increment_field_not_null= FALSE;
|
||||
drop_open_table(thd, table, create_table->db, create_table->table_name);
|
||||
drop_open_table(thd, table, &create_table->db, &create_table->table_name);
|
||||
table=0; // Safety
|
||||
if (thd->log_current_statement && mysql_bin_log.is_open())
|
||||
{
|
||||
/* Remove logging of drop, create + insert rows */
|
||||
binlog_reset_cache(thd);
|
||||
/* Original table was deleted. We have to log it */
|
||||
log_drop_table(thd, create_table->db, create_table->db_length,
|
||||
create_table->table_name, create_table->table_name_length,
|
||||
tmp_table);
|
||||
log_drop_table(thd, &create_table->db, &create_table->table_name, tmp_table);
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
|
Reference in New Issue
Block a user