summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/multi_update.result19
-rw-r--r--mysql-test/t/multi_update.test32
-rw-r--r--sql/handler.cc4
-rw-r--r--sql/handler.h2
-rw-r--r--sql/sql_update.cc2
-rw-r--r--storage/myisammrg/ha_myisammrg.cc18
-rw-r--r--storage/myisammrg/ha_myisammrg.h1
7 files changed, 77 insertions, 1 deletions
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index 7386af13e2c..7172693d685 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -794,4 +794,23 @@ SELECT * FROM t2;
col_int_key pk_1 pk_2 col_int
1 7 11 4
DROP TABLE t1,t2;
+#
+# MDEV-6139: UPDATE w/ join against MRG_MyISAM table with read-only
+# sub-table fails
+#
+CREATE TABLE t1 (
+id int(10) unsigned,
+a int(11)
+) ENGINE=MyISAM;
+CREATE TABLE t3 (
+id int(10) unsigned,
+b int(11)
+) ENGINE=MyISAM;
+CREATE TABLE t2 (
+id int(10) unsigned,
+b int(11)
+) ENGINE=MRG_MyISAM UNION=(t3);
+FLUSH TABLES;
+update t1 join t2 using (id) set t1.a=t2.b;
+drop table t2, t3, t1;
end of 5.5 tests
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index e0a35ca2bb9..7acebfbed53 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -808,5 +808,37 @@ SELECT * FROM t2;
DROP TABLE t1,t2;
+--echo #
+--echo # MDEV-6139: UPDATE w/ join against MRG_MyISAM table with read-only
+--echo # sub-table fails
+--echo #
+
+CREATE TABLE t1 (
+ id int(10) unsigned,
+ a int(11)
+) ENGINE=MyISAM;
+
+CREATE TABLE t3 (
+ id int(10) unsigned,
+ b int(11)
+) ENGINE=MyISAM;
+
+CREATE TABLE t2 (
+ id int(10) unsigned,
+ b int(11)
+) ENGINE=MRG_MyISAM UNION=(t3);
+
+FLUSH TABLES;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+--disable_result_log
+--exec $MYISAMPACK -f $MYSQLD_DATADIR/test/t3
+--exec $MYISAMCHK -rq $MYSQLD_DATADIR/test/t3
+--enable_result_log
+
+update t1 join t2 using (id) set t1.a=t2.b;
+
+drop table t2, t3, t1;
+
--echo end of 5.5 tests
diff --git a/sql/handler.cc b/sql/handler.cc
index b67bb5e9f66..f08d4a37e1d 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5285,6 +5285,10 @@ void signal_log_not_needed(struct handlerton, char *log_file)
DBUG_VOID_RETURN;
}
+void handler::ha_set_lock_type(enum thr_lock_type lock)
+{
+ table->reginfo.lock_type= lock;
+}
#ifdef TRANS_LOG_MGM_EXAMPLE_CODE
/*
diff --git a/sql/handler.h b/sql/handler.h
index f557db64221..5f8b4cde4a7 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -2952,6 +2952,8 @@ public:
inline int ha_write_tmp_row(uchar *buf);
inline int ha_update_tmp_row(const uchar * old_data, uchar * new_data);
+ virtual void ha_set_lock_type(enum thr_lock_type lock);
+
friend enum icp_result handler_index_cond_check(void* h_arg);
};
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 0cedf50e4a2..190e2e9a84d 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -1304,7 +1304,7 @@ int mysql_multi_update_prepare(THD *thd)
tl->updating= 0;
/* Update TABLE::lock_type accordingly. */
if (!tl->placeholder() && !using_lock_tables)
- tl->table->reginfo.lock_type= tl->lock_type;
+ tl->table->file->ha_set_lock_type(tl->lock_type);
}
}
for (tl= table_list; tl; tl= tl->next_local)
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 1ee974c1b23..388c9c9895d 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -1713,6 +1713,24 @@ my_bool ha_myisammrg::register_query_cache_dependant_tables(THD *thd
DBUG_RETURN(FALSE);
}
+
+void ha_myisammrg::ha_set_lock_type(enum thr_lock_type lock)
+{
+ handler::ha_set_lock_type(lock);
+ if (children_l != NULL)
+ {
+ for (TABLE_LIST *child_table= children_l;;
+ child_table= child_table->next_global)
+ {
+ child_table->lock_type=
+ child_table->table->reginfo.lock_type= lock;
+
+ if (&child_table->next_global == children_last_l)
+ break;
+ }
+ }
+}
+
extern int myrg_panic(enum ha_panic_function flag);
int myisammrg_panic(handlerton *hton, ha_panic_function flag)
{
diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
index f5ba2ffef38..ce9c1917118 100644
--- a/storage/myisammrg/ha_myisammrg.h
+++ b/storage/myisammrg/ha_myisammrg.h
@@ -155,4 +155,5 @@ public:
Query_cache *cache,
Query_cache_block_table **block,
uint *n);
+ virtual void ha_set_lock_type(enum thr_lock_type lock);
};