[MDEV-6139] UPDATE w/ join against MRG_MyISAM table with read-only sub-table fails Created: 2014-04-20 Updated: 2014-04-28 Resolved: 2014-04-28 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.5.37 |
| Fix Version/s: | 5.5.38, 10.0.11 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Kolbe Kegel (Inactive) | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
An UPDATE statement that reads against (but does not modify) a MRG_MyISAM table with a read-only sub-table fails.
This works in MySQL 5.1, but fails in MySQL 5.5 and MariaDB 5.5. |
| Comments |
| Comment by Michael Widenius [ 2014-04-20 ] |
|
The problem here is that MySQL 5.5 did cause problems in how privileges are checked in multi-table-update. We are fixing this and several other multi-table-update problems as part of This should be fixed at the same time or after this task is done. |
| Comment by Oleksandr Byelkin [ 2014-04-22 ] |
|
The bug should be recent. old build of 5.5 on my laptop had not it. |
| Comment by Kolbe Kegel (Inactive) [ 2014-04-22 ] |
|
Sanja, thanks for doing that additional investigation! I tested in MySQL 5.5.20 and I was still able to reproduce the issue. |
| Comment by Oleksandr Byelkin [ 2014-04-22 ] |
|
Yes, the problem is I have no revision number of that tree... |
| Comment by Kolbe Kegel (Inactive) [ 2014-04-22 ] |
|
The server should have a version number when you build it though, no? |
| Comment by Oleksandr Byelkin [ 2014-04-22 ] |
|
yes and it is current, and my mistake was not to get last revision number before I made 'bzr pull'. |
| Comment by Oleksandr Byelkin [ 2014-04-22 ] |
|
CREATE TABLE `t1` ( CREATE TABLE `t2_0` ( CREATE TABLE `t2` ( FLUSH TABLES; let $MYSQLD_DATADIR= `select @@datadir`; update t1 join t2 using (id) set t1.a=t2.b; drop table t2, t2_0, t1; |
| Comment by Oleksandr Byelkin [ 2014-04-23 ] |
|
I did not found revision where it is working. Patch which fixes privileges check for multi-update do not fix this problem. |
| Comment by Oleksandr Byelkin [ 2014-04-23 ] |
|
CREATE TABLE t1 ( CREATE TABLE t3 ( CREATE TABLE t2 ( let $MYSQLD_DATADIR= `select @@datadir`; update t1 join t2 using (id) set t1.a=t2.b; drop table t2, t3, t1; |
| Comment by Oleksandr Byelkin [ 2014-04-23 ] |
|
only t1 write lock is incorrect: (gdb) p tables[0]->reginfo.lock_type (gdb) p tables[1]->reginfo.lock_type (gdb) p tables[2]->reginfo.lock_type |
| Comment by Oleksandr Byelkin [ 2014-04-23 ] |
|
on openning all tables get TL_WRITE lock mode |
| Comment by Oleksandr Byelkin [ 2014-04-23 ] |
|
The problem is that mysql_multi_update_prepare() iterate through all local tables and remove TL_WRITE lock for tables which are not in update fields, but it do not touch underlying merged tables... |
| Comment by Oleksandr Byelkin [ 2014-04-23 ] |
|
In 5.3 tables under MyISAM merged table are not visible it the table list (so they are not checked for locking type but inherit it from merged table), but in 5.5 they are separate tables. |
| Comment by Oleksandr Byelkin [ 2014-04-23 ] |
|
MySQL 5.6 also has this bug |
| Comment by Oleksandr Byelkin [ 2014-04-25 ] |
|
Here is minimal patch but: === modified file 'sql/handler.cc' +void handler::ha_set_lock_type(enum thr_lock_type lock) #ifdef TRANS_LOG_MGM_EXAMPLE_CODE === modified file 'sql/handler.h' + virtual void ha_set_lock_type(enum thr_lock_type lock); === modified file 'sql/sql_update.cc'
=== modified file 'storage/myisammrg/ha_myisammrg.cc' + + } ; |
| Comment by Oleksandr Byelkin [ 2014-04-25 ] |
|
Partitions are not affected. |
| Comment by Oleksandr Byelkin [ 2014-04-25 ] |
|
the fix sent for review |
| Comment by Kolbe Kegel (Inactive) [ 2014-04-28 ] |
|
Great work, thanks for the super quick turnaround! |