summaryrefslogtreecommitdiff
path: root/storage/myisam/ha_myisam.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mysql.com>2009-12-22 10:35:56 +0100
committerSergei Golubchik <serg@mysql.com>2009-12-22 10:35:56 +0100
commitae2768ce9c7df45ec88ba49bf149985bf7c9308d (patch)
treeffef2f9db240392c7f322d05058dfd7ea8c01a9d /storage/myisam/ha_myisam.cc
parente3976aa9ae7f91fb08c8d61801631c9af821f6b1 (diff)
downloadmariadb-git-ae2768ce9c7df45ec88ba49bf149985bf7c9308d.tar.gz
WL#4738 streamline/simplify @@variable creation process
Bug#16565 mysqld --help --verbose does not order variablesBug#20413 sql_slave_skip_counter is not shown in show variables Bug#20415 Output of mysqld --help --verbose is incomplete Bug#25430 variable not found in SELECT @@global.ft_max_word_len; Bug#32902 plugin variables don't know their names Bug#34599 MySQLD Option and Variable Reference need to be consistent in formatting! Bug#34829 No default value for variable and setting default does not raise error Bug#34834 ? Is accepted as a valid sql mode Bug#34878 Few variables have default value according to documentation but error occurs Bug#34883 ft_boolean_syntax cant be assigned from user variable to global var. Bug#37187 `INFORMATION_SCHEMA`.`GLOBAL_VARIABLES`: inconsistent status Bug#40988 log_output_basic.test succeeded though syntactically false. Bug#41010 enum-style command-line options are not honoured (maria.maria-recover fails) Bug#42103 Setting key_buffer_size to a negative value may lead to very large allocations Bug#44691 Some plugins configured as MYSQL_PLUGIN_MANDATORY in can be disabled Bug#44797 plugins w/o command-line options have no disabling option in --help Bug#46314 string system variables don't support expressions Bug#46470 sys_vars.max_binlog_cache_size_basic_32 is broken Bug#46586 When using the plugin interface the type "set" for options caused a crash. Bug#47212 Crash in DBUG_PRINT in mysqltest.cc when trying to print octal number Bug#48758 mysqltest crashes on sys_vars.collation_server_basic in gcov builds Bug#49417 some complaints about mysqld --help --verbose output Bug#49540 DEFAULT value of binlog_format isn't the default value Bug#49640 ambiguous option '--skip-skip-myisam' (double skip prefix) Bug#49644 init_connect and \0 Bug#49645 init_slave and multi-byte characters Bug#49646 mysql --show-warnings crashes when server dies
Diffstat (limited to 'storage/myisam/ha_myisam.cc')
-rw-r--r--storage/myisam/ha_myisam.cc92
1 files changed, 81 insertions, 11 deletions
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 &param, 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;