diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/heap/hp_create.c | 6 | ||||
-rw-r--r-- | storage/heap/hp_rkey.c | 2 | ||||
-rw-r--r-- | storage/myisam/ft_parser.c | 8 | ||||
-rw-r--r-- | storage/myisam/ft_static.c | 18 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 92 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.h | 5 | ||||
-rw-r--r-- | storage/myisam/mi_check.c | 3 | ||||
-rw-r--r-- | storage/myisam/mi_static.c | 7 |
8 files changed, 101 insertions, 40 deletions
diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index 3f651d1573c..85e632e5aad 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -85,8 +85,6 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1; /* fall_through */ case HA_KEYTYPE_VARTEXT1: - if (!my_binary_compare(keyinfo->seg[j].charset)) - keyinfo->flag|= HA_END_SPACE_KEY; keyinfo->flag|= HA_VAR_LENGTH_KEY; length+= 2; /* Save number of bytes used to store length */ @@ -96,8 +94,6 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, /* Case-insensitiveness is handled in coll->hash_sort */ /* fall_through */ case HA_KEYTYPE_VARTEXT2: - if (!my_binary_compare(keyinfo->seg[j].charset)) - keyinfo->flag|= HA_END_SPACE_KEY; keyinfo->flag|= HA_VAR_LENGTH_KEY; length+= 2; /* Save number of bytes used to store length */ @@ -111,8 +107,6 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, default: break; } - if (keyinfo->seg[j].flag & HA_END_SPACE_ARE_EQUAL) - keyinfo->flag|= HA_END_SPACE_KEY; } keyinfo->length= length; length+= keyinfo->rb_tree.size_of_element + diff --git a/storage/heap/hp_rkey.c b/storage/heap/hp_rkey.c index 6eeac6acd7b..27d1114770e 100644 --- a/storage/heap/hp_rkey.c +++ b/storage/heap/hp_rkey.c @@ -63,7 +63,7 @@ int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key, info->update= 0; DBUG_RETURN(my_errno); } - if (!(keyinfo->flag & HA_NOSAME) || (keyinfo->flag & HA_END_SPACE_KEY)) + if (!(keyinfo->flag & HA_NOSAME)) memcpy(info->lastkey, key, (size_t) keyinfo->length); } memcpy(record, pos, (size_t) share->reclength); diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index 4cde3834ed7..8f5779b04ee 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -83,10 +83,10 @@ my_bool ft_boolean_check_syntax_string(const uchar *str) uint i, j; if (!str || - (strlen((char*) str)+1 != sizeof(ft_boolean_syntax)) || + (strlen((char*) str)+1 != sizeof(DEFAULT_FTB_SYNTAX)) || (str[0] != ' ' && str[1] != ' ')) return 1; - for (i=0; i<sizeof(ft_boolean_syntax); i++) + for (i=0; i<sizeof(DEFAULT_FTB_SYNTAX); i++) { /* limiting to 7-bit ascii only */ if ((unsigned char)(str[i]) > 127 || my_isalnum(default_charset_info, str[i])) @@ -127,7 +127,6 @@ uchar ft_get_word(CHARSET_INFO *cs, uchar **start, uchar *end, break; if (*doc == FTB_RQUOT && param->quot) { - param->quot= (char*) doc; *start=doc+1; param->type= FT_TOKEN_RIGHT_PAREN; goto ret; @@ -139,7 +138,7 @@ uchar ft_get_word(CHARSET_INFO *cs, uchar **start, uchar *end, /* param->prev=' '; */ *start=doc+1; if (*doc == FTB_LQUOT) - param->quot= (char*) *start; + param->quot= (char*) 1; param->type= (*doc == FTB_RBR ? FT_TOKEN_RIGHT_PAREN : FT_TOKEN_LEFT_PAREN); goto ret; } @@ -193,7 +192,6 @@ uchar ft_get_word(CHARSET_INFO *cs, uchar **start, uchar *end, if (param->quot) { *start= doc; - param->quot= (char*) doc; param->type= 3; /* FT_RBR */ goto ret; } diff --git a/storage/myisam/ft_static.c b/storage/myisam/ft_static.c index 16cbfa1dada..78fbc5781e9 100644 --- a/storage/myisam/ft_static.c +++ b/storage/myisam/ft_static.c @@ -17,12 +17,12 @@ #include "ftdefs.h" -ulong ft_min_word_len=4; -ulong ft_max_word_len=HA_FT_MAXCHARLEN; -ulong ft_query_expansion_limit=5; -char ft_boolean_syntax[]="+ -><()~*:\"\"&|"; +ulong ft_min_word_len= 4; +ulong ft_max_word_len= HA_FT_MAXCHARLEN; +ulong ft_query_expansion_limit= 5; +const char *ft_boolean_syntax= DEFAULT_FTB_SYNTAX; -const HA_KEYSEG ft_keysegs[FT_SEGS]={ +const HA_KEYSEG ft_keysegs[FT_SEGS]= { { 0, /* charset */ HA_FT_WLEN, /* start */ @@ -45,11 +45,11 @@ const HA_KEYSEG ft_keysegs[FT_SEGS]={ } }; -const struct _ft_vft _ft_vft_nlq = { +const struct _ft_vft _ft_vft_nlq= { ft_nlq_read_next, ft_nlq_find_relevance, ft_nlq_close_search, ft_nlq_get_relevance, ft_nlq_reinit_search }; -const struct _ft_vft _ft_vft_boolean = { +const struct _ft_vft _ft_vft_boolean= { ft_boolean_read_next, ft_boolean_find_relevance, ft_boolean_close_search, ft_boolean_get_relevance, ft_boolean_reinit_search }; @@ -68,8 +68,8 @@ FT_INFO *ft_init_search(uint flags, void *info, uint keynr, return res; } -const char *ft_stopword_file = 0; -const char *ft_precompiled_stopwords[] = { +const char *ft_stopword_file= 0; +const char *ft_precompiled_stopwords[]= { #ifdef COMPILE_STOPWORDS_IN diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 33678e9677b..d09eefda463 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -30,11 +30,12 @@ #include "myisamdef.h" #include "rt_index.h" -ulong myisam_recover_options= HA_RECOVER_NONE; +ulonglong myisam_recover_options; +static ulong opt_myisam_block_size; /* bits in myisam_recover_options */ const char *myisam_recover_names[] = -{ "DEFAULT", "BACKUP", "FORCE", "QUICK", NullS}; +{ "DEFAULT", "BACKUP", "FORCE", "QUICK", "OFF", NullS}; TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names)-1,"", myisam_recover_names, NULL}; @@ -44,6 +45,54 @@ TYPELIB myisam_stats_method_typelib= { array_elements(myisam_stats_method_names) - 1, "", myisam_stats_method_names, NULL}; +static MYSQL_SYSVAR_ULONG(block_size, opt_myisam_block_size, + PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_RQCMDARG, + "Block size to be used for MyISAM index pages", NULL, NULL, + MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, + MI_MIN_KEY_BLOCK_LENGTH); + +static MYSQL_SYSVAR_ULONG(data_pointer_size, myisam_data_pointer_size, + PLUGIN_VAR_RQCMDARG, "Default pointer size to be used for MyISAM tables", + NULL, NULL, 6, 2, 7, 1); + +#define MB (1024*1024) +static MYSQL_SYSVAR_ULONGLONG(max_sort_file_size, myisam_max_temp_length, + PLUGIN_VAR_RQCMDARG, "Don't use the fast sort index method to created " + "index if the temporary file would get bigger than this", NULL, NULL, + LONG_MAX/MB*MB, 0, MAX_FILE_SIZE, MB); + +static MYSQL_SYSVAR_SET(recover_options, myisam_recover_options, + PLUGIN_VAR_OPCMDARG|PLUGIN_VAR_READONLY, + "Syntax: myisam-recover-options[=option[,option...]], where option can be " + "DEFAULT, BACKUP, FORCE, QUICK, or OFF", + NULL, NULL, 0, &myisam_recover_typelib); + +static MYSQL_THDVAR_ULONG(repair_threads, PLUGIN_VAR_RQCMDARG, + "If larger than 1, when repairing a MyISAM table all indexes will be " + "created in parallel, with one thread per index. The value of 1 " + "disables parallel repair", NULL, NULL, + 1, 1, ULONG_MAX, 1); + +static MYSQL_THDVAR_ULONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG, + "The buffer that is allocated when sorting the index when doing " + "a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE", NULL, NULL, + 8192*1024, 4, ULONG_MAX, 1); + +static MYSQL_SYSVAR_BOOL(use_mmap, opt_myisam_use_mmap, PLUGIN_VAR_NOCMDARG, + "Use memory mapping for reading and writing MyISAM tables", NULL, NULL, FALSE); + +static MYSQL_SYSVAR_ULONGLONG(mmap_size, myisam_mmap_size, + PLUGIN_VAR_RQCMDARG|PLUGIN_VAR_READONLY, "Restricts the total memory " + "used for memory mapping of MySQL tables", NULL, NULL, + SIZE_T_MAX, MEMMAP_EXTRA_MARGIN, SIZE_T_MAX, 1); + +static MYSQL_THDVAR_ENUM(stats_method, PLUGIN_VAR_RQCMDARG, + "Specifies how MyISAM index statistics collection code should " + "treat NULLs. Possible values of name are NULLS_UNEQUAL (default " + "behavior for 4.1 and later), NULLS_EQUAL (emulate 4.0 behavior), " + "and NULLS_IGNORED", NULL, NULL, + MI_STATS_METHOD_NULLS_NOT_EQUAL, &myisam_stats_method_typelib); + #ifndef DBUG_OFF /** Causes the thread to wait in a spin lock for a query kill signal. @@ -751,7 +800,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) param.db_name= table->s->db.str; param.table_name= table->alias; param.testflag = check_opt->flags | T_CHECK | T_SILENT; - param.stats_method= (enum_mi_stats_method)thd->variables.myisam_stats_method; + param.stats_method= (enum_mi_stats_method)THDVAR(thd, stats_method); if (!(table->db_stat & HA_READ_ONLY)) param.testflag|= T_STATISTICS; @@ -843,7 +892,7 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt) param.testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS | T_DONT_CHECK_CHECKSUM); param.using_global_keycache = 1; - param.stats_method= (enum_mi_stats_method)thd->variables.myisam_stats_method; + param.stats_method= (enum_mi_stats_method)THDVAR(thd, stats_method); if (!(share->state.changed & STATE_NOT_ANALYZED)) return HA_ADMIN_ALREADY_DONE; @@ -875,7 +924,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) param.testflag= ((check_opt->flags & ~(T_EXTEND)) | T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM | (check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT)); - param.sort_buffer_length= check_opt->sort_buffer_size; + param.sort_buffer_length= THDVAR(thd, sort_buffer_size); start_records=file->state->records; while ((error=repair(thd,param,0)) && param.retry_repair) { @@ -921,7 +970,7 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt) param.op_name= "optimize"; param.testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE | T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX); - param.sort_buffer_length= check_opt->sort_buffer_size; + param.sort_buffer_length= THDVAR(thd, sort_buffer_size); if ((error= repair(thd,param,1)) && param.retry_repair) { sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying", @@ -979,7 +1028,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool do_optimize) local_testflag|= T_STATISTICS; param.testflag|= T_STATISTICS; // We get this for free statistics_done=1; - if (thd->variables.myisam_repair_threads>1) + if (THDVAR(thd, repair_threads)>1) { char buf[40]; /* TODO: respect myisam_repair_threads variable */ @@ -1290,8 +1339,8 @@ int ha_myisam::enable_indexes(uint mode) param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK | T_CREATE_MISSING_KEYS); param.myf_rw&= ~MY_WAIT_IF_FULL; - param.sort_buffer_length= thd->variables.myisam_sort_buff_size; - param.stats_method= (enum_mi_stats_method)thd->variables.myisam_stats_method; + param.sort_buffer_length= THDVAR(thd, sort_buffer_size); + param.stats_method= (enum_mi_stats_method)THDVAR(thd, stats_method); param.tmpdir=&mysql_tmpdir_list; if ((error= (repair(thd,param,0) != HA_ADMIN_OK)) && param.retry_repair) { @@ -1970,6 +2019,14 @@ static int myisam_init(void *p) init_myisam_psi_keys(); #endif + /* Set global variables based on startup options */ + if (myisam_recover_options) + ha_open_options|=HA_OPEN_ABORT_IF_CRASHED; + else + myisam_recover_options= HA_RECOVER_OFF; + + myisam_block_size=(uint) 1 << my_bit_log2(opt_myisam_block_size); + myisam_hton= (handlerton *)p; myisam_hton->state= SHOW_OPTION_YES; myisam_hton->db_type= DB_TYPE_MYISAM; @@ -1979,6 +2036,19 @@ static int myisam_init(void *p) return 0; } +static struct st_mysql_sys_var* myisam_sysvars[]= { + MYSQL_SYSVAR(block_size), + MYSQL_SYSVAR(data_pointer_size), + MYSQL_SYSVAR(max_sort_file_size), + MYSQL_SYSVAR(recover_options), + MYSQL_SYSVAR(repair_threads), + MYSQL_SYSVAR(sort_buffer_size), + MYSQL_SYSVAR(use_mmap), + MYSQL_SYSVAR(mmap_size), + MYSQL_SYSVAR(stats_method), + 0 +}; + struct st_mysql_storage_engine myisam_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; @@ -1994,8 +2064,8 @@ mysql_declare_plugin(myisam) NULL, /* Plugin Deinit */ 0x0100, /* 1.0 */ NULL, /* status variables */ - NULL, /* system variables */ - NULL /* config options */ + myisam_sysvars, /* system variables */ + NULL } mysql_declare_plugin_end; diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 5bb46b03650..2f41670b934 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -23,15 +23,16 @@ #include <myisam.h> #include <ft_global.h> -#define HA_RECOVER_NONE 0 /* No automatic recover */ #define HA_RECOVER_DEFAULT 1 /* Automatic recover active */ #define HA_RECOVER_BACKUP 2 /* Make a backupfile on recover */ #define HA_RECOVER_FORCE 4 /* Recover even if we loose rows */ #define HA_RECOVER_QUICK 8 /* Don't check rows in data file */ +#define HA_RECOVER_OFF 16 /* No automatic recover */ extern ulong myisam_sort_buffer_size; extern TYPELIB myisam_recover_typelib; -extern ulong myisam_recover_options; +extern const char *myisam_recover_names[]; +extern ulonglong myisam_recover_options; class ha_myisam: public handler { diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 8e55a7bc50e..1cc521baf0e 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -4673,8 +4673,7 @@ static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows) } return (key->flag & HA_SPATIAL) || (key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) && - ((ulonglong) rows * key_maxlength > - (ulonglong) myisam_max_temp_length)); + ((ulonglong) rows * key_maxlength > myisam_max_temp_length)); } /* diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c index 85a3124cba9..81d063a58fd 100644 --- a/storage/myisam/mi_static.c +++ b/storage/myisam/mi_static.c @@ -33,15 +33,14 @@ uint myisam_quick_table_bits=9; ulong myisam_block_size= MI_KEY_BLOCK_LENGTH; /* Best by test */ my_bool myisam_flush=0, myisam_delay_key_write=0, myisam_single_user=0; #if defined(THREAD) && !defined(DONT_USE_RW_LOCKS) -ulong myisam_concurrent_insert= 2; +uint myisam_concurrent_insert= 2; #else -ulong myisam_concurrent_insert= 0; +uint myisam_concurrent_insert= 0; #endif -my_off_t myisam_max_temp_length= MAX_FILE_SIZE; +ulonglong myisam_max_temp_length= MAX_FILE_SIZE; ulong myisam_bulk_insert_tree_size=8192*1024; ulong myisam_data_pointer_size=4; ulonglong myisam_mmap_size= SIZE_T_MAX, myisam_mmap_used= 0; -mysql_mutex_t THR_LOCK_myisam_mmap; static int always_valid(const char *filename __attribute__((unused))) { |