Commit bf2aae04 authored by Konstantin Osipov's avatar Konstantin Osipov

Backport of:

----------------------------------------------------------
revno: 2630.4.31
committer: Konstantin Osipov <konstantin@mysql.com>
branch nick: mysql-6.0-3726
timestamp: Thu 2008-06-12 06:23:08 +0400
message:
  Extend the signature of TABLE_LIST::init_one_table() to 
  initialize lengths

This is part of WL#3726 post-review fixes.
parent 7d3ad72e
......@@ -554,7 +554,7 @@ Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type,
TABLE_LIST tables;
DBUG_ENTER("Event_db_repository::open_event_table");
tables.init_one_table("mysql", "event", "event", lock_type);
tables.init_one_table("mysql", 5, "event", 5, "event", lock_type);
alloc_mdl_locks(&tables, thd->mem_root);
if (simple_open_n_lock_tables(thd, &tables))
......@@ -1109,7 +1109,7 @@ Event_db_repository::check_system_tables(THD *thd)
/* Check mysql.db */
tables.init_one_table("mysql", "db", "db", TL_READ);
tables.init_one_table("mysql", 5, "db", 2, "db", TL_READ);
alloc_mdl_locks(&tables, thd->mem_root);
if (simple_open_n_lock_tables(thd, &tables))
......@@ -1127,7 +1127,7 @@ Event_db_repository::check_system_tables(THD *thd)
close_thread_tables(thd);
}
/* Check mysql.user */
tables.init_one_table("mysql", "user", "user", TL_READ);
tables.init_one_table("mysql", 5, "user", 4, "user", TL_READ);
alloc_mdl_locks(&tables, thd->mem_root);
if (simple_open_n_lock_tables(thd, &tables))
......@@ -1148,7 +1148,7 @@ Event_db_repository::check_system_tables(THD *thd)
close_thread_tables(thd);
}
/* Check mysql.event */
tables.init_one_table("mysql", "event", "event", TL_READ);
tables.init_one_table("mysql", 5, "event", 5, "event", TL_READ);
alloc_mdl_locks(&tables, thd->mem_root);
if (simple_open_n_lock_tables(thd, &tables))
......
......@@ -2924,16 +2924,16 @@ Locked_tables_list::init_locked_tables(THD *thd)
{
TABLE_LIST *src_table_list= table->pos_in_table_list;
char *db, *table_name, *alias;
size_t db_len= strlen(src_table_list->db) + 1;
size_t table_name_len= strlen(src_table_list->table_name) + 1;
size_t alias_len= strlen(src_table_list->alias) + 1;
size_t db_len= src_table_list->db_length;
size_t table_name_len= src_table_list->table_name_length;
size_t alias_len= strlen(src_table_list->alias);
TABLE_LIST *dst_table_list;
if (! multi_alloc_root(&m_locked_tables_root,
&dst_table_list, sizeof(*dst_table_list),
&db, db_len,
&table_name, table_name_len,
&alias, alias_len,
&db, db_len + 1,
&table_name, table_name_len + 1,
&alias, alias_len + 1,
NullS))
{
unlock_locked_tables(0);
......@@ -2947,13 +2947,14 @@ Locked_tables_list::init_locked_tables(THD *thd)
TL_WRITE_DEFAULT, whereas reginfo.lock_type has been updated from
thd->update_lock_default.
*/
dst_table_list->init_one_table(db, table_name, alias,
dst_table_list->init_one_table(db, db_len, table_name, table_name_len,
alias,
src_table_list->table->reginfo.lock_type);
dst_table_list->mdl_lock_data= src_table_list->mdl_lock_data;
dst_table_list->table= table;
memcpy(db, src_table_list->db, db_len);
memcpy(table_name, src_table_list->table_name, table_name_len);
memcpy(alias, src_table_list->alias, alias_len);
memcpy(db, src_table_list->db, db_len + 1);
memcpy(table_name, src_table_list->table_name, table_name_len + 1);
memcpy(alias, src_table_list->alias, alias_len + 1);
/* Link last into the list of tables */
*(dst_table_list->prev_global= m_locked_tables_last)= dst_table_list;
m_locked_tables_last= &dst_table_list->next_global;
......
......@@ -1120,13 +1120,17 @@ struct TABLE_LIST
simple_open_and_lock_tables
*/
inline void init_one_table(const char *db_name_arg,
size_t db_length_arg,
const char *table_name_arg,
size_t table_name_length_arg,
const char *alias_arg,
enum thr_lock_type lock_type_arg)
{
bzero((char*) this, sizeof(*this));
db= (char*) db_name_arg;
db_length= db_length_arg;
table_name= (char*) table_name_arg;
table_name_length= table_name_length_arg;
alias= (char*) alias_arg;
lock_type= lock_type_arg;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment