Skip to content

Commit

Permalink
MDEV-29088 Server crash upon CREATE VIEW with unknown column in ON co…
Browse files Browse the repository at this point in the history
…ndition

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>
  • Loading branch information
igorbabaev committed Jul 13, 2022
1 parent f439cfd commit 65cc89e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mysql-test/main/view.result
Expand Up @@ -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
18 changes: 18 additions & 0 deletions mysql-test/main/view.test
Expand Up @@ -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
2 changes: 2 additions & 0 deletions sql/sql_yacc.yy
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down

0 comments on commit 65cc89e

Please sign in to comment.