Commit 968f4d4e authored by unknown's avatar unknown

MDEV-6139: UPDATE w/ join against MRG_MyISAM table with read-only sub-table...

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.
parent 772aa0c5
...@@ -794,4 +794,23 @@ SELECT * FROM t2; ...@@ -794,4 +794,23 @@ SELECT * FROM t2;
col_int_key pk_1 pk_2 col_int col_int_key pk_1 pk_2 col_int
1 7 11 4 1 7 11 4
DROP TABLE t1,t2; 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 end of 5.5 tests
...@@ -808,5 +808,37 @@ SELECT * FROM t2; ...@@ -808,5 +808,37 @@ SELECT * FROM t2;
DROP TABLE t1,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 --echo end of 5.5 tests
...@@ -5285,6 +5285,10 @@ void signal_log_not_needed(struct handlerton, char *log_file) ...@@ -5285,6 +5285,10 @@ void signal_log_not_needed(struct handlerton, char *log_file)
DBUG_VOID_RETURN; 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 #ifdef TRANS_LOG_MGM_EXAMPLE_CODE
/* /*
......
...@@ -2952,6 +2952,8 @@ public: ...@@ -2952,6 +2952,8 @@ public:
inline int ha_write_tmp_row(uchar *buf); inline int ha_write_tmp_row(uchar *buf);
inline int ha_update_tmp_row(const uchar * old_data, uchar * new_data); 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); friend enum icp_result handler_index_cond_check(void* h_arg);
}; };
......
...@@ -1304,7 +1304,7 @@ int mysql_multi_update_prepare(THD *thd) ...@@ -1304,7 +1304,7 @@ int mysql_multi_update_prepare(THD *thd)
tl->updating= 0; tl->updating= 0;
/* Update TABLE::lock_type accordingly. */ /* Update TABLE::lock_type accordingly. */
if (!tl->placeholder() && !using_lock_tables) 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) for (tl= table_list; tl; tl= tl->next_local)
......
...@@ -1713,6 +1713,24 @@ my_bool ha_myisammrg::register_query_cache_dependant_tables(THD *thd ...@@ -1713,6 +1713,24 @@ my_bool ha_myisammrg::register_query_cache_dependant_tables(THD *thd
DBUG_RETURN(FALSE); 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); extern int myrg_panic(enum ha_panic_function flag);
int myisammrg_panic(handlerton *hton, ha_panic_function flag) int myisammrg_panic(handlerton *hton, ha_panic_function flag)
{ {
......
...@@ -155,4 +155,5 @@ public: ...@@ -155,4 +155,5 @@ public:
Query_cache *cache, Query_cache *cache,
Query_cache_block_table **block, Query_cache_block_table **block,
uint *n); uint *n);
virtual void ha_set_lock_type(enum thr_lock_type lock);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment