diff options
author | Monty <monty@mariadb.org> | 2018-01-07 18:03:44 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-01-30 21:33:55 +0200 |
commit | a7e352b54ddfaf91c92951d605cb02a4ffd2676b (patch) | |
tree | dc76f140342938ed2a0fe0e005100402762d5308 /sql/sql_truncate.cc | |
parent | 921c5e931452301a09c84c53ffe35b81e6a1c71a (diff) | |
download | mariadb-git-a7e352b54ddfaf91c92951d605cb02a4ffd2676b.tar.gz |
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 "")
Diffstat (limited to 'sql/sql_truncate.cc')
-rw-r--r-- | sql/sql_truncate.cc | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index bd3f1fdc111..2ddb4bc042c 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -48,7 +48,7 @@ static bool fk_info_append_fields(THD *thd, String *str, while ((field= it++)) { - res|= append_identifier(thd, str, field->str, field->length); + res|= append_identifier(thd, str, field); res|= str->append(", "); } @@ -80,22 +80,17 @@ static const char *fk_info_str(THD *thd, FOREIGN_KEY_INFO *fk_info) `db`.`tbl`, CONSTRAINT `id` FOREIGN KEY (`fk`) REFERENCES `db`.`tbl` (`fk`) */ - res|= append_identifier(thd, &str, fk_info->foreign_db->str, - fk_info->foreign_db->length); + res|= append_identifier(thd, &str, fk_info->foreign_db); res|= str.append("."); - res|= append_identifier(thd, &str, fk_info->foreign_table->str, - fk_info->foreign_table->length); + res|= append_identifier(thd, &str, fk_info->foreign_table); res|= str.append(", CONSTRAINT "); - res|= append_identifier(thd, &str, fk_info->foreign_id->str, - fk_info->foreign_id->length); + res|= append_identifier(thd, &str, fk_info->foreign_id); res|= str.append(" FOREIGN KEY ("); res|= fk_info_append_fields(thd, &str, &fk_info->foreign_fields); res|= str.append(") REFERENCES "); - res|= append_identifier(thd, &str, fk_info->referenced_db->str, - fk_info->referenced_db->length); + res|= append_identifier(thd, &str, fk_info->referenced_db); res|= str.append("."); - res|= append_identifier(thd, &str, fk_info->referenced_table->str, - fk_info->referenced_table->length); + res|= append_identifier(thd, &str, fk_info->referenced_table); res|= str.append(" ("); res|= fk_info_append_fields(thd, &str, &fk_info->referenced_fields); res|= str.append(')'); @@ -303,8 +298,8 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref, */ if (thd->locked_tables_mode) { - if (!(table= find_table_for_mdl_upgrade(thd, table_ref->db, - table_ref->table_name, FALSE))) + if (!(table= find_table_for_mdl_upgrade(thd, table_ref->db.str, + table_ref->table_name.str, FALSE))) DBUG_RETURN(TRUE); *hton_can_recreate= ha_check_storage_engine_flag(table->s->db_type(), @@ -322,11 +317,12 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref, thd->variables.lock_wait_timeout, 0)) DBUG_RETURN(TRUE); - if (!ha_table_exists(thd, table_ref->db, table_ref->table_name, + if (!ha_table_exists(thd, &table_ref->db, &table_ref->table_name, &hton, &is_sequence) || hton == view_pseudo_hton) { - my_error(ER_NO_SUCH_TABLE, MYF(0), table_ref->db, table_ref->table_name); + my_error(ER_NO_SUCH_TABLE, MYF(0), table_ref->db.str, + table_ref->table_name.str); DBUG_RETURN(TRUE); } @@ -364,8 +360,8 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref, else { /* Table is already locked exclusively. Remove cached instances. */ - tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table_ref->db, - table_ref->table_name, FALSE); + tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table_ref->db.str, + table_ref->table_name.str, FALSE); } DBUG_RETURN(FALSE); @@ -418,7 +414,7 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) bool hton_can_recreate; if (WSREP(thd) && - wsrep_to_isolation_begin(thd, table_ref->db, table_ref->table_name, 0)) + wsrep_to_isolation_begin(thd, table_ref->db.str, table_ref->table_name.str, 0)) DBUG_RETURN(TRUE); if (lock_table(thd, table_ref, &hton_can_recreate)) DBUG_RETURN(TRUE); @@ -429,7 +425,7 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) The storage engine can truncate the table by creating an empty table with the same structure. */ - error= dd_recreate_table(thd, table_ref->db, table_ref->table_name); + error= dd_recreate_table(thd, table_ref->db.str, table_ref->table_name.str); if (thd->locked_tables_mode && thd->locked_tables_list.reopen_tables(thd)) thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); |