Skip to content

Commit 0ab93fd

Browse files
committed
MDEV-7445:Server crash with Signal 6
MDEV-7565: Server crash with Signal 6 (part 2) followup test suite and its fix.
1 parent 2e3e818 commit 0ab93fd

File tree

7 files changed

+55
-12
lines changed

7 files changed

+55
-12
lines changed

mysql-test/r/subselect.result

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
35903590
drop table t1, t2;
35913591
CREATE TABLE t1 (a INT);
35923592
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
3593-
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
3593+
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
35943594
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
35953595
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
35963596
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7047,3 +7047,9 @@ call procedure2();
70477047
ControlRev
70487048
NULL
70497049
drop procedure procedure2;
7050+
SELECT
7051+
(SELECT user FROM mysql.user
7052+
WHERE h.host in (SELECT host FROM mysql.user)
7053+
) AS sq
7054+
FROM mysql.host h GROUP BY h.host;
7055+
sq

mysql-test/r/subselect_no_mat.result

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3594,7 +3594,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
35943594
drop table t1, t2;
35953595
CREATE TABLE t1 (a INT);
35963596
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
3597-
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
3597+
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
35983598
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
35993599
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
36003600
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7044,6 +7044,12 @@ call procedure2();
70447044
ControlRev
70457045
NULL
70467046
drop procedure procedure2;
7047+
SELECT
7048+
(SELECT user FROM mysql.user
7049+
WHERE h.host in (SELECT host FROM mysql.user)
7050+
) AS sq
7051+
FROM mysql.host h GROUP BY h.host;
7052+
sq
70477053
set optimizer_switch=default;
70487054
select @@optimizer_switch like '%materialization=on%';
70497055
@@optimizer_switch like '%materialization=on%'

mysql-test/r/subselect_no_opts.result

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
35903590
drop table t1, t2;
35913591
CREATE TABLE t1 (a INT);
35923592
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
3593-
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
3593+
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
35943594
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
35953595
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
35963596
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7042,4 +7042,10 @@ call procedure2();
70427042
ControlRev
70437043
NULL
70447044
drop procedure procedure2;
7045+
SELECT
7046+
(SELECT user FROM mysql.user
7047+
WHERE h.host in (SELECT host FROM mysql.user)
7048+
) AS sq
7049+
FROM mysql.host h GROUP BY h.host;
7050+
sq
70457051
set @optimizer_switch_for_subselect_test=null;

mysql-test/r/subselect_no_scache.result

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3596,7 +3596,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
35963596
drop table t1, t2;
35973597
CREATE TABLE t1 (a INT);
35983598
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
3599-
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
3599+
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
36003600
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
36013601
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
36023602
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7053,6 +7053,12 @@ call procedure2();
70537053
ControlRev
70547054
NULL
70557055
drop procedure procedure2;
7056+
SELECT
7057+
(SELECT user FROM mysql.user
7058+
WHERE h.host in (SELECT host FROM mysql.user)
7059+
) AS sq
7060+
FROM mysql.host h GROUP BY h.host;
7061+
sq
70567062
set optimizer_switch=default;
70577063
select @@optimizer_switch like '%subquery_cache=on%';
70587064
@@optimizer_switch like '%subquery_cache=on%'

mysql-test/r/subselect_no_semijoin.result

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
35903590
drop table t1, t2;
35913591
CREATE TABLE t1 (a INT);
35923592
CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
3593-
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
3593+
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
35943594
CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
35953595
ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
35963596
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7042,5 +7042,11 @@ call procedure2();
70427042
ControlRev
70437043
NULL
70447044
drop procedure procedure2;
7045+
SELECT
7046+
(SELECT user FROM mysql.user
7047+
WHERE h.host in (SELECT host FROM mysql.user)
7048+
) AS sq
7049+
FROM mysql.host h GROUP BY h.host;
7050+
sq
70457051
set @optimizer_switch_for_subselect_test=null;
70467052
set @join_cache_level_for_subselect_test=NULL;

mysql-test/t/subselect.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5923,3 +5923,10 @@ call procedure2();
59235923
call procedure2();
59245924

59255925
drop procedure procedure2;
5926+
5927+
5928+
SELECT
5929+
(SELECT user FROM mysql.user
5930+
WHERE h.host in (SELECT host FROM mysql.user)
5931+
) AS sq
5932+
FROM mysql.host h GROUP BY h.host;

sql/item_subselect.cc

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,10 +2653,12 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
26532653
{
26542654
uint outer_cols_num;
26552655
List<Item> *inner_cols;
2656+
char const *save_where= thd->where;
26562657

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

2661+
thd->where= "IN/ALL/ANY subquery";
26602662
/*
26612663
Check if the outer and inner IN operands match in those cases when we
26622664
will not perform IN=>EXISTS transformation. Currently this is when we
@@ -2687,7 +2689,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
26872689
if (outer_cols_num != inner_cols->elements)
26882690
{
26892691
my_error(ER_OPERAND_COLUMNS, MYF(0), outer_cols_num);
2690-
return TRUE;
2692+
goto err;
26912693
}
26922694
if (outer_cols_num > 1)
26932695
{
@@ -2697,20 +2699,24 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
26972699
{
26982700
inner_col= inner_col_it++;
26992701
if (inner_col->check_cols(left_expr->element_index(i)->cols()))
2700-
return TRUE;
2702+
goto err;
27012703
}
27022704
}
27032705
}
27042706

2705-
if (thd_arg->lex->is_view_context_analysis() &&
2706-
left_expr && !left_expr->fixed &&
2707+
if (left_expr && !left_expr->fixed &&
27072708
left_expr->fix_fields(thd_arg, &left_expr))
2708-
return TRUE;
2709+
goto err;
27092710
else
2710-
if (Item_subselect::fix_fields(thd_arg, ref))
2711-
return TRUE;
2711+
if (Item_subselect::fix_fields(thd_arg, ref))
2712+
goto err;
27122713
fixed= TRUE;
2714+
thd->where= save_where;
27132715
return FALSE;
2716+
2717+
err:
2718+
thd->where= save_where;
2719+
return TRUE;
27142720
}
27152721

27162722

0 commit comments

Comments
 (0)