summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-12-05 00:21:28 +0100
committerSergei Golubchik <serg@mariadb.org>2023-01-02 00:04:03 +0100
commiteba099184e1f6704894694ea41f97f216eae5f21 (patch)
tree0c445eea7d8c518d05d2f3496dcf2f58d487aa27
parentf8adc47b698ef8d347fd36bffff90b237491eceb (diff)
downloadmariadb-git-eba099184e1f6704894694ea41f97f216eae5f21.tar.gz
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.
-rw-r--r--mysql-test/main/parser.result11
-rw-r--r--mysql-test/main/parser.test8
-rw-r--r--sql/sql_yacc.yy6
-rw-r--r--sql/sql_yacc_ora.yy6
4 files changed, 25 insertions, 6 deletions
diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result
index 0bb4e82c8b8..f44478727ae 100644
--- a/mysql-test/main/parser.result
+++ b/mysql-test/main/parser.result
@@ -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';
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;
+#
+# 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
+#
diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test
index 9df18c50ee3..cfe4f9d6f53 100644
--- a/mysql-test/main/parser.test
+++ b/mysql-test/main/parser.test
@@ -1673,4 +1673,12 @@ EXECUTE IMMEDIATE 'CREATE PROCEDURE p() UPDATE t SET c=\'\'"abc';
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 #
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 1f6485dac6a..73922ceb4f4 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -899,7 +899,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
/*
We should not introduce any further shift/reduce conflicts.
*/
-%expect 85
+%expect 96
/*
Comments for TOKENS.
@@ -1687,7 +1687,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%left PREC_BELOW_NOT
-%nonassoc NOT_SYM
+%nonassoc LOW_PRIORITY_NOT
%left '=' EQUAL_SYM GE '>' LE '<' NE
%nonassoc IS
%right BETWEEN_SYM
@@ -9840,7 +9840,7 @@ expr:
MYSQL_YYABORT;
}
}
- | NOT_SYM expr %prec NOT_SYM
+ | NOT_SYM expr %prec LOW_PRIORITY_NOT
{
$$= negate_expression(thd, $2);
if (unlikely($$ == NULL))
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index ec8e4f4c946..3a1b0c0e077 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -293,7 +293,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
/*
We should not introduce any further shift/reduce conflicts.
*/
-%expect 87
+%expect 98
/*
Comments for TOKENS.
@@ -1081,7 +1081,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%left PREC_BELOW_NOT
-%nonassoc NOT_SYM
+%nonassoc LOW_PRIORITY_NOT
%left '=' EQUAL_SYM GE '>' LE '<' NE
%nonassoc IS
%right BETWEEN_SYM
@@ -9797,7 +9797,7 @@ expr:
MYSQL_YYABORT;
}
}
- | NOT_SYM expr %prec NOT_SYM
+ | NOT_SYM expr %prec LOW_PRIORITY_NOT
{
$$= negate_expression(thd, $2);
if (unlikely($$ == NULL))