summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-07-11 18:57:11 +0200
committerSergei Golubchik <sergii@pisem.net>2013-07-11 18:57:11 +0200
commit7f5d138afd1ad9c261bd9e9d58dae829a98ff8fe (patch)
tree6c6fea96aee76be935e963919b108bfb8484db68
parentb7e77be5445e740746851e3a7c5193ac89009fd4 (diff)
downloadmariadb-git-7f5d138afd1ad9c261bd9e9d58dae829a98ff8fe.tar.gz
fix merge.test: online alter table support for MERGE tables, really
-rw-r--r--include/myisammrg.h3
-rw-r--r--storage/myisammrg/ha_myisammrg.cc49
-rw-r--r--storage/myisammrg/ha_myisammrg.h3
-rw-r--r--storage/myisammrg/myrg_create.c4
4 files changed, 45 insertions, 14 deletions
diff --git a/include/myisammrg.h b/include/myisammrg.h
index 84b2d637892..89293537989 100644
--- a/include/myisammrg.h
+++ b/include/myisammrg.h
@@ -31,7 +31,8 @@ extern "C" {
#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 */
#define MERGE_INSERT_DISABLED 0
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index a0158c9615c..156d071e230 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -135,7 +135,7 @@ ha_myisammrg::~ha_myisammrg(void)
static const char *ha_myisammrg_exts[] = {
- ".MRG",
+ MYRG_NAME_EXT,
NullS
};
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,
- HA_CREATE_INFO *create_info)
+int ha_myisammrg::create_mrg(const char *name, HA_CREATE_INFO *create_info)
{
char buff[FN_REFLEN];
const char **table_names, **pos;
TABLE_LIST *tables= create_info->merge_list.first;
THD *thd= current_thd;
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. */
if (!(table_names= (const char**)
@@ -1560,12 +1559,19 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
*pos=0;
/* Create a MERGE meta file from the table_names array. */
- DBUG_RETURN(myrg_create(fn_format(buff,name,"","",
- MY_RESOLVE_SYMLINKS|
- MY_UNPACK_FILENAME|MY_APPEND_EXT),
- table_names,
- create_info->merge_insert_method,
- (my_bool) 0));
+ int res= myrg_create(name, table_names, create_info->merge_insert_method, 0);
+ DBUG_RETURN(res);
+}
+
+
+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)
{
return this->file->children_attached ? HA_ADMIN_OK : HA_ADMIN_CORRUPT;
diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
index 68c2023c2a5..48cd3335833 100644
--- a/storage/myisammrg/ha_myisammrg.h
+++ b/storage/myisammrg/ha_myisammrg.h
@@ -138,6 +138,7 @@ public:
int extra_opt(enum ha_extra_function operation, ulong cache_size);
int external_lock(THD *thd, int lock_type);
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);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type);
@@ -147,6 +148,8 @@ public:
TABLE *table_ptr() { return table; }
enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *,
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);
ha_rows records();
virtual uint count_query_cache_dependant_tables(uint8 *tables_type);
diff --git a/storage/myisammrg/myrg_create.c b/storage/myisammrg/myrg_create.c
index 53c104b4c4a..715a5bcbd32 100644
--- a/storage/myisammrg/myrg_create.c
+++ b/storage/myisammrg/myrg_create.c
@@ -33,9 +33,7 @@ int myrg_create(const char *name, const char **table_names,
DBUG_ENTER("myrg_create");
errpos=0;
- if ((file= mysql_file_create(rg_key_file_MRG,
- fn_format(buff, name, "", MYRG_NAME_EXT,
- MY_UNPACK_FILENAME|MY_APPEND_EXT), 0,
+ if ((file= mysql_file_create(rg_key_file_MRG, name, 0,
O_RDWR | O_EXCL | O_NOFOLLOW, MYF(MY_WME))) < 0)
goto err;
errpos=1;