summaryrefslogtreecommitdiff
path: root/storage/myisammrg
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-07-21 16:39:19 +0200
committerSergei Golubchik <sergii@pisem.net>2013-07-21 16:39:19 +0200
commitb7b5f6f1ab49948b0e15b762266d4640b3d6b7fb (patch)
tree7c302c2025184dbd053aa6135f0ff28c8ce6f359 /storage/myisammrg
parent5f6380adde2dac3f32b40339b9b702c0135eb7d6 (diff)
parentc1d6a2d7e194225ccc19a68ea5d0f368632620d0 (diff)
downloadmariadb-git-b7b5f6f1ab49948b0e15b762266d4640b3d6b7fb.tar.gz
10.0-monty merge
includes: * remove some remnants of "Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING" * introduce LOCK_share, now LOCK_ha_data is strictly for engines * rea_create_table() always creates .par file (even in "frm-only" mode) * fix a 5.6 bug, temp file leak on dummy ALTER TABLE
Diffstat (limited to 'storage/myisammrg')
-rw-r--r--storage/myisammrg/ha_myisammrg.cc73
-rw-r--r--storage/myisammrg/ha_myisammrg.h6
-rw-r--r--storage/myisammrg/myrg_create.c4
-rw-r--r--storage/myisammrg/myrg_def.h5
4 files changed, 61 insertions, 27 deletions
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 69f84a9805a..bb225002dc0 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,
@@ -493,6 +493,11 @@ int ha_myisammrg::add_children_list(void)
child_l->set_table_ref_id(mrg_child_def->get_child_table_ref_type(),
mrg_child_def->get_child_def_version());
/*
+ Copy parent's prelocking attribute to allow opening of child
+ temporary residing in the prelocking list.
+ */
+ child_l->prelocking_placeholder= parent_l->prelocking_placeholder;
+ /*
For statements which acquire a SNW metadata lock on a parent table and
then later try to upgrade it to an X lock (e.g. ALTER TABLE), SNW
locks should be also taken on the children tables.
@@ -515,7 +520,7 @@ int ha_myisammrg::add_children_list(void)
DDL on implicitly locked underlying tables of a MERGE table.
*/
if (! thd->locked_tables_mode &&
- parent_l->mdl_request.type == MDL_SHARED_NO_WRITE)
+ parent_l->mdl_request.type == MDL_SHARED_UPGRADABLE)
child_l->mdl_request.set_type(MDL_SHARED_NO_WRITE);
/* Link TABLE_LIST object into the children list. */
if (this->children_last_l)
@@ -1312,7 +1317,7 @@ int ha_myisammrg::info(uint flag)
memcpy((char*) table->key_info[0].rec_per_key,
(char*) mrg_info.rec_per_key,
sizeof(table->key_info[0].rec_per_key[0]) *
- min(file->keys, table->s->key_parts));
+ MY_MIN(file->keys, table->s->key_parts));
}
}
if (flag & HA_STATUS_ERRKEY)
@@ -1375,8 +1380,6 @@ int ha_myisammrg::reset(void)
int ha_myisammrg::extra_opt(enum ha_extra_function operation, ulong cache_size)
{
DBUG_ASSERT(this->file->children_attached);
- if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_WRITE_CACHE)
- return 0;
return myrg_extra(file, operation, (void*) &cache_size);
}
@@ -1509,15 +1512,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**)
@@ -1565,12 +1567,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);
}
@@ -1621,17 +1630,41 @@ void ha_myisammrg::append_create_info(String *packet)
}
-bool ha_myisammrg::check_if_incompatible_data(HA_CREATE_INFO *info,
- uint table_changes)
+enum_alter_inplace_result
+ha_myisammrg::check_if_supported_inplace_alter(TABLE *altered_table,
+ Alter_inplace_info *ha_alter_info)
{
/*
- For myisammrg, we should always re-generate the mapping file as this
- is trivial to do
+ We always support inplace ALTER in the new API, because old
+ HA_NO_COPY_ON_ALTER table_flags() hack prevents non-inplace ALTER anyway.
*/
- return COMPATIBLE_DATA_NO;
+ return HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
+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;
@@ -1677,7 +1710,7 @@ my_bool ha_myisammrg::register_query_cache_dependant_tables(THD *thd
There are not callback function for for MyISAM, and engine data
*/
if (!cache->insert_table(key_length, key, (*block_table),
- db_length,
+ db_length, 0,
table_cache_type(),
0, 0, TRUE))
DBUG_RETURN(TRUE);
diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
index 455819c5526..6b4301616d9 100644
--- a/storage/myisammrg/ha_myisammrg.h
+++ b/storage/myisammrg/ha_myisammrg.h
@@ -137,6 +137,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);
@@ -144,7 +145,10 @@ public:
void append_create_info(String *packet);
MYRG_INFO *myrg_info() { return file; }
TABLE *table_ptr() { return table; }
- bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
+ 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;
diff --git a/storage/myisammrg/myrg_def.h b/storage/myisammrg/myrg_def.h
index e6fa869ff9b..cf60390b22e 100644
--- a/storage/myisammrg/myrg_def.h
+++ b/storage/myisammrg/myrg_def.h
@@ -33,11 +33,10 @@ extern "C"
void myrg_print_wrong_table(const char *table_name);
#ifdef HAVE_PSI_INTERFACE
-extern PSI_mutex_key rg_key_mutex_MYRG_INFO_mutex;
-
-extern PSI_file_key rg_key_file_MRG;
C_MODE_START
+extern PSI_mutex_key rg_key_mutex_MYRG_INFO_mutex;
+extern PSI_file_key rg_key_file_MRG;
void init_myisammrg_psi_keys();
C_MODE_END
#endif /* HAVE_PSI_INTERFACE */