summaryrefslogtreecommitdiff
path: root/mysql-test/main/insert.test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2022-04-25 18:08:57 -0700
committerIgor Babaev <igor@askmonty.org>2022-04-27 08:23:01 -0700
commit39feab3cd31b5414aa9b428eaba915c251ac34a2 (patch)
treed30244a324d73d724ce0c50b1d72a46467a2d3d5 /mysql-test/main/insert.test
parentfccca49997320bafe1282c758a5143f88b6e0e0f (diff)
downloadmariadb-git-39feab3cd31b5414aa9b428eaba915c251ac34a2.tar.gz
MDEV-26412 Server crash in Item_field::fix_outer_field for INSERT SELECT
IF an INSERT/REPLACE SELECT statement contained an ON expression in the top level select and this expression used a subquery with a column reference that could not be resolved then an attempt to resolve this reference as an outer reference caused a crash of the server. This happened because the outer context field in the Name_resolution_context structure was not set to NULL for such references. Rather it pointed to the first element in the select_stack. Note that starting from 10.4 we cannot use the SELECT_LEX::outer_select() method when parsing a SELECT construct. Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'mysql-test/main/insert.test')
-rw-r--r--mysql-test/main/insert.test22
1 files changed, 22 insertions, 0 deletions
diff --git a/mysql-test/main/insert.test b/mysql-test/main/insert.test
index e00c9cd7a0d..9fd0933cc7c 100644
--- a/mysql-test/main/insert.test
+++ b/mysql-test/main/insert.test
@@ -612,3 +612,25 @@ CREATE VIEW v1 AS SELECT * FROM t1 WHERE f <=> 'foo' WITH CHECK OPTION;
REPLACE INTO v1 SET f = NULL;
DROP VIEW v1;
DROP TABLE t1;
+
+--echo # End of 10.0 tests
+
+--echo #
+--echo # MDEV-26412: INSERT CREATE with subquery in ON expression
+--echo #
+
+create table t1 (a int);
+create table t2 (b int);
+create table t3 (c int);
+create table t4 (d1 int, d2 int);
+
+--error ER_BAD_FIELD_ERROR
+insert into t4
+ select * from t1 left join t2 on (select t1.i from t3);
+--error ER_BAD_FIELD_ERROR
+replace t4
+ select * from t1 left join t2 on (select t1.i from t3);
+
+drop table t1,t2,t3,t4;
+
+--echo # End of 10.4 tests