Commit 493c7d34 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-24194 View definition corruption

fix parsing of "1 IS NULL = 2"
parent f6e91552
...@@ -8017,4 +8017,8 @@ create or replace view v1 as select 1 IS TRUE IS FALSE, 2 IS FALSE IS UNKNOWN, 3 ...@@ -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'; Select view_definition from information_schema.views where table_schema='test' and table_name='v1';
view_definition 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` 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; drop view v1;
...@@ -4785,4 +4785,7 @@ Select view_definition from information_schema.views where table_schema='test' a ...@@ -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; 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'; 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; drop view v1;
...@@ -1030,10 +1030,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1030,10 +1030,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd } %parse-param { THD *thd }
%lex-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. We should not introduce new conflicts any more.
*/ */
%expect 105 %expect 98
/* /*
Comments for TOKENS. Comments for TOKENS.
...@@ -1836,7 +1836,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1836,7 +1836,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <item> %type <item>
literal text_literal insert_ident order_ident temporal_literal literal text_literal insert_ident order_ident temporal_literal
simple_ident expr opt_expr opt_else sum_expr in_sum_expr 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 predicate bit_expr parenthesized_expr
table_wild simple_expr column_default_non_parenthesized_expr udf_expr table_wild simple_expr column_default_non_parenthesized_expr udf_expr
expr_or_default set_expr_or_default expr_or_default set_expr_or_default
...@@ -8972,23 +8972,19 @@ expr: ...@@ -8972,23 +8972,19 @@ expr:
if ($$ == NULL) if ($$ == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
| bool_pri | expr EQUAL_SYM predicate %prec EQUAL_SYM
;
bool_pri:
bool_pri EQUAL_SYM predicate %prec EQUAL_SYM
{ {
$$= new (thd->mem_root) Item_func_equal(thd, $1, $3); $$= new (thd->mem_root) Item_func_equal(thd, $1, $3);
if ($$ == NULL) if ($$ == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
| bool_pri comp_op predicate %prec '=' | expr comp_op predicate %prec '='
{ {
$$= (*$2)(0)->create(thd, $1, $3); $$= (*$2)(0)->create(thd, $1, $3);
if ($$ == NULL) if ($$ == NULL)
MYSQL_YYABORT; 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); $$= all_any_subquery_creator(thd, $1, $2, $3, $5);
if ($$ == NULL) if ($$ == 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