diff options
author | Mikael Ronstrom <mikael@mysql.com> | 2009-09-10 11:18:50 +0200 |
---|---|---|
committer | Mikael Ronstrom <mikael@mysql.com> | 2009-09-10 11:18:50 +0200 |
commit | ec5b25954376265d187c57984d0416c50d0a1694 (patch) | |
tree | 1592740eb9d853816e655e3e0d34c5be7a6cca33 | |
parent | d0d52e9f11ab7bad11d34d207139a26f26dd362c (diff) | |
parent | 52d9a4d3d660d9b90e6523eb05a1be4cd9f0607c (diff) | |
download | mariadb-git-ec5b25954376265d187c57984d0416c50d0a1694.tar.gz |
Automerge
-rw-r--r-- | sql/ha_partition.cc | 58 | ||||
-rw-r--r-- | sql/ha_partition.h | 5 | ||||
-rw-r--r-- | sql/sql_partition.cc | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 1 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 83 |
5 files changed, 127 insertions, 22 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 83a2a3064d5..79e3247d040 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -847,9 +847,12 @@ int ha_partition::rename_partitions(const char *path) #define ANALYZE_PARTS 2 #define CHECK_PARTS 3 #define REPAIR_PARTS 4 +#define ASSIGN_KEYCACHE_PARTS 5 +#define PRELOAD_KEYS_PARTS 6 static const char *opt_op_name[]= {NULL, - "optimize", "analyze", "check", "repair" }; + "optimize", "analyze", "check", "repair", + "assign_to_keycache", "preload_keys"}; /* Optimize table @@ -934,7 +937,44 @@ int ha_partition::repair(THD *thd, HA_CHECK_OPT *check_opt) DBUG_RETURN(handle_opt_partitions(thd, check_opt, REPAIR_PARTS)); } +/** + Assign to keycache + + @param thd Thread object + @param check_opt Check/analyze/repair/optimize options + + @return + @retval >0 Error + @retval 0 Success +*/ + +int ha_partition::assign_to_keycache(THD *thd, HA_CHECK_OPT *check_opt) +{ + DBUG_ENTER("ha_partition::assign_to_keycache"); + + DBUG_RETURN(handle_opt_partitions(thd, check_opt, ASSIGN_KEYCACHE_PARTS)); +} + + +/** + Preload to keycache + @param thd Thread object + @param check_opt Check/analyze/repair/optimize options + + @return + @retval >0 Error + @retval 0 Success +*/ + +int ha_partition::preload_keys(THD *thd, HA_CHECK_OPT *check_opt) +{ + DBUG_ENTER("ha_partition::preload_keys"); + + DBUG_RETURN(handle_opt_partitions(thd, check_opt, PRELOAD_KEYS_PARTS)); +} + + /* Handle optimize/analyze/check/repair of one partition @@ -965,6 +1005,10 @@ static int handle_opt_part(THD *thd, HA_CHECK_OPT *check_opt, error= file->ha_check(thd, check_opt); else if (flag == REPAIR_PARTS) error= file->ha_repair(thd, check_opt); + else if (flag == ASSIGN_KEYCACHE_PARTS) + error= file->assign_to_keycache(thd, check_opt); + else if (flag == PRELOAD_KEYS_PARTS) + error= file->preload_keys(thd, check_opt); else { DBUG_ASSERT(FALSE); @@ -1094,6 +1138,12 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, "Subpartition %s returned error", sub_elem->partition_name); } + /* reset part_state for the remaining partitions */ + do + { + if (part_elem->part_state == PART_ADMIN) + part_elem->part_state= PART_NORMAL; + } while (part_elem= part_it++); DBUG_RETURN(error); } } while (++j < no_subparts); @@ -1120,6 +1170,12 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, opt_op_name[flag], "Partition %s returned error", part_elem->partition_name); } + /* reset part_state for the remaining partitions */ + do + { + if (part_elem->part_state == PART_ADMIN) + part_elem->part_state= PART_NORMAL; + } while (part_elem= part_it++); DBUG_RETURN(error); } } diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 8a81a759e2a..2f0ce6e7910 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1061,12 +1061,13 @@ public: virtual int backup(TD* thd, HA_CHECK_OPT *check_opt); virtual int restore(THD* thd, HA_CHECK_OPT *check_opt); - virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt); - virtual int preload_keys(THD *thd, HA_CHECK_OPT *check_opt); virtual int dump(THD* thd, int fd = -1); virtual int net_read_dump(NET* net); virtual uint checksum() const; */ + /* Enabled keycache for performance reasons, WL#4571 */ + virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt); + virtual int preload_keys(THD* thd, HA_CHECK_OPT* check_opt); /* ------------------------------------------------------------------------- diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 2fbdde9c4aa..53fc34d374e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4151,7 +4151,7 @@ uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info, /* Mark the partition. I.e mark the partition as a partition to be "changed" by - analyzing/optimizing/rebuilding/checking/repairing + analyzing/optimizing/rebuilding/checking/repairing/... */ no_parts_found++; part_elem->part_state= part_state; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4a1050b897d..ff4faa494e9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4521,6 +4521,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, /* Set up which partitions that should be processed if ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION .. + CACHE INDEX/LOAD INDEX for specified partitions */ Alter_info *alter_info= &lex->alter_info; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 72ec879a7c8..1cd69889ddc 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1261,7 +1261,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); slave master_def master_defs master_file_def slave_until_opts repair restore backup analyze check start checksum field_list field_list_item field_spec kill column_def key_def - keycache_list assign_to_keycache preload_list preload_keys + keycache_list keycache_list_or_parts assign_to_keycache + assign_to_keycache_parts + preload_list preload_list_or_parts preload_keys preload_keys_parts select_item_list select_item values_list no_braces opt_limit_clause delete_limit_clause fields opt_values values procedure_list procedure_list2 procedure_item @@ -3747,17 +3749,9 @@ opt_partitioning: ; partitioning: - PARTITION_SYM + PARTITION_SYM have_partitioning { -#ifdef WITH_PARTITION_STORAGE_ENGINE LEX *lex= Lex; - LEX_STRING partition_name={C_STRING_WITH_LEN("partition")}; - if (!plugin_is_ready(&partition_name, MYSQL_STORAGE_ENGINE_PLUGIN)) - { - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), - "--skip-partition"); - MYSQL_YYABORT; - } lex->part_info= new partition_info(); if (!lex->part_info) { @@ -3768,14 +3762,27 @@ partitioning: { lex->alter_info.flags|= ALTER_PARTITION; } + } + partition + ; + +have_partitioning: + /* empty */ + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + LEX_STRING partition_name={C_STRING_WITH_LEN("partition")}; + if (!plugin_is_ready(&partition_name, MYSQL_STORAGE_ENGINE_PLUGIN)) + { + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), + "--skip-partition"); + MYSQL_YYABORT; + } #else - my_error(ER_FEATURE_DISABLED, MYF(0), - "partitioning", "--with-partition"); + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), + "--skip-partition"); MYSQL_YYABORT; #endif - } - partition ; partition_entry: @@ -5437,7 +5444,6 @@ alter: if (!lex->select_lex.add_table_to_list(thd, $4, NULL, TL_OPTION_UPDATING)) MYSQL_YYABORT; - lex->alter_info.reset(); lex->col_list.empty(); lex->select_lex.init_order(); lex->select_lex.db= @@ -6303,14 +6309,23 @@ table_to_table: ; keycache: - CACHE_SYM INDEX_SYM keycache_list IN_SYM key_cache_name + CACHE_SYM INDEX_SYM + { + Lex->alter_info.reset(); + } + keycache_list_or_parts IN_SYM key_cache_name { LEX *lex=Lex; lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE; - lex->ident= $5; + lex->ident= $6; } ; +keycache_list_or_parts: + keycache_list + | assign_to_keycache_parts + ; + keycache_list: assign_to_keycache | keycache_list ',' assign_to_keycache @@ -6325,6 +6340,15 @@ assign_to_keycache: } ; +assign_to_keycache_parts: + table_ident adm_partition cache_keys_spec + { + if (!Select->add_table_to_list(YYTHD, $1, NULL, 0, TL_READ, + Select->pop_index_hints())) + MYSQL_YYABORT; + } + ; + key_cache_name: ident { $$= $1; } | DEFAULT { $$ = default_key_cache_base; } @@ -6335,11 +6359,17 @@ preload: { LEX *lex=Lex; lex->sql_command=SQLCOM_PRELOAD_KEYS; + lex->alter_info.reset(); } - preload_list + preload_list_or_parts {} ; +preload_list_or_parts: + preload_keys_parts + | preload_list + ; + preload_list: preload_keys | preload_list ',' preload_keys @@ -6354,6 +6384,23 @@ preload_keys: } ; +preload_keys_parts: + table_ident adm_partition cache_keys_spec opt_ignore_leaves + { + if (!Select->add_table_to_list(YYTHD, $1, NULL, $4, TL_READ, + Select->pop_index_hints())) + MYSQL_YYABORT; + } + ; + +adm_partition: + PARTITION_SYM have_partitioning + { + Lex->alter_info.flags|= ALTER_ADMIN_PARTITION; + } + '(' all_or_alt_part_name_list ')' + ; + cache_keys_spec: { Lex->select_lex.alloc_index_hints(YYTHD); |