[Commits] 6570149: MDEV-29088 Server crash upon CREATE VIEW with unknown column in ON condition
revision-id: 65701497583f86c5958f6c91e42b5c504eb54b9e (mariadb-10.4.25-26-g6570149) parent(s): 9a0cbd31ce8576468981b14b066dea155cb922d9 author: Igor Babaev committer: Igor Babaev timestamp: 2022-07-13 11:13:06 -0700 message: MDEV-29088 Server crash upon CREATE VIEW with unknown column in ON condition This bug caused crashes when the server executed such a CREATE VIEW statement whose view specification contained a reference to an unknown column in a subquery used in ON condition. The cause of this bug is quite similar to the cause of the bug MDEV-26412. The fix of this bug is quite similar to the fix for MDEV-26412. Approved by Sergey Petrunia <sergey@mariadb.com> --- mysql-test/main/view.result | 13 +++++++++++++ mysql-test/main/view.test | 18 ++++++++++++++++++ sql/sql_yacc.yy | 2 ++ 3 files changed, 33 insertions(+) diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index 11686fe..e92ba3f 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -6896,4 +6896,17 @@ ERROR 42S22: Unknown column 't1.x' in 'on clause' CREATE TABLE t4 AS SELECT * FROM t1 JOIN t2 ON t1.x > t2.b; ERROR 42S22: Unknown column 't1.x' in 'on clause' DROP TABLE t1,t2,t3; +# +# MDEV-29088: view specification contains unknown column in ON condition +# +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +create view v as +select * from t1 left join t2 on t1.a=t2.b and t1.a in (select d from t3); +ERROR 42S22: Unknown column 'd' in 'field list' +create algorithm=merge view v as +select * from t1 left join t2 on t1.a=t2.b and t1.a in (select d from t3); +ERROR 42S22: Unknown column 'd' in 'field list' +drop table t1,t2,t3; # End of 10.4 tests diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 5b813b4..6e65666 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -6626,4 +6626,22 @@ CREATE TABLE t4 AS SELECT * FROM t1 JOIN t2 ON t1.x > t2.b; DROP TABLE t1,t2,t3; +--echo # +--echo # MDEV-29088: view specification contains unknown column in ON condition +--echo # + +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); + +--error ER_BAD_FIELD_ERROR +create view v as + select * from t1 left join t2 on t1.a=t2.b and t1.a in (select d from t3); + +--error ER_BAD_FIELD_ERROR +create algorithm=merge view v as + select * from t1 left join t2 on t1.a=t2.b and t1.a in (select d from t3); + +drop table t1,t2,t3; + --echo # End of 10.4 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ff91a64..57540f9 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2829,6 +2829,7 @@ create: { if (Lex->main_select_push()) MYSQL_YYABORT; + Lex->inc_select_stack_outer_barrier(); if (Lex->add_create_view(thd, $1 | $5, DTYPE_ALGORITHM_UNDEFINED, $3, $6)) MYSQL_YYABORT; @@ -2844,6 +2845,7 @@ create: MYSQL_YYABORT; if (Lex->main_select_push()) MYSQL_YYABORT; + Lex->inc_select_stack_outer_barrier(); } view_list_opt AS view_select {
participants (1)
-
IgorBabaev