Commit 29f61620 authored by igor@rurik.mysql.com's avatar igor@rurik.mysql.com

af

parent 6fa845d7
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -700,6 +700,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -700,6 +700,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%type <table_list> %type <table_list>
join_table_list join_table join_table_list join_table
table_factor table_ref
%type <date_time_type> date_time_type; %type <date_time_type> date_time_type;
%type <interval> interval %type <interval> interval
...@@ -4430,59 +4431,80 @@ when_list2: ...@@ -4430,59 +4431,80 @@ when_list2:
sel->when_list.head()->push_back($5); sel->when_list.head()->push_back($5);
}; };
join_table_list: table_ref:
'(' join_table_list ')' { $$=$2; } table_factor { $$=$1; }
| join_table { $$=$1; } | join_table { $$=$1; }
| join_table_list ',' join_table_list { $$=$3; } {
| join_table_list normal_join join_table_list { $$=$3; } LEX *lex= Lex;
| join_table_list STRAIGHT_JOIN join_table_list if (!($$= lex->current_select->nest_last_join(lex->thd)))
{ $$=$3 ; $1->next->straight=1; } YYABORT;
| join_table_list normal_join join_table_list ON expr }
;
join_table_list:
table_ref { $$=$1; }
| join_table_list ',' table_ref { $$=$3; }
;
join_table:
table_ref normal_join table_ref { $$=$3; }
| table_ref STRAIGHT_JOIN table_factor
{ $3->straight=1; $$=$3 ; }
| table_ref normal_join table_ref ON expr
{ add_join_on($3,$5); $$=$3; } { add_join_on($3,$5); $$=$3; }
| join_table_list normal_join join_table_list | table_ref normal_join table_ref
USING USING
{ {
SELECT_LEX *sel= Select; SELECT_LEX *sel= Select;
sel->db1=$1->db; sel->table1=$1->alias; sel->save_names_for_using_list($1, $3);
sel->db2=$3->db; sel->table2=$3->alias;
} }
'(' using_list ')' '(' using_list ')'
{ add_join_on($3,$7); $$=$3; } { add_join_on($3,$7); $$=$3; }
| join_table_list LEFT opt_outer JOIN_SYM join_table_list ON expr | table_ref LEFT opt_outer JOIN_SYM table_factor ON expr
{ add_join_on($5,$7); $5->outer_join|=JOIN_TYPE_LEFT; $$=$5; } { add_join_on($5,$7); $5->outer_join|=JOIN_TYPE_LEFT; $$=$5; }
| join_table_list LEFT opt_outer JOIN_SYM join_table_list | table_ref LEFT opt_outer JOIN_SYM table_factor
{ {
SELECT_LEX *sel= Select; SELECT_LEX *sel= Select;
sel->db1=$1->db; sel->table1=$1->alias; sel->save_names_for_using_list($1, $5);
sel->db2=$5->db; sel->table2=$5->alias;
} }
USING '(' using_list ')' USING '(' using_list ')'
{ add_join_on($5,$9); $5->outer_join|=JOIN_TYPE_LEFT; $$=$5; } { add_join_on($5,$9); $5->outer_join|=JOIN_TYPE_LEFT; $$=$5; }
| join_table_list NATURAL LEFT opt_outer JOIN_SYM join_table_list | table_ref NATURAL LEFT opt_outer JOIN_SYM table_factor
{ {
add_join_natural($1,$1->next); add_join_natural($1,$6);
$1->next->outer_join|=JOIN_TYPE_LEFT; $6->outer_join|=JOIN_TYPE_LEFT;
$$=$6; $$=$6;
} }
| join_table_list RIGHT opt_outer JOIN_SYM join_table_list ON expr | table_ref RIGHT opt_outer JOIN_SYM table_factor ON expr
{ add_join_on($1,$7); $1->outer_join|=JOIN_TYPE_RIGHT; $$=$5; } {
| join_table_list RIGHT opt_outer JOIN_SYM join_table_list LEX *lex= Lex;
if (!($$= lex->current_select->convert_right_join()))
YYABORT;
add_join_on($$, $7);
}
| table_ref RIGHT opt_outer JOIN_SYM table_factor
{ {
SELECT_LEX *sel= Select; SELECT_LEX *sel= Select;
sel->db1=$1->db; sel->table1=$1->alias; sel->save_names_for_using_list($1, $5);
sel->db2=$5->db; sel->table2=$5->alias;
} }
USING '(' using_list ')' USING '(' using_list ')'
{ add_join_on($1,$9); $1->outer_join|=JOIN_TYPE_RIGHT; $$=$5; }
| join_table_list NATURAL RIGHT opt_outer JOIN_SYM join_table_list
{ {
add_join_natural($1->next,$1); LEX *lex= Lex;
$1->outer_join|=JOIN_TYPE_RIGHT; if (!($$= lex->current_select->convert_right_join()))
$$=$6; YYABORT;
add_join_on($$, $9);
}
| table_ref NATURAL RIGHT opt_outer JOIN_SYM table_factor
{
add_join_natural($6,$1);
LEX *lex= Lex;
if (!($$= lex->current_select->convert_right_join()))
YYABORT;
} }
| join_table_list NATURAL JOIN_SYM join_table_list | table_ref NATURAL JOIN_SYM table_factor
{ add_join_natural($1,$1->next); $$=$4; }; { add_join_natural($1,$4); $$=$4; };
normal_join: normal_join:
JOIN_SYM {} JOIN_SYM {}
...@@ -4490,7 +4512,7 @@ normal_join: ...@@ -4490,7 +4512,7 @@ normal_join:
| CROSS JOIN_SYM {} | CROSS JOIN_SYM {}
; ;
join_table: table_factor:
{ {
SELECT_LEX *sel= Select; SELECT_LEX *sel= Select;
sel->use_index_ptr=sel->ignore_index_ptr=0; sel->use_index_ptr=sel->ignore_index_ptr=0;
...@@ -4506,8 +4528,21 @@ join_table: ...@@ -4506,8 +4528,21 @@ join_table:
sel->get_use_index(), sel->get_use_index(),
sel->get_ignore_index()))) sel->get_ignore_index())))
YYABORT; YYABORT;
sel->add_joined_table($$);
}
| '('
{
LEX *lex= Lex;
if (lex->current_select->init_nested_join(lex->thd))
YYABORT;
}
join_table_list ')'
{
LEX *lex= Lex;
if (!($$= lex->current_select->end_nested_join(lex->thd)))
YYABORT;
} }
| '{' ident join_table LEFT OUTER JOIN_SYM join_table ON expr '}' | '{' ident table_ref LEFT OUTER JOIN_SYM table_ref ON expr '}'
{ add_join_on($7,$9); $7->outer_join|=JOIN_TYPE_LEFT; $$=$7; } { add_join_on($7,$9); $7->outer_join|=JOIN_TYPE_LEFT; $$=$7; }
| '(' SELECT_SYM select_derived ')' opt_table_alias | '(' SELECT_SYM select_derived ')' opt_table_alias
{ {
...@@ -4520,6 +4555,7 @@ join_table: ...@@ -4520,6 +4555,7 @@ join_table:
(List<String> *)0))) (List<String> *)0)))
YYABORT; YYABORT;
lex->current_select->add_joined_table($$);
}; };
select_derived: select_derived:
......
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