Manual merge

parent 74bbe205
...@@ -508,10 +508,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -508,10 +508,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%pure_parser /* We have threads */ %pure_parser /* We have threads */
/* /*
Currently there is 286 shift/reduce conflict. We should not introduce Currently there are 280 shift/reduce conflicts.
new conflicts any more. We should not introduce new conflicts any more.
*/ */
%expect 286 %expect 280
/* /*
Comments for TOKENS. Comments for TOKENS.
...@@ -1089,7 +1089,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1089,7 +1089,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
/* A dummy token to force the priority of table_ref production in a join. */ /* A dummy token to force the priority of table_ref production in a join. */
%left TABLE_REF_PRIORITY %left TABLE_REF_PRIORITY
%left SET_VAR %left SET_VAR
%left OR_OR_SYM OR_SYM OR2_SYM XOR %left OR_OR_SYM OR_SYM OR2_SYM
%left XOR
%left AND_SYM AND_AND_SYM %left AND_SYM AND_AND_SYM
%left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE %left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
%left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP IN_SYM %left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP IN_SYM
...@@ -1102,6 +1103,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1102,6 +1103,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%left NEG '~' %left NEG '~'
%right NOT_SYM NOT2_SYM %right NOT_SYM NOT2_SYM
%right BINARY COLLATE_SYM %right BINARY COLLATE_SYM
%left INTERVAL_SYM
%type <lex_str> %type <lex_str>
IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM
...@@ -1150,7 +1152,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1150,7 +1152,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <item> %type <item>
literal text_literal insert_ident order_ident literal text_literal insert_ident order_ident
simple_ident select_item2 expr opt_expr opt_else sum_expr in_sum_expr simple_ident select_item2 expr opt_expr opt_else sum_expr in_sum_expr
variable variable_aux bool_term bool_factor bool_test bool_pri variable variable_aux bool_factor bool_test bool_pri
predicate bit_expr bit_term bit_factor value_expr term factor predicate bit_expr bit_term bit_factor value_expr term factor
table_wild simple_expr udf_expr table_wild simple_expr udf_expr
expr_or_default set_expr_or_default interval_expr expr_or_default set_expr_or_default interval_expr
...@@ -6555,52 +6557,102 @@ optional_braces: ...@@ -6555,52 +6557,102 @@ optional_braces:
/* all possible expressions */ /* all possible expressions */
expr: expr:
bool_term { Select->expr_list.push_front(new List<Item>); } bool_factor
bool_or_expr | expr or expr %prec OR_SYM
{ {
List<Item> *list= Select->expr_list.pop(); /*
if (list->elements) Design notes:
Do not use a manually maintained stack like thd->lex->xxx_list,
but use the internal bison stack ($$, $1 and $3) instead.
Using the bison stack is:
- more robust to changes in the grammar,
- guaranteed to be in sync with the parser state,
- better for performances (no memory allocation).
*/
Item_cond_or *item1;
Item_cond_or *item3;
if (is_cond_or($1))
{
item1= (Item_cond_or*) $1;
if (is_cond_or($3))
{ {
list->push_front($1); item3= (Item_cond_or*) $3;
$$= new Item_cond_or(*list); /*
/* optimize construction of logical OR to reduce (X1 OR X2) OR (Y1 OR Y2) ==> OR (X1, X2, Y1, Y2)
amount of objects for complex expressions */ */
item3->add_at_head(item1->argument_list());
$$ = $3;
} }
else else
$$= $1; {
delete list; /*
(X1 OR X2) OR Y ==> OR (X1, X2, Y)
*/
item1->add($3);
$$ = $1;
} }
; }
else if (is_cond_or($3))
bool_or_expr: {
/* empty */ item3= (Item_cond_or*) $3;
| bool_or_expr or bool_term /*
{ Select->expr_list.head()->push_back($3); } X OR (Y1 OR Y2) ==> OR (X, Y1, Y2)
; */
item3->add_at_head($1);
bool_term: $$ = $3;
bool_term XOR bool_term { $$= new Item_cond_xor($1,$3); } }
| bool_factor { Select->expr_list.push_front(new List<Item>); } else
bool_and_expr {
/* X OR Y */
$$ = new (YYTHD->mem_root) Item_cond_or($1, $3);
}
}
| expr XOR expr %prec XOR
{
/* XOR is a proprietary extension */
$$ = new (YYTHD->mem_root) Item_cond_xor($1, $3);
}
| expr and expr %prec AND_SYM
{ {
List<Item> *list= Select->expr_list.pop(); /* See comments in rule expr: expr or expr */
if (list->elements) Item_cond_and *item1;
Item_cond_and *item3;
if (is_cond_and($1))
{ {
list->push_front($1); item1= (Item_cond_and*) $1;
$$= new Item_cond_and(*list); if (is_cond_and($3))
/* optimize construction of logical AND to reduce {
amount of objects for complex expressions */ item3= (Item_cond_and*) $3;
/*
(X1 AND X2) AND (Y1 AND Y2) ==> AND (X1, X2, Y1, Y2)
*/
item3->add_at_head(item1->argument_list());
$$ = $3;
} }
else else
$$= $1; {
delete list; /*
(X1 AND X2) AND Y ==> AND (X1, X2, Y)
*/
item1->add($3);
$$ = $1;
}
}
else if (is_cond_and($3))
{
item3= (Item_cond_and*) $3;
/*
X AND (Y1 AND Y2) ==> AND (X, Y1, Y2)
*/
item3->add_at_head($1);
$$ = $3;
}
else
{
/* X AND Y */
$$ = new (YYTHD->mem_root) Item_cond_and($1, $3);
}
} }
;
bool_and_expr:
/* empty */
| bool_and_expr and bool_factor
{ Select->expr_list.head()->push_back($3); }
; ;
bool_factor: bool_factor:
...@@ -6766,7 +6818,8 @@ all_or_any: ...@@ -6766,7 +6818,8 @@ all_or_any:
; ;
interval_expr: interval_expr:
INTERVAL_SYM expr { $$=$2; } INTERVAL_SYM expr %prec INTERVAL_SYM
{ $$=$2; }
; ;
simple_expr: simple_expr:
......
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