summaryrefslogtreecommitdiff
path: root/mysql-test/t/myisam.test
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@sun.com>2010-02-12 15:28:38 +0400
committerSergey Vojtovich <svoj@sun.com>2010-02-12 15:28:38 +0400
commit9d0c1ce535b57d97cb41dfca47aa33608c38b62d (patch)
tree7f70dbfafef89d0ed14ff52646172f49202224fc /mysql-test/t/myisam.test
parent44c1a79b0e6af3f87712af7e7386aa6c516b89f9 (diff)
downloadmariadb-git-9d0c1ce535b57d97cb41dfca47aa33608c38b62d.tar.gz
BUG#48438 - crash with error in unioned query against merge
table and view... Invalid memory reads after a query referencing MyISAM table multiple times with write lock. Invalid memory reads may lead to server crash, valgrind warnings, incorrect values in INFORMATION_SCHEMA.TABLES.{TABLE_ROWS, DATA_LENGTH, INDEX_LENGTH, ...}. This may happen when one of the table instances gets closed after a query, e.g. out of slots in open tables cache. UNION, MERGE and VIEW are irrelevant. The problem was that MyISAM didn't restore state info pointer to default value. myisam/mi_locking.c: When a query is referencing MyISAM table multiple times with a write lock, all table instances share the same state info, pointing to MI_INFO::save_state of "primary" table instance. When lock is released, state pointer was restored only for the primary table instance. Secondary table instances are still pointing to save_state of primary table instance. Primary table instance may get closed, leaving secondary table instances state pointer pointing to freed memory. That's mostly ok, since next lock will update state info pointer to correct value. But there're some cases, when this secondary table instance state info is accessed without a lock, e.g. INFORMATION_SCHEMA, MERGE (in 5.1 and up), MyISAM itself for DBUG purposes. Restore default value of state pointer unconditionally, for both primary and secondary table instances. mysql-test/r/myisam.result: A test case for BUG#48438. mysql-test/t/myisam.test: A test case for BUG#48438.
Diffstat (limited to 'mysql-test/t/myisam.test')
-rw-r--r--mysql-test/t/myisam.test11
1 files changed, 11 insertions, 0 deletions
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index d0a480348a3..936c47a6d08 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -1239,4 +1239,15 @@ CHECKSUM TABLE t1 EXTENDED;
DROP TABLE t1;
+--echo #
+--echo # BUG#48438 - crash with error in unioned query against merge table and view...
+--echo #
+SET GLOBAL table_cache=3;
+CREATE TABLE t1(a INT);
+SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4 FOR UPDATE;
+SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES
+ WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
+DROP TABLE t1;
+SET GLOBAL table_cache=DEFAULT;
+
--echo End of 5.0 tests