mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
First stage of table definition cache
Split TABLE to TABLE and TABLE_SHARE (TABLE_SHARE is still allocated as part of table, will be fixed soon) Created Field::make_field() and made Field_num::make_field() to call this Added 'TABLE_SHARE->db' that points to database name; Changed all usage of table_cache_key as database name to use this instead Changed field->table_name to point to pointer to alias. This allows us to change alias for a table by just updating one pointer. Renamed TABLE_SHARE->real_name to table_name Renamed TABLE->table_name to alias Renamed TABLE_LIST->real_name to table_name
This commit is contained in:
@@ -1228,7 +1228,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
|
||||
if (!(table_list = (TABLE_LIST*) thd->calloc(sizeof(TABLE_LIST))))
|
||||
DBUG_RETURN(1); // out of memory
|
||||
table_list->db= db;
|
||||
table_list->real_name= table_list->alias= tbl_name;
|
||||
table_list->table_name= table_list->alias= tbl_name;
|
||||
table_list->lock_type= TL_READ_NO_INSERT;
|
||||
table_list->prev_global= &table_list; // can be removed after merge with 4.1
|
||||
|
||||
@@ -1239,7 +1239,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
|
||||
}
|
||||
if (lower_case_table_names)
|
||||
my_casedn_str(files_charset_info, tbl_name);
|
||||
remove_escape(table_list->real_name);
|
||||
remove_escape(table_list->table_name);
|
||||
|
||||
if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT)))
|
||||
DBUG_RETURN(1);
|
||||
@@ -1601,7 +1601,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
pend= strend(packet);
|
||||
thd->convert_string(&conv_name, system_charset_info,
|
||||
packet, (uint) (pend-packet), thd->charset());
|
||||
table_list.alias= table_list.real_name= conv_name.str;
|
||||
table_list.alias= table_list.table_name= conv_name.str;
|
||||
packet= pend+1;
|
||||
|
||||
if (!my_strcasecmp(system_charset_info, table_list.db,
|
||||
@@ -1615,10 +1615,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
/* command not cachable => no gap for data base name */
|
||||
if (!(thd->query=fields=thd->memdup(packet,thd->query_length+1)))
|
||||
break;
|
||||
mysql_log.write(thd,command,"%s %s",table_list.real_name,fields);
|
||||
mysql_log.write(thd,command,"%s %s",table_list.table_name, fields);
|
||||
if (lower_case_table_names)
|
||||
my_casedn_str(files_charset_info, table_list.real_name);
|
||||
remove_escape(table_list.real_name); // This can't have wildcards
|
||||
my_casedn_str(files_charset_info, table_list.table_name);
|
||||
remove_escape(table_list.table_name); // This can't have wildcards
|
||||
|
||||
if (check_access(thd,SELECT_ACL,table_list.db,&table_list.grant.privilege,
|
||||
0, 0))
|
||||
@@ -1975,7 +1975,7 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
|
||||
TABLE_LIST *table_list= (TABLE_LIST*) sel->table_list.first;
|
||||
char *db= table_list->db;
|
||||
remove_escape(db); // Fix escaped '_'
|
||||
remove_escape(table_list->real_name);
|
||||
remove_escape(table_list->table_name);
|
||||
if (check_access(thd,SELECT_ACL | EXTRA_ACL,db,
|
||||
&table_list->grant.privilege, 0, 0))
|
||||
DBUG_RETURN(1); /* purecov: inspected */
|
||||
@@ -2534,9 +2534,9 @@ mysql_execute_command(THD *thd)
|
||||
if (check_grant(thd, CREATE_ACL, all_tables, 0, 1, 0))
|
||||
goto error;
|
||||
}
|
||||
if (strlen(first_table->real_name) > NAME_LEN)
|
||||
if (strlen(first_table->table_name) > NAME_LEN)
|
||||
{
|
||||
my_error(ER_WRONG_TABLE_NAME, MYF(0), first_table->real_name);
|
||||
my_error(ER_WRONG_TABLE_NAME, MYF(0), first_table->table_name);
|
||||
break;
|
||||
}
|
||||
pthread_mutex_lock(&LOCK_active_mi);
|
||||
@@ -2544,7 +2544,7 @@ mysql_execute_command(THD *thd)
|
||||
fetch_master_table will send the error to the client on failure.
|
||||
Give error if the table already exists.
|
||||
*/
|
||||
if (!fetch_master_table(thd, first_table->db, first_table->real_name,
|
||||
if (!fetch_master_table(thd, first_table->db, first_table->table_name,
|
||||
active_mi, 0, 0))
|
||||
{
|
||||
send_ok(thd);
|
||||
@@ -2570,9 +2570,9 @@ mysql_execute_command(THD *thd)
|
||||
#else
|
||||
/* Fix names if symlinked tables */
|
||||
if (append_file_to_dir(thd, &lex->create_info.data_file_name,
|
||||
create_table->real_name) ||
|
||||
create_table->table_name) ||
|
||||
append_file_to_dir(thd, &lex->create_info.index_file_name,
|
||||
create_table->real_name))
|
||||
create_table->table_name))
|
||||
goto create_error;
|
||||
#endif
|
||||
/*
|
||||
@@ -2604,7 +2604,7 @@ mysql_execute_command(THD *thd)
|
||||
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) &&
|
||||
unique_table(create_table, select_tables))
|
||||
{
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->real_name);
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->table_name);
|
||||
goto create_error;
|
||||
}
|
||||
/* If we create merge table, we have to test tables in merge, too */
|
||||
@@ -2617,7 +2617,7 @@ mysql_execute_command(THD *thd)
|
||||
{
|
||||
if (unique_table(tab, select_tables))
|
||||
{
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->real_name);
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->table_name);
|
||||
goto create_error;
|
||||
}
|
||||
}
|
||||
@@ -2654,7 +2654,7 @@ mysql_execute_command(THD *thd)
|
||||
else
|
||||
{
|
||||
res= mysql_create_table(thd, create_table->db,
|
||||
create_table->real_name, &lex->create_info,
|
||||
create_table->table_name, &lex->create_info,
|
||||
lex->create_list,
|
||||
lex->key_list, 0, 0);
|
||||
}
|
||||
@@ -2747,7 +2747,7 @@ create_error:
|
||||
{ // Rename of table
|
||||
TABLE_LIST tmp_table;
|
||||
bzero((char*) &tmp_table,sizeof(tmp_table));
|
||||
tmp_table.real_name=lex->name;
|
||||
tmp_table.table_name=lex->name;
|
||||
tmp_table.db=select_lex->db;
|
||||
tmp_table.grant.privilege=priv;
|
||||
if (check_grant(thd, INSERT_ACL | CREATE_ACL, &tmp_table, 0,
|
||||
@@ -4331,7 +4331,7 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
|
||||
for (; tables; tables= tables->next_global)
|
||||
{
|
||||
if (tables->derived || tables->schema_table ||
|
||||
(tables->table && (int)tables->table->tmp_table) ||
|
||||
(tables->table && (int)tables->table->s->tmp_table) ||
|
||||
my_tz_check_n_skip_implicit_tables(&tables,
|
||||
thd->lex->time_zone_tables_used))
|
||||
continue;
|
||||
@@ -4370,7 +4370,7 @@ check_procedure_access(THD *thd, ulong want_access,char *db, char *name,
|
||||
|
||||
bzero((char *)tables, sizeof(TABLE_LIST));
|
||||
tables->db= db;
|
||||
tables->real_name= tables->alias= name;
|
||||
tables->table_name= tables->alias= name;
|
||||
|
||||
if ((thd->master_access & want_access) == want_access && !thd->db)
|
||||
tables->grant.privilege= want_access;
|
||||
@@ -5319,8 +5319,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
ptr->alias= alias_str;
|
||||
if (lower_case_table_names && table->table.length)
|
||||
my_casedn_str(files_charset_info, table->table.str);
|
||||
ptr->real_name=table->table.str;
|
||||
ptr->real_name_length=table->table.length;
|
||||
ptr->table_name=table->table.str;
|
||||
ptr->table_name_length=table->table.length;
|
||||
ptr->lock_type= lock_type;
|
||||
ptr->updating= test(table_options & TL_OPTION_UPDATING);
|
||||
ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX);
|
||||
@@ -5329,13 +5329,13 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
if (!my_strcasecmp(system_charset_info, ptr->db,
|
||||
information_schema_name.str))
|
||||
{
|
||||
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->real_name);
|
||||
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name);
|
||||
if (!schema_table ||
|
||||
(schema_table->hidden &&
|
||||
lex->orig_sql_command == SQLCOM_END)) // not a 'show' command
|
||||
{
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0),
|
||||
ptr->real_name, information_schema_name.str);
|
||||
ptr->table_name, information_schema_name.str);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
ptr->schema_table= schema_table;
|
||||
@@ -6039,7 +6039,7 @@ bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
|
||||
bzero((char*) &create_info,sizeof(create_info));
|
||||
create_info.db_type=DB_TYPE_DEFAULT;
|
||||
create_info.default_table_charset= thd->variables.collation_database;
|
||||
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
|
||||
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
|
||||
&create_info, table_list,
|
||||
fields, keys, 0, (ORDER*)0,
|
||||
DUP_ERROR, 0, &alter_info));
|
||||
@@ -6057,7 +6057,7 @@ bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info)
|
||||
create_info.default_table_charset= thd->variables.collation_database;
|
||||
alter_info->clear();
|
||||
alter_info->flags= ALTER_DROP_INDEX;
|
||||
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
|
||||
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
|
||||
&create_info, table_list,
|
||||
fields, keys, 0, (ORDER*)0,
|
||||
DUP_ERROR, 0, alter_info));
|
||||
@@ -6193,7 +6193,7 @@ bool multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count)
|
||||
if (!walk)
|
||||
{
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0),
|
||||
target_tbl->real_name, "MULTI DELETE");
|
||||
target_tbl->table_name, "MULTI DELETE");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
walk->lock_type= target_tbl->lock_type;
|
||||
@@ -6343,7 +6343,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
|
||||
*/
|
||||
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) &&
|
||||
find_table_in_global_list(tables, create_table->db,
|
||||
create_table->real_name))
|
||||
create_table->table_name))
|
||||
{
|
||||
error= FALSE;
|
||||
goto err;
|
||||
|
||||
Reference in New Issue
Block a user