cleanups
This commit is contained in:
parent
5f69c8a594
commit
9594107fb8
@ -158,26 +158,35 @@ bool dd_check_storage_engine_flag(THD *thd,
|
|||||||
@param thd Thread context.
|
@param thd Thread context.
|
||||||
@param db Name of the database to which the table belongs to.
|
@param db Name of the database to which the table belongs to.
|
||||||
@param name Table name.
|
@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 FALSE Success.
|
||||||
@retval TRUE Error.
|
@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;
|
bool error= TRUE;
|
||||||
HA_CREATE_INFO create_info;
|
HA_CREATE_INFO create_info;
|
||||||
char path[FN_REFLEN + 1];
|
char path_buf[FN_REFLEN + 1];
|
||||||
DBUG_ENTER("dd_recreate_table");
|
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));
|
memset(&create_info, 0, sizeof(create_info));
|
||||||
|
|
||||||
/* Create a path to the table, but without a extension. */
|
if (path)
|
||||||
build_table_filename(path, sizeof(path) - 1, db, table_name, "", 0);
|
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. */
|
/* Attempt to reconstruct the table. */
|
||||||
error= ha_create_table(thd, path, db, table_name, &create_info);
|
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,
|
const char *db, const char *table_name,
|
||||||
uint32 flag,
|
uint32 flag,
|
||||||
bool *yes_no);
|
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
|
#endif // DATADICT_INCLUDED
|
||||||
|
@ -258,25 +258,16 @@ static bool recreate_temporary_table(THD *thd, TABLE *table)
|
|||||||
{
|
{
|
||||||
bool error= TRUE;
|
bool error= TRUE;
|
||||||
TABLE_SHARE *share= table->s;
|
TABLE_SHARE *share= table->s;
|
||||||
HA_CREATE_INFO create_info;
|
|
||||||
handlerton *table_type= table->s->db_type();
|
handlerton *table_type= table->s->db_type();
|
||||||
DBUG_ENTER("recreate_temporary_table");
|
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);
|
table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK);
|
||||||
|
|
||||||
/* Don't free share. */
|
/* Don't free share. */
|
||||||
close_temporary_table(thd, table, FALSE, FALSE);
|
close_temporary_table(thd, table, FALSE, FALSE);
|
||||||
|
|
||||||
/*
|
dd_recreate_table(thd, share->db.str, share->table_name.str,
|
||||||
We must use share->normalized_path.str since for temporary tables it
|
share->normalized_path.str);
|
||||||
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);
|
|
||||||
|
|
||||||
if (open_table_uncached(thd, share->path.str, share->db.str,
|
if (open_table_uncached(thd, share->path.str, share->db.str,
|
||||||
share->table_name.str, TRUE))
|
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 uint get_interval_id(uint *,List<Create_field> &, Create_field *);
|
||||||
static bool pack_fields(File file, List<Create_field> &create_fields,
|
static bool pack_fields(File file, List<Create_field> &create_fields,
|
||||||
ulong data_offset);
|
ulong data_offset);
|
||||||
static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type,
|
static bool make_empty_rec(THD *thd, int file, uint table_options,
|
||||||
uint table_options,
|
|
||||||
List<Create_field> &create_fields,
|
List<Create_field> &create_fields,
|
||||||
uint reclength, ulong data_offset,
|
uint reclength, ulong data_offset);
|
||||||
handler *handler);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
An interceptor to hijack ER_TOO_MANY_FIELDS error from
|
An interceptor to hijack ER_TOO_MANY_FIELDS error from
|
||||||
@ -102,8 +100,8 @@ handle_condition(THD *,
|
|||||||
create_fields Fields to create
|
create_fields Fields to create
|
||||||
keys number of keys to create
|
keys number of keys to create
|
||||||
key_info Keys to create
|
key_info Keys to create
|
||||||
db_file Handler to use. May be zero, in which case we use
|
db_file Handler to use.
|
||||||
create_info->db_type
|
|
||||||
RETURN
|
RETURN
|
||||||
false ok
|
false ok
|
||||||
true error
|
true error
|
||||||
@ -317,9 +315,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
|
|||||||
mysql_file_seek(file,
|
mysql_file_seek(file,
|
||||||
(ulong) uint2korr(fileinfo+6) + (ulong) key_buff_length,
|
(ulong) uint2korr(fileinfo+6) + (ulong) key_buff_length,
|
||||||
MY_SEEK_SET, MYF(0));
|
MY_SEEK_SET, MYF(0));
|
||||||
if (make_empty_rec(thd,file,ha_legacy_type(create_info->db_type),
|
if (make_empty_rec(thd, file, create_info->table_options,
|
||||||
create_info->table_options,
|
create_fields, reclength, data_offset))
|
||||||
create_fields,reclength, data_offset, db_file))
|
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
int2store(buff, create_info->connect_string.length);
|
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 */
|
/* save an empty record on start of formfile */
|
||||||
|
|
||||||
static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
|
static bool make_empty_rec(THD *thd, File file, uint table_options,
|
||||||
uint table_options,
|
|
||||||
List<Create_field> &create_fields,
|
List<Create_field> &create_fields,
|
||||||
uint reclength,
|
uint reclength, ulong data_offset)
|
||||||
ulong data_offset,
|
|
||||||
handler *handler)
|
|
||||||
{
|
{
|
||||||
int error= 0;
|
int error= 0;
|
||||||
Field::utype type;
|
Field::utype type;
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
#define READ_ALL 1 /* openfrm: Read all parameters */
|
#define READ_ALL 1 /* openfrm: Read all parameters */
|
||||||
#define CHANGE_FRM 2 /* openfrm: open .frm as O_RDWR */
|
#define CHANGE_FRM 2 /* openfrm: open .frm as O_RDWR */
|
||||||
#define READ_KEYINFO 4 /* L{s nyckeldata fr}n filen */
|
#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_TABLES 8 /* Don't open database-files (frd) */
|
||||||
#define DONT_OPEN_MASTER_REG 16 /* Don't open first reg-file (prt) */
|
#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 */
|
#define EXTRA_LONG_RECORD 16 /* Plats f|r dubbel s|k-record */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user