summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-11-23 14:10:44 +0100
committerSergei Golubchik <serg@mariadb.org>2020-12-10 08:45:20 +0100
commit493c7d34cb2c5c0bc8c495d1dd7b2394c62036ad (patch)
tree7d33065a4492f3c371571916f61c389feda5de33
parentf6e91552f00daf7f87bffd3a64082dc5673af95c (diff)
downloadmariadb-git-493c7d34cb2c5c0bc8c495d1dd7b2394c62036ad.tar.gz
MDEV-24194 View definition corruption
fix parsing of "1 IS NULL = 2"
-rw-r--r--mysql-test/r/precedence.result4
-rw-r--r--mysql-test/t/precedence.test3
-rw-r--r--sql/sql_yacc.yy16
3 files changed, 13 insertions, 10 deletions
diff --git a/mysql-test/r/precedence.result b/mysql-test/r/precedence.result
index 986af631346..65c32ba2b04 100644
--- a/mysql-test/r/precedence.result
+++ b/mysql-test/r/precedence.result
@@ -8017,4 +8017,8 @@ create or replace view v1 as select 1 IS TRUE IS FALSE, 2 IS FALSE IS UNKNOWN, 3
Select view_definition from information_schema.views where table_schema='test' and table_name='v1';
view_definition
select 1 is true is false AS `1 IS TRUE IS FALSE`,/*always not null*/ 1 is null AS `2 IS FALSE IS UNKNOWN`,/*always not null*/ 1 is null AS `3 IS UNKNOWN IS NULL`,/*always not null*/ 1 is null is true AS `4 IS NULL IS TRUE`
+create or replace view v1 as select 2 IS TRUE = 3, 2 IS FALSE = 3, 2 IS UNKNOWN = 3, 2 IS NULL = 3, ISNULL(2) = 1;
+Select view_definition from information_schema.views where table_schema='test' and table_name='v1';
+view_definition
+select 2 is true = 3 AS `2 IS TRUE = 3`,2 is false = 3 AS `2 IS FALSE = 3`,/*always not null*/ 1 is null = 3 AS `2 IS UNKNOWN = 3`,/*always not null*/ 1 is null = 3 AS `2 IS NULL = 3`,/*always not null*/ 1 is null = 1 AS `ISNULL(2) = 1`
drop view v1;
diff --git a/mysql-test/t/precedence.test b/mysql-test/t/precedence.test
index ad367c23603..cd7cee4f911 100644
--- a/mysql-test/t/precedence.test
+++ b/mysql-test/t/precedence.test
@@ -4785,4 +4785,7 @@ Select view_definition from information_schema.views where table_schema='test' a
create or replace view v1 as select 1 IS TRUE IS FALSE, 2 IS FALSE IS UNKNOWN, 3 IS UNKNOWN IS NULL, 4 IS NULL IS TRUE;
Select view_definition from information_schema.views where table_schema='test' and table_name='v1';
+create or replace view v1 as select 2 IS TRUE = 3, 2 IS FALSE = 3, 2 IS UNKNOWN = 3, 2 IS NULL = 3, ISNULL(2) = 1;
+Select view_definition from information_schema.views where table_schema='test' and table_name='v1';
+
drop view v1;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 2eabc4f0a6d..1f37296842c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1030,10 +1030,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
- Currently there are 105 shift/reduce conflicts.
+ Currently there are 98 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
-%expect 105
+%expect 98
/*
Comments for TOKENS.
@@ -1836,7 +1836,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <item>
literal text_literal insert_ident order_ident temporal_literal
simple_ident expr opt_expr opt_else sum_expr in_sum_expr
- variable variable_aux bool_pri
+ variable variable_aux
predicate bit_expr parenthesized_expr
table_wild simple_expr column_default_non_parenthesized_expr udf_expr
expr_or_default set_expr_or_default
@@ -8972,23 +8972,19 @@ expr:
if ($$ == NULL)
MYSQL_YYABORT;
}
- | bool_pri
- ;
-
-bool_pri:
- bool_pri EQUAL_SYM predicate %prec EQUAL_SYM
+ | expr EQUAL_SYM predicate %prec EQUAL_SYM
{
$$= new (thd->mem_root) Item_func_equal(thd, $1, $3);
if ($$ == NULL)
MYSQL_YYABORT;
}
- | bool_pri comp_op predicate %prec '='
+ | expr comp_op predicate %prec '='
{
$$= (*$2)(0)->create(thd, $1, $3);
if ($$ == NULL)
MYSQL_YYABORT;
}
- | bool_pri comp_op all_or_any '(' subselect ')' %prec '='
+ | expr comp_op all_or_any '(' subselect ')' %prec '='
{
$$= all_any_subquery_creator(thd, $1, $2, $3, $5);
if ($$ == NULL)