mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
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.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user