Commit 18c21eb6 authored by unknown's avatar unknown

Bug#6726 - failure to parse NOT BETWEEN

  Fix and test for parse bug


mysql-test/r/func_test.result:
  Bug#6726
    Test for parse bug
mysql-test/t/func_test.test:
  Bug#6726
    Test for parse bug
sql/sql_yacc.yy:
  Bug#6726
    Parser was confused by NOT in lookahead
parent ef6442f2
...@@ -183,3 +183,13 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3; ...@@ -183,3 +183,13 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3;
select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3; select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3;
5 mod 3 5 mod -3 -5 mod 3 -5 mod -3 5 mod 3 5 mod -3 -5 mod 3 -5 mod -3
2 2 -2 -2 2 2 -2 -2
create table t1 (a int, b int);
insert into t1 values (1,2), (2,3), (3,4), (4,5);
select * from t1 where a not between 1 and 2;
a b
3 4
4 5
select * from t1 where a not between 1 and 2 and b not between 3 and 4;
a b
4 5
drop table t1;
...@@ -107,3 +107,12 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3; ...@@ -107,3 +107,12 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3;
# #
select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3; select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3;
#
# Bug#6726: NOT BETWEEN parse failure
#
create table t1 (a int, b int);
insert into t1 values (1,2), (2,3), (3,4), (4,5);
select * from t1 where a not between 1 and 2;
select * from t1 where a not between 1 and 2 and b not between 3 and 4;
drop table t1;
...@@ -4032,14 +4032,15 @@ bool_test: ...@@ -4032,14 +4032,15 @@ bool_test:
bool_pri: bool_pri:
bool_pri IS NULL_SYM { $$= new Item_func_isnull($1); } bool_pri IS NULL_SYM { $$= new Item_func_isnull($1); }
| bool_pri IS not NULL_SYM { $$= new Item_func_isnotnull($1); } | bool_pri IS not NULL_SYM { $$= new Item_func_isnotnull($1); }
| predicate BETWEEN_SYM bit_expr AND_SYM bool_pri | bool_pri EQUAL_SYM predicate { $$= new Item_func_equal($1,$3); }
{ $$= new Item_func_between($1,$3,$5); } | bool_pri comp_op predicate %prec EQ
| predicate not BETWEEN_SYM bit_expr AND_SYM bool_pri { $$= (*$2)(0)->create($1,$3); }
{ $$= negate_expression(YYTHD, new Item_func_between($1,$4,$6)); } | bool_pri comp_op all_or_any in_subselect %prec EQ
{ $$= all_any_subquery_creator($1, $2, $3, $4); }
| predicate ; | predicate ;
predicate: predicate:
bit_expr IN_SYM '(' expr_list ')' bit_expr IN_SYM '(' expr_list ')'
{ $4->push_front($1); $$= new Item_func_in(*$4); } { $4->push_front($1); $$= new Item_func_in(*$4); }
| bit_expr not IN_SYM '(' expr_list ')' | bit_expr not IN_SYM '(' expr_list ')'
{ $5->push_front($1); $$= negate_expression(YYTHD, new Item_func_in(*$5)); } { $5->push_front($1); $$= negate_expression(YYTHD, new Item_func_in(*$5)); }
...@@ -4047,6 +4048,10 @@ predicate: ...@@ -4047,6 +4048,10 @@ predicate:
{ $$= new Item_in_subselect($1, $3); } { $$= new Item_in_subselect($1, $3); }
| bit_expr not IN_SYM in_subselect | bit_expr not IN_SYM in_subselect
{ $$= negate_expression(YYTHD, new Item_in_subselect($1, $4)); } { $$= negate_expression(YYTHD, new Item_in_subselect($1, $4)); }
| bit_expr BETWEEN_SYM bit_expr AND_SYM predicate
{ $$= new Item_func_between($1,$3,$5); }
| bit_expr not BETWEEN_SYM bit_expr AND_SYM predicate
{ $$= negate_expression(YYTHD, new Item_func_between($1,$4,$6)); }
| bit_expr SOUNDS_SYM LIKE bit_expr | bit_expr SOUNDS_SYM LIKE bit_expr
{ $$= new Item_func_eq(new Item_func_soundex($1), { $$= new Item_func_eq(new Item_func_soundex($1),
new Item_func_soundex($4)); } new Item_func_soundex($4)); }
...@@ -4057,11 +4062,6 @@ predicate: ...@@ -4057,11 +4062,6 @@ predicate:
| bit_expr REGEXP bit_expr { $$= new Item_func_regex($1,$3); } | bit_expr REGEXP bit_expr { $$= new Item_func_regex($1,$3); }
| bit_expr not REGEXP bit_expr | bit_expr not REGEXP bit_expr
{ $$= negate_expression(YYTHD, new Item_func_regex($1,$4)); } { $$= negate_expression(YYTHD, new Item_func_regex($1,$4)); }
| bit_expr EQUAL_SYM bit_expr { $$= new Item_func_equal($1,$3); }
| bit_expr comp_op bit_expr %prec EQ
{ $$= (*$2)(0)->create($1,$3); }
| bit_expr comp_op all_or_any in_subselect %prec EQ
{ $$= all_any_subquery_creator($1, $2, $3, $4); }
| bit_expr ; | bit_expr ;
bit_expr: bit_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