Skip to content

Commit

Permalink
MDEV-7445:Server crash with Signal 6
Browse files Browse the repository at this point in the history
MDEV-7565: Server crash with Signal 6 (part 2)

followup test suite and its fix.
  • Loading branch information
sanja-byelkin committed Oct 6, 2015
1 parent 2e3e818 commit 0ab93fd
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 12 deletions.
8 changes: 7 additions & 1 deletion mysql-test/r/subselect.result
Original file line number Diff line number Diff line change
Expand Up @@ -3590,7 +3590,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
drop table t1, t2;
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
Expand Down Expand Up @@ -7047,3 +7047,9 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
SELECT
(SELECT user FROM mysql.user
WHERE h.host in (SELECT host FROM mysql.user)
) AS sq
FROM mysql.host h GROUP BY h.host;
sq
8 changes: 7 additions & 1 deletion mysql-test/r/subselect_no_mat.result
Original file line number Diff line number Diff line change
Expand Up @@ -3594,7 +3594,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
drop table t1, t2;
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
Expand Down Expand Up @@ -7044,6 +7044,12 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
SELECT
(SELECT user FROM mysql.user
WHERE h.host in (SELECT host FROM mysql.user)
) AS sq
FROM mysql.host h GROUP BY h.host;
sq
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%'
Expand Down
8 changes: 7 additions & 1 deletion mysql-test/r/subselect_no_opts.result
Original file line number Diff line number Diff line change
Expand Up @@ -3590,7 +3590,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
drop table t1, t2;
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
Expand Down Expand Up @@ -7042,4 +7042,10 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
SELECT
(SELECT user FROM mysql.user
WHERE h.host in (SELECT host FROM mysql.user)
) AS sq
FROM mysql.host h GROUP BY h.host;
sq
set @optimizer_switch_for_subselect_test=null;
8 changes: 7 additions & 1 deletion mysql-test/r/subselect_no_scache.result
Original file line number Diff line number Diff line change
Expand Up @@ -3596,7 +3596,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
drop table t1, t2;
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
Expand Down Expand Up @@ -7053,6 +7053,12 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
SELECT
(SELECT user FROM mysql.user
WHERE h.host in (SELECT host FROM mysql.user)
) AS sq
FROM mysql.host h GROUP BY h.host;
sq
set optimizer_switch=default;
select @@optimizer_switch like '%subquery_cache=on%';
@@optimizer_switch like '%subquery_cache=on%'
Expand Down
8 changes: 7 additions & 1 deletion mysql-test/r/subselect_no_semijoin.result
Original file line number Diff line number Diff line change
Expand Up @@ -3590,7 +3590,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
drop table t1, t2;
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
Expand Down Expand Up @@ -7042,5 +7042,11 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
SELECT
(SELECT user FROM mysql.user
WHERE h.host in (SELECT host FROM mysql.user)
) AS sq
FROM mysql.host h GROUP BY h.host;
sq
set @optimizer_switch_for_subselect_test=null;
set @join_cache_level_for_subselect_test=NULL;
7 changes: 7 additions & 0 deletions mysql-test/t/subselect.test
Original file line number Diff line number Diff line change
Expand Up @@ -5923,3 +5923,10 @@ call procedure2();
call procedure2();

drop procedure procedure2;


SELECT
(SELECT user FROM mysql.user
WHERE h.host in (SELECT host FROM mysql.user)
) AS sq
FROM mysql.host h GROUP BY h.host;
20 changes: 13 additions & 7 deletions sql/item_subselect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2653,10 +2653,12 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
{
uint outer_cols_num;
List<Item> *inner_cols;
char const *save_where= thd->where;

if (test_strategy(SUBS_SEMI_JOIN))
return !( (*ref)= new Item_int(1));

thd->where= "IN/ALL/ANY subquery";
/*
Check if the outer and inner IN operands match in those cases when we
will not perform IN=>EXISTS transformation. Currently this is when we
Expand Down Expand Up @@ -2687,7 +2689,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
if (outer_cols_num != inner_cols->elements)
{
my_error(ER_OPERAND_COLUMNS, MYF(0), outer_cols_num);
return TRUE;
goto err;
}
if (outer_cols_num > 1)
{
Expand All @@ -2697,20 +2699,24 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
{
inner_col= inner_col_it++;
if (inner_col->check_cols(left_expr->element_index(i)->cols()))
return TRUE;
goto err;
}
}
}

if (thd_arg->lex->is_view_context_analysis() &&
left_expr && !left_expr->fixed &&
if (left_expr && !left_expr->fixed &&
left_expr->fix_fields(thd_arg, &left_expr))
return TRUE;
goto err;
else
if (Item_subselect::fix_fields(thd_arg, ref))
return TRUE;
if (Item_subselect::fix_fields(thd_arg, ref))
goto err;
fixed= TRUE;
thd->where= save_where;
return FALSE;

err:
thd->where= save_where;
return TRUE;
}


Expand Down

0 comments on commit 0ab93fd

Please sign in to comment.