fix merge.test: online alter table support for MERGE tables, really
This commit is contained in:
parent
b7e77be544
commit
7f5d138afd
@ -32,6 +32,7 @@ extern "C" {
|
|||||||
#include <queues.h>
|
#include <queues.h>
|
||||||
|
|
||||||
#define MYRG_NAME_EXT ".MRG"
|
#define MYRG_NAME_EXT ".MRG"
|
||||||
|
#define MYRG_NAME_TMPEXT ".MRG_TMP"
|
||||||
|
|
||||||
/* In which table to INSERT rows */
|
/* In which table to INSERT rows */
|
||||||
#define MERGE_INSERT_DISABLED 0
|
#define MERGE_INSERT_DISABLED 0
|
||||||
|
@ -135,7 +135,7 @@ ha_myisammrg::~ha_myisammrg(void)
|
|||||||
|
|
||||||
|
|
||||||
static const char *ha_myisammrg_exts[] = {
|
static const char *ha_myisammrg_exts[] = {
|
||||||
".MRG",
|
MYRG_NAME_EXT,
|
||||||
NullS
|
NullS
|
||||||
};
|
};
|
||||||
extern int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
|
extern int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
|
||||||
@ -1504,15 +1504,14 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ha_myisammrg::create(const char *name, register TABLE *form,
|
int ha_myisammrg::create_mrg(const char *name, HA_CREATE_INFO *create_info)
|
||||||
HA_CREATE_INFO *create_info)
|
|
||||||
{
|
{
|
||||||
char buff[FN_REFLEN];
|
char buff[FN_REFLEN];
|
||||||
const char **table_names, **pos;
|
const char **table_names, **pos;
|
||||||
TABLE_LIST *tables= create_info->merge_list.first;
|
TABLE_LIST *tables= create_info->merge_list.first;
|
||||||
THD *thd= current_thd;
|
THD *thd= current_thd;
|
||||||
size_t dirlgt= dirname_length(name);
|
size_t dirlgt= dirname_length(name);
|
||||||
DBUG_ENTER("ha_myisammrg::create");
|
DBUG_ENTER("ha_myisammrg::create_mrg");
|
||||||
|
|
||||||
/* Allocate a table_names array in thread mem_root. */
|
/* Allocate a table_names array in thread mem_root. */
|
||||||
if (!(table_names= (const char**)
|
if (!(table_names= (const char**)
|
||||||
@ -1560,12 +1559,19 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
|
|||||||
*pos=0;
|
*pos=0;
|
||||||
|
|
||||||
/* Create a MERGE meta file from the table_names array. */
|
/* Create a MERGE meta file from the table_names array. */
|
||||||
DBUG_RETURN(myrg_create(fn_format(buff,name,"","",
|
int res= myrg_create(name, table_names, create_info->merge_insert_method, 0);
|
||||||
MY_RESOLVE_SYMLINKS|
|
DBUG_RETURN(res);
|
||||||
MY_UNPACK_FILENAME|MY_APPEND_EXT),
|
}
|
||||||
table_names,
|
|
||||||
create_info->merge_insert_method,
|
|
||||||
(my_bool) 0));
|
int ha_myisammrg::create(const char *name, register TABLE *form,
|
||||||
|
HA_CREATE_INFO *create_info)
|
||||||
|
{
|
||||||
|
char buff[FN_REFLEN];
|
||||||
|
DBUG_ENTER("ha_myisammrg::create");
|
||||||
|
fn_format(buff, name, "", MYRG_NAME_EXT, MY_UNPACK_FILENAME | MY_APPEND_EXT);
|
||||||
|
int res= create_mrg(buff, create_info);
|
||||||
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1628,6 +1634,29 @@ ha_myisammrg::check_if_supported_inplace_alter(TABLE *altered_table,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ha_myisammrg::inplace_alter_table(TABLE *altered_table,
|
||||||
|
Alter_inplace_info *ha_alter_info)
|
||||||
|
{
|
||||||
|
char tmp_path[FN_REFLEN];
|
||||||
|
char *name= table->s->normalized_path.str;
|
||||||
|
DBUG_ENTER("ha_myisammrg::inplace_alter_table");
|
||||||
|
fn_format(tmp_path, name, "", MYRG_NAME_TMPEXT, MY_UNPACK_FILENAME | MY_APPEND_EXT);
|
||||||
|
int res= create_mrg(tmp_path, ha_alter_info->create_info);
|
||||||
|
if (res)
|
||||||
|
mysql_file_delete(rg_key_file_MRG, tmp_path, MYF(0));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char path[FN_REFLEN];
|
||||||
|
fn_format(path, name, "", MYRG_NAME_EXT, MY_UNPACK_FILENAME | MY_APPEND_EXT);
|
||||||
|
if (mysql_file_rename(rg_key_file_MRG, tmp_path, path, MYF(0)))
|
||||||
|
{
|
||||||
|
res= my_errno;
|
||||||
|
mysql_file_delete(rg_key_file_MRG, tmp_path, MYF(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBUG_RETURN(res);
|
||||||
|
}
|
||||||
|
|
||||||
int ha_myisammrg::check(THD* thd, HA_CHECK_OPT* check_opt)
|
int ha_myisammrg::check(THD* thd, HA_CHECK_OPT* check_opt)
|
||||||
{
|
{
|
||||||
return this->file->children_attached ? HA_ADMIN_OK : HA_ADMIN_CORRUPT;
|
return this->file->children_attached ? HA_ADMIN_OK : HA_ADMIN_CORRUPT;
|
||||||
|
@ -138,6 +138,7 @@ public:
|
|||||||
int extra_opt(enum ha_extra_function operation, ulong cache_size);
|
int extra_opt(enum ha_extra_function operation, ulong cache_size);
|
||||||
int external_lock(THD *thd, int lock_type);
|
int external_lock(THD *thd, int lock_type);
|
||||||
uint lock_count(void) const;
|
uint lock_count(void) const;
|
||||||
|
int create_mrg(const char *name, HA_CREATE_INFO *create_info);
|
||||||
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
|
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
|
||||||
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
|
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
|
||||||
enum thr_lock_type lock_type);
|
enum thr_lock_type lock_type);
|
||||||
@ -147,6 +148,8 @@ public:
|
|||||||
TABLE *table_ptr() { return table; }
|
TABLE *table_ptr() { return table; }
|
||||||
enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *,
|
enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *,
|
||||||
Alter_inplace_info *);
|
Alter_inplace_info *);
|
||||||
|
bool inplace_alter_table(TABLE *altered_table,
|
||||||
|
Alter_inplace_info *ha_alter_info);
|
||||||
int check(THD* thd, HA_CHECK_OPT* check_opt);
|
int check(THD* thd, HA_CHECK_OPT* check_opt);
|
||||||
ha_rows records();
|
ha_rows records();
|
||||||
virtual uint count_query_cache_dependant_tables(uint8 *tables_type);
|
virtual uint count_query_cache_dependant_tables(uint8 *tables_type);
|
||||||
|
@ -33,9 +33,7 @@ int myrg_create(const char *name, const char **table_names,
|
|||||||
DBUG_ENTER("myrg_create");
|
DBUG_ENTER("myrg_create");
|
||||||
|
|
||||||
errpos=0;
|
errpos=0;
|
||||||
if ((file= mysql_file_create(rg_key_file_MRG,
|
if ((file= mysql_file_create(rg_key_file_MRG, name, 0,
|
||||||
fn_format(buff, name, "", MYRG_NAME_EXT,
|
|
||||||
MY_UNPACK_FILENAME|MY_APPEND_EXT), 0,
|
|
||||||
O_RDWR | O_EXCL | O_NOFOLLOW, MYF(MY_WME))) < 0)
|
O_RDWR | O_EXCL | O_NOFOLLOW, MYF(MY_WME))) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
errpos=1;
|
errpos=1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user