Commit 8e7c17a8 authored by unknown's avatar unknown

Bug#8670

  Rework to resolve ambigious grammer: conflict in join expression
  handling of parentheses for nested joins and derived tables.
  Tests included of failing statements
Optimize item construction for AND/OR logical expressions


mysql-test/r/select.result:
  Bug#8670
    Tests for failing expressions
mysql-test/t/select.test:
  Bug#8670
    Tests for failing expressions
sql/sql_parse.cc:
  Bug#8670
    method st_select_lex::end_nested_join() returns NULL when
    there are no elements in the join.
sql/sql_yacc.yy:
  Optimize construction for Item_cond_or and Item_cond_and
    Reduces object count in case of complex expressions.
  Bug#8670
    Solve ambigious grammar.
    Fix handling of parentheses in join expressions to
    correct handling of nested joins and derived tables.
parent a569b083
...@@ -2446,3 +2446,12 @@ cast((a - b) as unsigned) ...@@ -2446,3 +2446,12 @@ cast((a - b) as unsigned)
1 1
18446744073709551615 18446744073709551615
drop table t1; drop table t1;
create table t1 (a int, b int);
create table t2 like t1;
select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1;
a
select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1;
a
select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1;
a a a
drop table t1,t2;
...@@ -2015,3 +2015,13 @@ select a-b , (a-b < 0) from t1 order by 1; ...@@ -2015,3 +2015,13 @@ select a-b , (a-b < 0) from t1 order by 1;
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
select cast((a - b) as unsigned) from t1 order by 1; select cast((a - b) as unsigned) from t1 order by 1;
drop table t1; drop table t1;
#
# Bug#8670
#
create table t1 (a int, b int);
create table t2 like t1;
select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1;
select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1;
select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1;
drop table t1,t2;
...@@ -5852,6 +5852,7 @@ TABLE_LIST *st_select_lex::end_nested_join(THD *thd) ...@@ -5852,6 +5852,7 @@ TABLE_LIST *st_select_lex::end_nested_join(THD *thd)
{ {
TABLE_LIST *ptr; TABLE_LIST *ptr;
DBUG_ENTER("end_nested_join"); DBUG_ENTER("end_nested_join");
DBUG_ASSERT(embedding);
ptr= embedding; ptr= embedding;
join_list= ptr->join_list; join_list= ptr->join_list;
embedding= ptr->embedding; embedding= ptr->embedding;
...@@ -5865,6 +5866,12 @@ TABLE_LIST *st_select_lex::end_nested_join(THD *thd) ...@@ -5865,6 +5866,12 @@ TABLE_LIST *st_select_lex::end_nested_join(THD *thd)
join_list->push_front(embedded); join_list->push_front(embedded);
ptr= embedded; ptr= embedded;
} }
else
if (nested_join->join_list.elements == 0)
{
join_list->pop();
DBUG_RETURN(0);
}
DBUG_RETURN(ptr); DBUG_RETURN(ptr);
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment