summaryrefslogtreecommitdiff
path: root/mysql-test/t/innodb_mysql.test
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-01-07 10:11:37 -0200
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-01-07 10:11:37 -0200
commit7ba37134d247f6057302f6af9893df603d14afae (patch)
tree16f893cdfcf2c58dcdd814d7fa23d376fb02335c /mysql-test/t/innodb_mysql.test
parent6ff7a3264f83b7f39888bd3e1f08e2862828c28e (diff)
downloadmariadb-git-7ba37134d247f6057302f6af9893df603d14afae.tar.gz
Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites
locking type of temp table The problem is that INSERT INTO .. SELECT FROM .. and CREATE TABLE .. SELECT FROM a temporary table could inadvertently overwrite the locking type of the temporary table. The lock type of temporary tables should be a write lock by default. The solution is to reset the lock type of temporary tables back to its default value after they are used in a statement. mysql-test/r/innodb_mysql.result: Add test case result for Bug#41348 mysql-test/r/temp_table.result: Add test case result for Bug#41348 mysql-test/t/innodb_mysql.test: Add test case for Bug#41348 mysql-test/t/temp_table.test: Add test case for Bug#41348 sql/sql_base.cc: Allow the lock type of temp tables to be overwritten now that the the value is being restored once the table is marked as free for re-use. This makes the behavior consistent with that of non-temporary tables and avoids confusion.
Diffstat (limited to 'mysql-test/t/innodb_mysql.test')
-rw-r--r--mysql-test/t/innodb_mysql.test41
1 files changed, 41 insertions, 0 deletions
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index 1f9c08ac43b..5a2e115a98d 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -91,4 +91,45 @@ INSERT INTO foo2 SELECT * FROM foo;
DROP TABLE foo, bar, foo2;
+#
+# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t3,t2;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+DELIMITER |;
+CREATE FUNCTION f1() RETURNS VARCHAR(250)
+ BEGIN
+ return 'hhhhhhh' ;
+ END|
+DELIMITER ;|
+
+CREATE TABLE t1 (a VARCHAR(20), b VARCHAR(20), c VARCHAR(20)) ENGINE=INNODB;
+
+BEGIN WORK;
+
+CREATE TEMPORARY TABLE t2 (a VARCHAR(20), b VARCHAR(20), c varchar(20)) ENGINE=INNODB;
+CREATE TEMPORARY TABLE t3 LIKE t2;
+
+INSERT INTO t1 VALUES ('a','b',NULL),('c','d',NULL),('e','f',NULL);
+
+SET @stmt := CONCAT('INSERT INTO t2 SELECT tbl.a, tbl.b, f1()',' FROM t1 tbl');
+PREPARE stmt1 FROM @stmt;
+
+SET @stmt := CONCAT('INSERT INTO t3', ' SELECT * FROM t2');
+PREPARE stmt3 FROM @stmt;
+
+EXECUTE stmt1;
+
+COMMIT;
+
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt3;
+
+DROP TABLE t1,t3,t2;
+DROP FUNCTION f1;
+
--echo End of 5.1 tests