Commit 9594107f authored by Sergei Golubchik's avatar Sergei Golubchik

cleanups

parent 5f69c8a5
......@@ -158,26 +158,35 @@ bool dd_check_storage_engine_flag(THD *thd,
@param thd Thread context.
@param db Name of the database to which the table belongs to.
@param name Table name.
@param path For temporary tables only - path to table files.
Otherwise NULL (the path is calculated from db and table names).
@retval FALSE Success.
@retval TRUE Error.
*/
bool dd_recreate_table(THD *thd, const char *db, const char *table_name)
bool dd_recreate_table(THD *thd, const char *db, const char *table_name,
const char *path)
{
bool error= TRUE;
HA_CREATE_INFO create_info;
char path[FN_REFLEN + 1];
char path_buf[FN_REFLEN + 1];
DBUG_ENTER("dd_recreate_table");
/* There should be a exclusive metadata lock on the table. */
DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name,
MDL_EXCLUSIVE));
memset(&create_info, 0, sizeof(create_info));
/* Create a path to the table, but without a extension. */
build_table_filename(path, sizeof(path) - 1, db, table_name, "", 0);
if (path)
create_info.options|= HA_LEX_CREATE_TMP_TABLE;
else
{
build_table_filename(path_buf, sizeof(path_buf) - 1,
db, table_name, "", 0);
path= path_buf;
/* There should be a exclusive metadata lock on the table. */
DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, table_name,
MDL_EXCLUSIVE));
}
/* Attempt to reconstruct the table. */
error= ha_create_table(thd, path, db, table_name, &create_info);
......
......@@ -36,6 +36,7 @@ bool dd_check_storage_engine_flag(THD *thd,
const char *db, const char *table_name,
uint32 flag,
bool *yes_no);
bool dd_recreate_table(THD *thd, const char *db, const char *table_name);
bool dd_recreate_table(THD *thd, const char *db, const char *table_name,
const char *path = NULL);
#endif // DATADICT_INCLUDED
......@@ -258,25 +258,16 @@ static bool recreate_temporary_table(THD *thd, TABLE *table)
{
bool error= TRUE;
TABLE_SHARE *share= table->s;
HA_CREATE_INFO create_info;
handlerton *table_type= table->s->db_type();
DBUG_ENTER("recreate_temporary_table");
memset(&create_info, 0, sizeof(create_info));
create_info.options|= HA_LEX_CREATE_TMP_TABLE;
table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK);
/* Don't free share. */
close_temporary_table(thd, table, FALSE, FALSE);
/*
We must use share->normalized_path.str since for temporary tables it
differs from what dd_recreate_table() would generate based
on table and schema names.
*/
ha_create_table(thd, share->normalized_path.str, share->db.str,
share->table_name.str, &create_info);
dd_recreate_table(thd, share->db.str, share->table_name.str,
share->normalized_path.str);
if (open_table_uncached(thd, share->path.str, share->db.str,
share->table_name.str, TRUE))
......
......@@ -49,11 +49,9 @@ static bool pack_header(uchar *forminfo,enum legacy_db_type table_type,
static uint get_interval_id(uint *,List<Create_field> &, Create_field *);
static bool pack_fields(File file, List<Create_field> &create_fields,
ulong data_offset);
static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type,
uint table_options,
static bool make_empty_rec(THD *thd, int file, uint table_options,
List<Create_field> &create_fields,
uint reclength, ulong data_offset,
handler *handler);
uint reclength, ulong data_offset);
/**
An interceptor to hijack ER_TOO_MANY_FIELDS error from
......@@ -102,8 +100,8 @@ handle_condition(THD *,
create_fields Fields to create
keys number of keys to create
key_info Keys to create
db_file Handler to use. May be zero, in which case we use
create_info->db_type
db_file Handler to use.
RETURN
false ok
true error
......@@ -317,9 +315,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
mysql_file_seek(file,
(ulong) uint2korr(fileinfo+6) + (ulong) key_buff_length,
MY_SEEK_SET, MYF(0));
if (make_empty_rec(thd,file,ha_legacy_type(create_info->db_type),
create_info->table_options,
create_fields,reclength, data_offset, db_file))
if (make_empty_rec(thd, file, create_info->table_options,
create_fields, reclength, data_offset))
goto err;
int2store(buff, create_info->connect_string.length);
......@@ -1064,12 +1061,9 @@ static bool pack_fields(File file, List<Create_field> &create_fields,
/* save an empty record on start of formfile */
static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
uint table_options,
static bool make_empty_rec(THD *thd, File file, uint table_options,
List<Create_field> &create_fields,
uint reclength,
ulong data_offset,
handler *handler)
uint reclength, ulong data_offset)
{
int error= 0;
Field::utype type;
......
......@@ -86,7 +86,7 @@
#define READ_ALL 1 /* openfrm: Read all parameters */
#define CHANGE_FRM 2 /* openfrm: open .frm as O_RDWR */
#define READ_KEYINFO 4 /* L{s nyckeldata fr}n filen */
#define EXTRA_RECORD 8 /* Reservera plats f|r extra record */
#define EXTRA_RECORD 8 /* Reserve space for an extra record */
#define DONT_OPEN_TABLES 8 /* Don't open database-files (frd) */
#define DONT_OPEN_MASTER_REG 16 /* Don't open first reg-file (prt) */
#define EXTRA_LONG_RECORD 16 /* Plats f|r dubbel s|k-record */
......
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