Skip to content
Permalink
Browse files
MDEV-29088 Server crash upon CREATE VIEW with unknown column in ON co…
…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.
@@ -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
@@ -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
@@ -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
{

0 comments on commit 65cc89e

Please sign in to comment.