diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 8a01b4080c3..6c05ce10592 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -2809,19 +2809,19 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where Warnings: -Note 1003 select test.t1.one AS `one`,test.t1.two AS `two`,((test.t1.one,test.t1.two),(select test.t2.one AS `one`,test.t2.two AS `two` from test.t2 where ((test.t2.flag = _latin1'0') and (((test.t1.one) = test.t2.one) or isnull(test.t2.one)) and (((test.t1.two) = test.t2.two) or isnull(test.t2.two))) having ((test.t2.one) and (test.t2.two)))) AS `test` from test.t1 +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'0') and (((`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)) and (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) having ((`test`.`t2`.`one`) and (`test`.`t2`.`two`)))) AS `test` from `test`.`t1` explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where Warnings: -Note 1003 select test.t1.one AS `one`,test.t1.two AS `two` from test.t1 where ((test.t1.one,test.t1.two),(select test.t2.one AS `one`,test.t2.two AS `two` from test.t2 where ((test.t2.flag = _latin1'N') and ((test.t1.one) = test.t2.one) and ((test.t1.two) = test.t2.two)))) +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where ((`test`.`t1`.`one`,`test`.`t1`.`two`),(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'N') and ((`test`.`t1`.`one`) = `test`.`t2`.`one`) and ((`test`.`t1`.`two`) = `test`.`t2`.`two`)))) explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where; Using temporary; Using filesort Warnings: -Note 1003 select test.t1.one AS `one`,test.t1.two AS `two`,((test.t1.one,test.t1.two),(select test.t2.one AS `one`,test.t2.two AS `two` from test.t2 where (test.t2.flag = _latin1'0') group by test.t2.one,test.t2.two having ((((test.t1.one) = test.t2.one) or isnull(test.t2.one)) and (((test.t1.two) = test.t2.two) or isnull(test.t2.two)) and (test.t2.one) and (test.t2.two)))) AS `test` from test.t1 +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,((`test`.`t1`.`one`,`test`.`t1`.`two`),(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where (`test`.`t2`.`flag` = _latin1'0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having ((((`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)) and (((`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)) and (`test`.`t2`.`one`) and (`test`.`t2`.`two`)))) AS `test` from `test`.`t1` DROP TABLE t1,t2; CREATE TABLE t1 (a char(5), b char(5)); INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 1eddb36b34c..a5985a6c4a9 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1093,21 +1093,24 @@ Item_in_subselect::row_value_transformer(JOIN *join) DBUG_RETURN(RES_ERROR); Item *item_eq= new Item_func_eq(new - Item_direct_ref((*optimizer->get_cache())-> + Item_direct_ref(&select_lex->context, + (*optimizer->get_cache())-> addr(i), (char *)"", (char *)in_left_expr_name), new - Item_direct_ref(select_lex->ref_pointer_array + i, + Item_direct_ref(&select_lex->context, + select_lex->ref_pointer_array + i, (char *)"", (char *)"") ); Item *item_isnull= new Item_func_isnull(new - Item_direct_ref( select_lex-> - ref_pointer_array+i, - (char *)"", - (char *)"") + Item_direct_ref(&select_lex->context, + select_lex-> + ref_pointer_array+i, + (char *)"", + (char *)"") ); having_item= and_items(having_item, @@ -1117,7 +1120,8 @@ Item_in_subselect::row_value_transformer(JOIN *join) new Item_is_not_null_test(this, new - Item_direct_ref(select_lex-> + Item_direct_ref(&select_lex->context, + select_lex-> ref_pointer_array + i, (char *)"", (char *)"") @@ -1157,15 +1161,17 @@ Item_in_subselect::row_value_transformer(JOIN *join) DBUG_RETURN(RES_ERROR); item= new Item_func_eq(new - Item_direct_ref((*optimizer->get_cache())-> + Item_direct_ref(&select_lex->context, + (*optimizer->get_cache())-> addr(i), (char *)"", (char *)in_left_expr_name), new - Item_direct_ref( select_lex-> - ref_pointer_array+i, - (char *)"", - (char *)"") + Item_direct_ref(&select_lex->context, + select_lex-> + ref_pointer_array+i, + (char *)"", + (char *)"") ); if (!abort_on_null) { @@ -1174,7 +1180,8 @@ Item_in_subselect::row_value_transformer(JOIN *join) new Item_is_not_null_test(this, new - Item_direct_ref(select_lex-> + Item_direct_ref(&select_lex->context, + select_lex-> ref_pointer_array + i, (char *)"", (char *)"") @@ -1182,10 +1189,11 @@ Item_in_subselect::row_value_transformer(JOIN *join) ); item_isnull= new Item_func_isnull(new - Item_direct_ref( select_lex-> - ref_pointer_array+i, - (char *)"", - (char *)"") + Item_direct_ref(&select_lex->context, + select_lex-> + ref_pointer_array+i, + (char *)"", + (char *)"") ); item= new Item_cond_or(item, item_isnull);