From f7aeb6f9fd473d856585ffa068064067f02cbd94 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Sep 2005 10:53:09 +0300 Subject: part 1 (ver 2, postreview fix) of WL#2787 view definer information syntax/storage/replication fixed SOURCE field of .frm mysql-test/r/func_in.result: definer information added to CREATE VIEW mysql-test/r/lowercase_view.result: definer information added to CREATE VIEW mysql-test/r/mysqldump.result: definer information added to CREATE VIEW mysql-test/r/rpl_view.result: check log of queries mysql-test/r/skip_grants.result: --skip-grants do not allow use user information mysql-test/r/sql_mode.result: definer information added to CREATE VIEW mysql-test/r/temp_table.result: definer information added to CREATE VIEW mysql-test/r/view.result: definer information added to CREATE VIEW test of storing/restoring definer information mysql-test/r/view_grant.result: test of grant check of definer information definer information added to CREATE VIEW mysql-test/t/rpl_view.test: check log of queries mysql-test/t/skip_grants.test: --skip-grants do not allow use user information mysql-test/t/view.test: test of storing/restoring definer information mysql-test/t/view_grant.test: test of grant check of definer information sql/mysql_priv.h: CREATE/ALTER VIEW print support set current user as definer procedure sql/share/errmsg.txt: new errors/warnings sql/sql_acl.cc: make find_acl_user public to allow to check user sql/sql_acl.h: make find_acl_user public to allow to check user sql/sql_lex.h: storing definer information sql/sql_parse.cc: send CREATE/ALTER VIEW for replication with full list of options set current user as definer procedure sql/sql_show.cc: new CREATE VIEW options printed sql/sql_view.cc: check of definer clause changes in .frm file definer information storage support now we store only original SELECT in SOURCE field of .frm sql/sql_yacc.yy: definer information sintax support getting SOURCE field information for .frm sql/table.h: definer information storage --- sql/sql_yacc.yy | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 7 deletions(-) (limited to 'sql/sql_yacc.yy') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a39ee7c82aa..8713e47e20a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -823,10 +823,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); precision subselect_start opt_and charset subselect_end select_var_list select_var_list_init help opt_len opt_extended_describe - prepare prepare_src execute deallocate + prepare prepare_src execute deallocate statement sp_suid opt_view_list view_list or_replace algorithm 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 + view_user view_suid END_OF_INPUT %type call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt @@ -1254,16 +1255,16 @@ create: YYTHD->client_capabilities |= CLIENT_MULTI_QUERIES; sp->restore_thd_mem_root(YYTHD); } - | CREATE or_replace algorithm VIEW_SYM table_ident + | CREATE or_replace algorithm view_user view_suid VIEW_SYM table_ident { THD *thd= YYTHD; LEX *lex= thd->lex; lex->sql_command= SQLCOM_CREATE_VIEW; /* first table in list is target VIEW name */ - if (!lex->select_lex.add_table_to_list(thd, $5, NULL, 0)) + if (!lex->select_lex.add_table_to_list(thd, $7, NULL, 0)) YYABORT; } - opt_view_list AS select_init check_option + opt_view_list AS select_view_init check_option {} | CREATE TRIGGER_SYM sp_name trg_action_time trg_event ON table_ident FOR_SYM EACH_SYM ROW_SYM @@ -3418,16 +3419,16 @@ alter: lex->sql_command= SQLCOM_ALTER_FUNCTION; lex->spname= $3; } - | ALTER algorithm VIEW_SYM table_ident + | ALTER algorithm view_user 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, $4, NULL, 0); + lex->select_lex.add_table_to_list(thd, $6, NULL, 0); } - opt_view_list AS select_init check_option + opt_view_list AS select_view_init check_option {} ; @@ -3995,6 +3996,18 @@ select_init: | '(' select_paren ')' union_opt; +select_view_init: + SELECT_SYM remember_name select_init2 + { + Lex->create_view_select_start= $2; + } + | + '(' remember_name select_paren ')' union_opt + { + Lex->create_view_select_start= $2; + } + ; + select_paren: SELECT_SYM select_part2 { @@ -8885,6 +8898,53 @@ algorithm: | ALGORITHM_SYM EQ TEMPTABLE_SYM { Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; } ; + +view_user: + /* empty */ + { + THD *thd= YYTHD; + if (!(thd->lex->create_view_definer= + (LEX_USER*) thd->alloc(sizeof(st_lex_user)))) + YYABORT; + if (default_view_definer(thd, thd->lex->create_view_definer)) + YYABORT; + } + | CURRENT_USER optional_braces + { + THD *thd= YYTHD; + if (!(thd->lex->create_view_definer= + (LEX_USER*) thd->alloc(sizeof(st_lex_user)))) + YYABORT; + if (default_view_definer(thd, thd->lex->create_view_definer)) + YYABORT; + } + | DEFINER_SYM EQ ident_or_text '@' ident_or_text + { + THD *thd= YYTHD; + st_lex_user *view_user; + if (!(thd->lex->create_view_definer= view_user= + (LEX_USER*) thd->alloc(sizeof(st_lex_user)))) + YYABORT; + view_user->user = $3; view_user->host=$5; + if (strchr(view_user->host.str, wild_many) || + strchr(view_user->host.str, wild_one)) + { + my_error(ER_NO_VIEW_USER, MYF(0)); + YYABORT; + } + } + ; + +view_suid: + /* empty */ + { Lex->create_view_suid= TRUE; } + | + SQL_SYM SECURITY_SYM DEFINER_SYM + { Lex->create_view_suid= TRUE; } + | SQL_SYM SECURITY_SYM INVOKER_SYM + { Lex->create_view_suid= FALSE; } + ; + check_option: /* empty */ { Lex->create_view_check= VIEW_CHECK_NONE; } -- cgit v1.2.1