[Commits] Rev 4163: MDEV-6139: UPDATE w/ join against MRG_MyISAM table with read-only sub-table failsUPDATE w/ join against MRG_MyISAM table with read-only sub-table fails in file:///home/bell/maria/bzr/work-maria-5.5-MDEV-6139/

sanja at askmonty.org sanja at askmonty.org
Fri Apr 25 21:44:09 EEST 2014


At file:///home/bell/maria/bzr/work-maria-5.5-MDEV-6139/

------------------------------------------------------------
revno: 4163
revision-id: sanja at askmonty.org-20140425184344-rvzw2yonsa07ef49
parent: monty at askmonty.org-20140424152057-d7kc187y5xou1g5s
committer: sanja at askmonty.org
branch nick: work-maria-5.5-MDEV-6139
timestamp: Fri 2014-04-25 21:43:44 +0300
message:
  MDEV-6139: UPDATE w/ join against MRG_MyISAM table with read-only sub-table failsUPDATE w/ join against MRG_MyISAM table with read-only sub-table fails
  
  The problem was that on opening all tables TL_WRITE, than local tables which is not updated set to TL_READ, but underlying tables of MyISAMmrg left untouched.
  
  Prartition engine has not this problem.
  
  All cases where lock_type assigned is not changed because call of virtual function is not cheap.
-------------- next part --------------
=== modified file 'mysql-test/r/multi_update.result'
--- a/mysql-test/r/multi_update.result	2013-02-28 21:47:29 +0000
+++ b/mysql-test/r/multi_update.result	2014-04-25 18:43:44 +0000
@@ -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

=== modified file 'mysql-test/t/multi_update.test'
--- a/mysql-test/t/multi_update.test	2013-02-28 21:47:29 +0000
+++ b/mysql-test/t/multi_update.test	2014-04-25 18:43:44 +0000
@@ -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
 

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2014-04-11 08:46:11 +0000
+++ b/sql/handler.cc	2014-04-25 18:43:44 +0000
@@ -5285,6 +5285,10 @@ void signal_log_not_needed(struct handle
   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
 /*

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2014-04-11 08:46:11 +0000
+++ b/sql/handler.h	2014-04-25 18:43:44 +0000
@@ -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);
 };
 

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2014-03-17 12:04:28 +0000
+++ b/sql/sql_update.cc	2014-04-25 18:43:44 +0000
@@ -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)

=== modified file 'storage/myisammrg/ha_myisammrg.cc'
--- a/storage/myisammrg/ha_myisammrg.cc	2013-12-13 12:00:38 +0000
+++ b/storage/myisammrg/ha_myisammrg.cc	2014-04-25 18:43:44 +0000
@@ -1713,6 +1713,24 @@ my_bool ha_myisammrg::register_query_cac
   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)
 {

=== modified file 'storage/myisammrg/ha_myisammrg.h'
--- a/storage/myisammrg/ha_myisammrg.h	2012-07-13 19:17:32 +0000
+++ b/storage/myisammrg/ha_myisammrg.h	2014-04-25 18:43:44 +0000
@@ -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);
 };



More information about the commits mailing list