Resolve one shift/reduce conflict introduced with the push of the fix

for bug#16425: Events: no DEFINER clause.  The problem was that there
were two rules

  ALTER view_algorithm_opt definer ... VIEW ...
  ALTER definer EVENT ...

so when there was 'ALTER definer' in the input it was unclear if empty
view_algorithm_opt should be executed or not.

We solve this by introducing three distinct rules

  ALTER view_algorithm definer ... VIEW ...
  ALTER definer ... VIEW ...
  ALTER definer EVENT ...

that remove the ambiguity.
parent b641bd7b
......@@ -3283,3 +3283,38 @@ DROP TABLE `t-2`;
DROP VIEW `v-2`;
DROP DATABASE `d-1`;
USE test;
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT);
CREATE VIEW v1 AS SELECT * FROM t1;
ALTER VIEW v1 AS SELECT * FROM t1;
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1;
Warnings:
Note 1449 There is no 'no_such'@'user_1' registered
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
Warnings:
Note 1449 There is no 'no_such'@'user_1' registered
ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
Warnings:
Note 1449 There is no 'no_such'@'user_1' registered
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
Warnings:
Note 1449 There is no 'no_such'@'user_1' registered
ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1;
Warnings:
Note 1449 There is no 'no_such'@'user_2' registered
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`no_such`@`user_2` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
Warnings:
Note 1449 There is no 'no_such'@'user_2' registered
DROP VIEW v1;
DROP TABLE t1;
End of 5.1 tests.
......@@ -3175,3 +3175,30 @@ DROP TABLE `t-2`;
DROP VIEW `v-2`;
DROP DATABASE `d-1`;
USE test;
#
# Test that ALTER VIEW accepts DEFINER and ALGORITHM, see bug#16425.
#
--disable_warnings
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (i INT);
CREATE VIEW v1 AS SELECT * FROM t1;
ALTER VIEW v1 AS SELECT * FROM t1;
SHOW CREATE VIEW v1;
ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1;
SHOW CREATE VIEW v1;
ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
SHOW CREATE VIEW v1;
ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1;
SHOW CREATE VIEW v1;
DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.1 tests.
......@@ -492,7 +492,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
Currently there is 287 shift/reduce conflict. We should not introduce
new conflicts any more.
*/
%expect 287
%expect 286
/*
Comments for TOKENS.
......@@ -1246,7 +1246,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
statement sp_suid
sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic xa
load_data opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
definer view_replace_or_algorithm view_replace view_algorithm_opt
definer view_replace_or_algorithm view_replace
view_algorithm view_or_trigger_or_sp_or_event
view_or_trigger_or_sp_or_event_tail
view_suid view_tail view_list_opt view_list view_select
......@@ -5154,18 +5154,25 @@ alter:
lex->sql_command= SQLCOM_ALTER_FUNCTION;
lex->spname= $3;
}
| ALTER view_algorithm_opt definer view_suid
VIEW_SYM table_ident
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
lex->sql_command= SQLCOM_CREATE_VIEW;
lex->create_view_mode= VIEW_ALTER;
/* first table in list is target VIEW name */
lex->select_lex.add_table_to_list(thd, $6, NULL, TL_OPTION_UPDATING);
}
view_list_opt AS view_select view_check_option
{}
| ALTER view_algorithm definer
{
Lex->create_view_mode= VIEW_ALTER;
}
view_tail
{}
| ALTER definer
/*
We have two separate rules for ALTER VIEW rather that
optional view_algorithm above, to resolve the ambiguity
with the ALTER EVENT below.
*/
{
LEX *lex= Lex;
lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED;
lex->create_view_mode= VIEW_ALTER;
}
view_tail
{}
| ALTER definer EVENT_SYM sp_name
/*
BE CAREFUL when you add a new rule to update the block where
......@@ -11298,13 +11305,6 @@ view_algorithm:
{ Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; }
;
view_algorithm_opt:
/* empty */
{ Lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; }
| view_algorithm
{}
;
view_suid:
/* empty */
{ Lex->create_view_suid= VIEW_SUID_DEFAULT; }
......
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