mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +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:
@ -1767,4 +1767,25 @@ ref NULL
|
||||
rows 6
|
||||
Extra Using where; Using index
|
||||
DROP TABLE foo, bar, foo2;
|
||||
DROP TABLE IF EXISTS t1,t3,t2;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
CREATE FUNCTION f1() RETURNS VARCHAR(250)
|
||||
BEGIN
|
||||
return 'hhhhhhh' ;
|
||||
END|
|
||||
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;
|
||||
End of 5.1 tests
|
||||
|
Reference in New Issue
Block a user