Commit f398ced7 authored by Sergei Golubchik's avatar Sergei Golubchik

don't compare table names to detect temporary tables

(also fixes a bug with unaccounted table names like #sql-123,
see drop and alter_table tests)
parent 1035a16a
......@@ -2265,12 +2265,6 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
}
delete file;
if (likely(error == 0))
{
PSI_CALL_drop_table_share(is_prefix(alias, tmp_file_prefix),
db, strlen(db), alias, strlen(alias));
}
DBUG_RETURN(error);
}
......@@ -2353,8 +2347,7 @@ void handler::rebind_psi()
Notify the instrumentation that this table is now owned
by this thread.
*/
PSI_table_share *share_psi= ha_table_share_psi();
m_psi= PSI_CALL_rebind_table(share_psi, this, m_psi);
m_psi= PSI_CALL_rebind_table(ha_table_share_psi(), this, m_psi);
}
......@@ -4316,8 +4309,9 @@ int ha_create_table(THD *thd, const char *path,
char name_buff[FN_REFLEN];
const char *name;
TABLE_SHARE share;
bool temp_table __attribute__((unused)) = create_info->tmp_table() ||
is_prefix(table_name, tmp_file_prefix);
bool temp_table __attribute__((unused)) =
create_info->options & (HA_LEX_CREATE_TMP_TABLE | HA_CREATE_TMP_ALTER);
DBUG_ENTER("ha_create_table");
init_tmp_table_share(thd, &share, db, 0, table_name, path);
......
......@@ -320,6 +320,7 @@
#define HA_LEX_CREATE_TMP_TABLE 1
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
#define HA_LEX_CREATE_TABLE_LIKE 4
#define HA_CREATE_TMP_ALTER 8
#define HA_MAX_REC_LENGTH 65535
/* Table caching type */
......@@ -1437,7 +1438,7 @@ struct HA_CREATE_INFO
const char *alias;
ulonglong max_rows,min_rows;
ulonglong auto_increment_value;
ulong table_options;
ulong table_options; ///< HA_OPTION_ values
ulong avg_row_length;
ulong used_fields;
ulong key_block_size;
......
......@@ -2374,6 +2374,13 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
wrong_tables.append(',');
wrong_tables.append(String(table->table_name,system_charset_info));
}
else
{
PSI_CALL_drop_table_share(table->internal_tmp_table,
table->db, table->db_length,
table->table_name, table->table_name_length);
}
DBUG_PRINT("table", ("table: 0x%lx s: 0x%lx", (long) table->table,
table->table ? (long) table->table->s : (long) -1));
......@@ -2510,6 +2517,11 @@ bool quick_rm_table(handlerton *base,const char *db,
path[path_length - reg_ext_length]= '\0'; // Remove reg_ext
if (!(flags & FRM_ONLY))
error|= ha_delete_table(current_thd, base, path, db, table_name, 0);
if (likely(error == 0))
PSI_CALL_drop_table_share(flags & FN_IS_TMP, db, strlen(db),
table_name, strlen(table_name));
DBUG_RETURN(error);
}
......@@ -4674,7 +4686,7 @@ mysql_rename_table(handlerton *base, const char *old_db,
*/
if (likely(error == 0))
{
PSI_CALL_drop_table_share(is_prefix(old_name, tmp_file_prefix),
PSI_CALL_drop_table_share(flags & FN_FROM_IS_TMP,
old_db, strlen(old_db),
old_name, strlen(old_name));
}
......@@ -7001,6 +7013,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
HA_OPTION_PACK_RECORD));
}
tmp_disable_binlog(thd);
create_info->options|=HA_CREATE_TMP_ALTER;
error= mysql_create_table_no_lock(thd, new_db, tmp_name, create_info,
alter_info, NULL, create_table_mode);
reenable_binlog(thd);
......
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