diff options
Diffstat (limited to 'storage/myisammrg')
-rw-r--r-- | storage/myisammrg/Makefile.am | 62 | ||||
-rw-r--r-- | storage/myisammrg/ha_myisammrg.cc | 47 | ||||
-rw-r--r-- | storage/myisammrg/ha_myisammrg.h | 3 | ||||
-rw-r--r-- | storage/myisammrg/myrg_def.h | 2 | ||||
-rw-r--r-- | storage/myisammrg/myrg_open.c | 8 | ||||
-rw-r--r-- | storage/myisammrg/plug.in | 6 |
6 files changed, 50 insertions, 78 deletions
diff --git a/storage/myisammrg/Makefile.am b/storage/myisammrg/Makefile.am deleted file mode 100644 index 43dec3ae3d9..00000000000 --- a/storage/myisammrg/Makefile.am +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2000-2002, 2005-2006 MySQL AB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -MYSQLDATAdir = $(localstatedir) -MYSQLSHAREdir = $(pkgdatadir) -MYSQLBASEdir= $(prefix) -MYSQLLIBdir= $(pkglibdir) -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \ - -I$(top_srcdir)/regex \ - -I$(top_srcdir)/sql \ - -I$(srcdir) -WRAPLIBS= - -LDADD = - -DEFS = @DEFS@ -pkglib_LIBRARIES = libmyisammrg.a -noinst_HEADERS = myrg_def.h ha_myisammrg.h -noinst_LIBRARIES = libmyisammrg.a -libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \ - myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \ - myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \ - myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \ - myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \ - ha_myisammrg.cc \ - myrg_rnext_same.c myrg_records.c - - -EXTRA_DIST = CMakeLists.txt plug.in - -if HAVE_DTRACE_DASH_G -libmyisammrg_a_LIBADD = probes_mysql.o -libmyisammrg_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers -CLEANFILES = probes_mysql.o dtrace_files dtrace_providers -DTRACEFILES = ha_myisammrg.o -DTRACEPROVIDER = probes_mysql.d -CLEANFILES += $(DTRACEPROVIDER) dtrace_sources - -dtrace_files: - echo $(DTRACEFILES) > $@ -dtrace_providers: probes_mysql.d - echo $(DTRACEPROVIDER) > $@ -probes_mysql.d: - -$(RM) -f probes_mysql.d - $(CP) $(top_srcdir)/include/probes_mysql.d.base probes_mysql.d - echo timestamp > dtrace_sources - -probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES) - $(DTRACE) $(DTRACEFLAGS) -G -s $(DTRACEPROVIDER) $(DTRACEFILES) -o $@ -endif diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index ef7cd5712e8..22b4794dbde 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -480,6 +480,31 @@ int ha_myisammrg::add_children_list(void) /* Set the expected table version, to not cause spurious re-prepare. */ child_l->set_table_ref_id(mrg_child_def->get_child_table_ref_type(), mrg_child_def->get_child_def_version()); + /* + 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. + + Otherwise we end up in a situation where the thread trying to upgrade SNW + to X lock on the parent also holds a SR metadata lock and a read + thr_lock.c lock on the child. As a result, another thread might be + blocked on the thr_lock.c lock for the child after successfully acquiring + a SR or SW metadata lock on it. If at the same time this second thread + has a shared metadata lock on the parent table or there is some other + thread which has a shared metadata lock on the parent and is waiting for + this second thread, we get a deadlock. This deadlock cannot be properly + detected by the MDL subsystem as part of the waiting happens within + thr_lock.c. By taking SNW locks on the child tables we ensure that any + thread which waits for a thread doing SNW -> X upgrade, does this within + the MDL subsystem and thus potential deadlocks are exposed to the deadlock + detector. + + We don't do the same thing for SNRW locks as this would allow + DDL on implicitly locked underlying tables of a MERGE table. + */ + if (! thd->locked_tables_mode && + parent_l->mdl_request.type == MDL_SHARED_NO_WRITE) + child_l->mdl_request.set_type(MDL_SHARED_NO_WRITE); /* Link TABLE_LIST object into the children list. */ if (this->children_last_l) child_l->prev_global= this->children_last_l; @@ -657,7 +682,7 @@ CPP_UNNAMED_NS_END @return A cloned handler instance. */ -handler *ha_myisammrg::clone(MEM_ROOT *mem_root) +handler *ha_myisammrg::clone(const char *name, MEM_ROOT *mem_root) { MYRG_TABLE *u_table,*newu_table; ha_myisammrg *new_handler= @@ -678,8 +703,8 @@ handler *ha_myisammrg::clone(MEM_ROOT *mem_root) return NULL; } - if (new_handler->ha_open(table, table->s->normalized_path.str, table->db_stat, - HA_OPEN_IGNORE_IF_LOCKED)) + if (new_handler->ha_open(table, name, table->db_stat, + HA_OPEN_IGNORE_IF_LOCKED)) { delete new_handler; return NULL; @@ -1202,6 +1227,22 @@ ha_rows ha_myisammrg::records_in_range(uint inx, key_range *min_key, } +int ha_myisammrg::truncate() +{ + int err= 0; + MYRG_TABLE *table; + DBUG_ENTER("ha_myisammrg::truncate"); + + for (table= file->open_tables; table != file->end_table; table++) + { + if ((err= mi_delete_all_rows(table->table))) + break; + } + + DBUG_RETURN(err); +} + + int ha_myisammrg::info(uint flag) { MYMERGE_INFO mrg_info; diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h index c434dc28426..14734eed064 100644 --- a/storage/myisammrg/ha_myisammrg.h +++ b/storage/myisammrg/ha_myisammrg.h @@ -110,7 +110,7 @@ public: int add_children_list(void); int attach_children(void); int detach_children(void); - virtual handler *clone(MEM_ROOT *mem_root); + virtual handler *clone(const char *name, MEM_ROOT *mem_root); int close(void); int write_row(uchar * buf); int update_row(const uchar * old_data, uchar * new_data); @@ -131,6 +131,7 @@ public: int rnd_pos(uchar * buf, uchar *pos); void position(const uchar *record); ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); + int truncate(); int info(uint); int reset(void); int extra(enum ha_extra_function operation); diff --git a/storage/myisammrg/myrg_def.h b/storage/myisammrg/myrg_def.h index b916243be21..9bc0881b212 100644 --- a/storage/myisammrg/myrg_def.h +++ b/storage/myisammrg/myrg_def.h @@ -23,9 +23,7 @@ extern LIST *myrg_open_list; -#ifdef THREAD extern mysql_mutex_t THR_LOCK_open; -#endif int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag); int _myrg_mi_read_record(MI_INFO *info, uchar *buf); diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index 156660d00c0..ab1d9ad7f7e 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -78,7 +78,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) { if (!strncmp(buff+1,"INSERT_METHOD=",14)) { /* Lookup insert method */ - int tmp=find_type(buff+15,&merge_insert_method,2); + int tmp= find_type(buff + 15, &merge_insert_method, FIND_TYPE_BASIC); found_merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); } continue; /* Skip comments */ @@ -222,7 +222,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, int (*callback)(void*, const char*), void *callback_param) { - MYRG_INFO *m_info; + MYRG_INFO *UNINIT_VAR(m_info); int rc; int errpos; int save_errno; @@ -274,7 +274,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, { /* Compare buffer with global methods list: merge_insert_method. */ insert_method= find_type(child_name_buff + 15, - &merge_insert_method, 2); + &merge_insert_method, FIND_TYPE_BASIC); } continue; } diff --git a/storage/myisammrg/plug.in b/storage/myisammrg/plug.in deleted file mode 100644 index 1f94e07d881..00000000000 --- a/storage/myisammrg/plug.in +++ /dev/null @@ -1,6 +0,0 @@ -MYSQL_STORAGE_ENGINE(myisammrg,no,[MyISAM MERGE Engine], - [Merge multiple MySQL tables into one]) -MYSQL_PLUGIN_DIRECTORY(myisammrg,[storage/myisammrg]) -MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg.a]) -MYSQL_PLUGIN_MANDATORY(myisammrg) -MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisammrg, [ha_myisammrg.cc]) |