summaryrefslogtreecommitdiff
path: root/mysql-test/r
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-05-16 21:51:46 +0300
committerMonty <monty@mariadb.org>2018-05-16 21:51:46 +0300
commitef295c31e3d50a99a90beccfb4deb9d9d36ac1e3 (patch)
treee504c310e3f0829c2041e65e1e9cbfe7ac5fc99d /mysql-test/r
parentd703e09cd6706673fbb127f540d3917068b40755 (diff)
downloadmariadb-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/r')
-rw-r--r--mysql-test/r/create_or_replace.result20
1 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/r/create_or_replace.result b/mysql-test/r/create_or_replace.result
index a43dc2eaca4..0d171f9f87a 100644
--- a/mysql-test/r/create_or_replace.result
+++ b/mysql-test/r/create_or_replace.result
@@ -453,3 +453,23 @@ CREATE OR REPLACE TABLE t1 AS SELECT f1();
UNLOCK TABLES;
DROP FUNCTION f1;
DROP TABLE t1;
+#
+# MDEV-11129
+# CREATE OR REPLACE TABLE t1 AS SELECT spfunc() crashes if spfunc()
+# references t1
+#
+CREATE OR REPLACE TABLE t1(a INT);
+CREATE FUNCTION f1() RETURNS VARCHAR(16383)
+BEGIN
+INSERT INTO t1 VALUES(1);
+RETURN 'test';
+END;
+$$
+CREATE OR REPLACE TABLE t1 AS SELECT f1();
+ERROR HY000: Table 't1' is specified twice, both as a target for 'CREATE' and as a separate source for data
+LOCK TABLE t1 WRITE;
+CREATE OR REPLACE TABLE t1 AS SELECT f1();
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+UNLOCK TABLES;
+DROP FUNCTION f1;
+DROP TABLE t1;