diff options
author | Monty <monty@mariadb.org> | 2018-05-16 21:51:46 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-05-16 21:51:46 +0300 |
commit | ef295c31e3d50a99a90beccfb4deb9d9d36ac1e3 (patch) | |
tree | e504c310e3f0829c2041e65e1e9cbfe7ac5fc99d /mysql-test/t | |
parent | d703e09cd6706673fbb127f540d3917068b40755 (diff) | |
download | mariadb-git-ef295c31e3d50a99a90beccfb4deb9d9d36ac1e3.tar.gz |
MDEV-11129 CREATE OR REPLACE TABLE t1 AS SELECT spfunc() crashes if spfunc() references t1
Fixed by extending unique_table() with a flag to not allow usage of
the replaced table.
I also cleaned up find_dup_table() to not use goto next.
I also added more comments to the code in find_dup_table()
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/create_or_replace.test | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mysql-test/t/create_or_replace.test b/mysql-test/t/create_or_replace.test index b37417f39d0..5ebb3031be3 100644 --- a/mysql-test/t/create_or_replace.test +++ b/mysql-test/t/create_or_replace.test @@ -398,3 +398,28 @@ CREATE OR REPLACE TABLE t1 AS SELECT f1(); UNLOCK TABLES; DROP FUNCTION f1; DROP TABLE t1; + +--echo # +--echo # MDEV-11129 +--echo # CREATE OR REPLACE TABLE t1 AS SELECT spfunc() crashes if spfunc() +--echo # references t1 +--echo # + +CREATE OR REPLACE TABLE t1(a INT); +DELIMITER $$; +CREATE FUNCTION f1() RETURNS VARCHAR(16383) +BEGIN + INSERT INTO t1 VALUES(1); + RETURN 'test'; +END; +$$ +DELIMITER ;$$ +--error ER_UPDATE_TABLE_USED +CREATE OR REPLACE TABLE t1 AS SELECT f1(); +LOCK TABLE t1 WRITE; +--error ER_TABLE_NOT_LOCKED +CREATE OR REPLACE TABLE t1 AS SELECT f1(); +UNLOCK TABLES; + +DROP FUNCTION f1; +DROP TABLE t1; |