Commit eba09918 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-30151 parse error 1=2 not between/in

the parser couldn't parse `1=2 not between 3 and 5`
after `2` it expected only NOT2_SYM, but not NOT_SYM
(visible from the sql_yacc.output file), which resulted in
Syntax error ... near 'not between 3 and 4'

The parser was confused by a rather low NOT_SYM precedence and
%prec BETWEEN_SYM didn't resolve this confusion.

As a fix, let's remove any %precedence from NOT_SYM and
specify %prec explicitly in the only place where it matters for NOT_SYM.

In other places, such as for NOT BETWEEN, NOT_SYM won't have a
precedence, so bison won't be confused about it.
parent f8adc47b
...@@ -1866,4 +1866,15 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -1866,4 +1866,15 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
EXECUTE IMMEDIATE 'CREATE PROCEDURE p() UPDATE t SET c=\'\'"abc'; EXECUTE IMMEDIATE 'CREATE PROCEDURE p() UPDATE t SET c=\'\'"abc';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"abc' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"abc' at line 1
SET @@sql_mode=@save_sql_mode; SET @@sql_mode=@save_sql_mode;
#
# MDEV-30151 parse error 1=2 not between/in
#
select 1=2 not in (3,4);
1=2 not in (3,4)
1
select 1=2 not between 3 and 4;
1=2 not between 3 and 4
1
#
# End of 10.3 tests # End of 10.3 tests
#
...@@ -1673,4 +1673,12 @@ EXECUTE IMMEDIATE 'CREATE PROCEDURE p() UPDATE t SET c=\'\'"abc'; ...@@ -1673,4 +1673,12 @@ EXECUTE IMMEDIATE 'CREATE PROCEDURE p() UPDATE t SET c=\'\'"abc';
SET @@sql_mode=@save_sql_mode; SET @@sql_mode=@save_sql_mode;
--echo #
--echo # MDEV-30151 parse error 1=2 not between/in
--echo #
select 1=2 not in (3,4);
select 1=2 not between 3 and 4;
--echo #
--echo # End of 10.3 tests --echo # End of 10.3 tests
--echo #
...@@ -899,7 +899,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -899,7 +899,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
/* /*
We should not introduce any further shift/reduce conflicts. We should not introduce any further shift/reduce conflicts.
*/ */
%expect 85 %expect 96
/* /*
Comments for TOKENS. Comments for TOKENS.
...@@ -1687,7 +1687,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -1687,7 +1687,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%left PREC_BELOW_NOT %left PREC_BELOW_NOT
%nonassoc NOT_SYM %nonassoc LOW_PRIORITY_NOT
%left '=' EQUAL_SYM GE '>' LE '<' NE %left '=' EQUAL_SYM GE '>' LE '<' NE
%nonassoc IS %nonassoc IS
%right BETWEEN_SYM %right BETWEEN_SYM
...@@ -9840,7 +9840,7 @@ expr: ...@@ -9840,7 +9840,7 @@ expr:
MYSQL_YYABORT; MYSQL_YYABORT;
} }
} }
| NOT_SYM expr %prec NOT_SYM | NOT_SYM expr %prec LOW_PRIORITY_NOT
{ {
$$= negate_expression(thd, $2); $$= negate_expression(thd, $2);
if (unlikely($$ == NULL)) if (unlikely($$ == NULL))
......
...@@ -293,7 +293,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -293,7 +293,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
/* /*
We should not introduce any further shift/reduce conflicts. We should not introduce any further shift/reduce conflicts.
*/ */
%expect 87 %expect 98
/* /*
Comments for TOKENS. Comments for TOKENS.
...@@ -1081,7 +1081,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -1081,7 +1081,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%left PREC_BELOW_NOT %left PREC_BELOW_NOT
%nonassoc NOT_SYM %nonassoc LOW_PRIORITY_NOT
%left '=' EQUAL_SYM GE '>' LE '<' NE %left '=' EQUAL_SYM GE '>' LE '<' NE
%nonassoc IS %nonassoc IS
%right BETWEEN_SYM %right BETWEEN_SYM
...@@ -9797,7 +9797,7 @@ expr: ...@@ -9797,7 +9797,7 @@ expr:
MYSQL_YYABORT; MYSQL_YYABORT;
} }
} }
| NOT_SYM expr %prec NOT_SYM | NOT_SYM expr %prec LOW_PRIORITY_NOT
{ {
$$= negate_expression(thd, $2); $$= negate_expression(thd, $2);
if (unlikely($$ == NULL)) if (unlikely($$ == NULL))
......
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