diff options
| author | Sergei Golubchik <serg@mariadb.org> | 2017-12-16 21:33:43 +0100 |
|---|---|---|
| committer | Aleksey Midenkov <midenok@gmail.com> | 2017-12-19 16:35:38 +0300 |
| commit | 617e108fb6e2bc24e5c9badb94e7d8eaa65d8851 (patch) | |
| tree | b7c0bc622483a2abd3b642e194609da625e8d52d /sql | |
| parent | ee68d019d1e059fa0fcf9e63bd97176dd46582c2 (diff) | |
| download | mariadb-git-617e108fb6e2bc24e5c9badb94e7d8eaa65d8851.tar.gz | |
s/TRUNCATE ... TO/DELETE HISTORY FROM ... BEFORE/
Diffstat (limited to 'sql')
| -rw-r--r-- | sql/sql_parse.cc | 16 | ||||
| -rw-r--r-- | sql/sql_truncate.cc | 7 | ||||
| -rw-r--r-- | sql/sql_yacc.yy | 38 |
3 files changed, 34 insertions, 27 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3c245eea92b..01b77f49b7d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -9409,10 +9409,18 @@ bool update_precheck(THD *thd, TABLE_LIST *tables) bool delete_precheck(THD *thd, TABLE_LIST *tables) { DBUG_ENTER("delete_precheck"); - if (check_one_table_access(thd, DELETE_ACL, tables)) - DBUG_RETURN(TRUE); - /* Set privilege for the WHERE clause */ - tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege); + if (tables->vers_conditions) + { + if (check_one_table_access(thd, DELETE_HISTORY_ACL, tables)) + DBUG_RETURN(TRUE); + } + else + { + if (check_one_table_access(thd, DELETE_ACL, tables)) + DBUG_RETURN(TRUE); + /* Set privilege for the WHERE clause */ + tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege); + } DBUG_RETURN(FALSE); } diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 9286143e259..bd3f1fdc111 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -496,13 +496,6 @@ bool Sql_cmd_truncate_table::execute(THD *thd) TABLE_LIST *table= thd->lex->select_lex.table_list.first; DBUG_ENTER("Sql_cmd_truncate_table::execute"); - if (table->vers_conditions) - { - if (check_one_table_access(thd, DELETE_HISTORY_ACL, table)) - DBUG_RETURN(res); - DBUG_RETURN(mysql_delete(thd, table, NULL, NULL, -1, 0, NULL)); - } - if (check_one_table_access(thd, DROP_ACL, table)) DBUG_RETURN(res); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f68ce213a2c..dfc82a70784 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -892,10 +892,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %parse-param { THD *thd } %lex-param { THD *thd } /* - Currently there are 122 shift/reduce conflicts. + Currently there are 123 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 122 +%expect 123 /* Comments for TOKENS. @@ -13404,10 +13404,20 @@ delete: lex->ignore= 0; lex->select_lex.init_order(); } - opt_delete_options single_multi + delete_part2 + ; + +delete_part2: + opt_delete_options single_multi {} + | HISTORY_SYM delete_single_table + BEFORE_SYM SYSTEM_TIME_SYM opt_trans_or_timestamp simple_expr + { + Lex->vers_conditions.init(SYSTEM_TIME_BEFORE, $5, $6); + Lex->last_table()->vers_conditions= Lex->vers_conditions; + } ; -single_multi: +delete_single_table: FROM table_ident opt_use_partition { if (!Select->add_table_to_list(thd, $2, NULL, TL_OPTION_UPDATING, @@ -13419,8 +13429,13 @@ single_multi: YYPS->m_lock_type= TL_READ_DEFAULT; YYPS->m_mdl_type= MDL_SHARED_READ; } - opt_where_clause opt_order_clause - delete_limit_clause {} + ; + +single_multi: + delete_single_table + opt_where_clause + opt_order_clause + delete_limit_clause opt_select_expressions {} | table_wild_list { @@ -13501,15 +13516,6 @@ opt_delete_option: | IGNORE_SYM { Lex->ignore= 1; } ; -truncate_end: - opt_lock_wait_timeout - | TO_SYM SYSTEM_TIME_SYM opt_trans_or_timestamp simple_expr - { - Lex->vers_conditions.init(SYSTEM_TIME_BEFORE, $3, $4); - Lex->last_table()->vers_conditions= Lex->vers_conditions; - } - ; - truncate: TRUNCATE_SYM { @@ -13522,7 +13528,7 @@ truncate: YYPS->m_lock_type= TL_WRITE; YYPS->m_mdl_type= MDL_EXCLUSIVE; } - opt_table_sym table_name truncate_end + opt_table_sym table_name opt_lock_wait_timeout { LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_sql_cmd); |
