Commit aa20bd9e authored by unknown's avatar unknown

Ensure that one can't from the command line set a variable too small. (Bug #2710)

Allow one to force lower_case_table_names to 0, even if the file system is case insensitive. This fixes some issues on Mac OS X (Bug #2994)
Added variables "lower_case_file_system", "version_compile_os" and "license"


mysql-test/t/lowercase_table3-master.opt:
  Rename: mysql-test/t/lowercase_table2-master.opt -> mysql-test/t/lowercase_table3-master.opt
mysys/my_getopt.c:
  Ensure that one can't from the command line set a variable too small (could happen when sub_size was set)
sql/mysql_priv.h:
  Added lower_case_file_system
sql/mysqld.cc:
  Allow one to force lower_case_table_names to 0, even if the file system is case insensitive
sql/set_var.cc:
  Added variable "lower_case_file_system"
  Added variable "version_compile_os"
  Added variable "license"
sql/set_var.h:
  Added support for read only strings
sql/sql_select.cc:
  Make join optimizer killable
parent 0b751edc
Variable_name Value
lower_case_file_system ON
lower_case_table_names 0
DROP TABLE IF EXISTS t1,T1;
CREATE TABLE t1 (a int);
SELECT * from T1;
a
drop table t1;
flush tables;
CREATE TABLE t1 (a int) type=INNODB;
SELECT * from T1;
Table 'test.T1' doesn't exist
drop table t1;
#
# Test of force of lower-case-table-names=0
# (User has case insensitive file system and want's to preserve case of
# table names)
#
--source include/have_innodb.inc
--require r/lowercase0.require
disable_query_log;
show variables like "lower_case_%";
--require r/true.require
select @@version_compile_os NOT IN ("NT","WIN2000","Win95/Win98","XP") as "TRUE";
enable_query_log;
--disable_warnings
DROP TABLE IF EXISTS t1,T1;
--enable_warnings
#
# This is actually an error, but ok as the user has forced this
# by using --lower-case-table-names=0
CREATE TABLE t1 (a int);
SELECT * from T1;
drop table t1;
flush tables;
#
# InnoDB should in this case be case sensitive
# Note that this is not true on windows as no this OS, InnoDB is always
# storing things in lower case.
#
CREATE TABLE t1 (a int) type=INNODB;
--error 1146
SELECT * from T1;
drop table t1;
...@@ -576,18 +576,15 @@ static longlong eval_num_suffix (char *argument, int *error, char *option_name) ...@@ -576,18 +576,15 @@ static longlong eval_num_suffix (char *argument, int *error, char *option_name)
static longlong getopt_ll(char *arg, const struct my_option *optp, int *err) static longlong getopt_ll(char *arg, const struct my_option *optp, int *err)
{ {
longlong num; longlong num;
ulonglong block_size= (optp->block_size ? (ulonglong) optp->block_size : 1L);
num= eval_num_suffix(arg, err, (char*) optp->name); num= eval_num_suffix(arg, err, (char*) optp->name);
if (num < (longlong) optp->min_value) if (num > 0 && (ulonglong) num > (ulonglong) (ulong) optp->max_value &&
num= (longlong) optp->min_value; optp->max_value) /* if max value is not set -> no upper limit */
else if (num > 0 && (ulonglong) num > (ulonglong) (ulong) optp->max_value
&& optp->max_value) /* if max value is not set -> no upper limit */
num= (longlong) (ulong) optp->max_value; num= (longlong) (ulong) optp->max_value;
num= ((num - (longlong) optp->sub_size) / (optp->block_size ? num= ((num - (longlong) optp->sub_size) / block_size);
(ulonglong) optp->block_size : num= (longlong) (num * block_size);
1L)); return max(num, optp->min_value);
return (longlong) (num * (optp->block_size ? (ulonglong) optp->block_size :
1L));
} }
/* /*
......
...@@ -710,7 +710,7 @@ extern uint volatile thread_count, thread_running, global_read_lock; ...@@ -710,7 +710,7 @@ extern uint volatile thread_count, thread_running, global_read_lock;
extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types; extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
extern my_bool opt_safe_show_db, opt_local_infile; extern my_bool opt_safe_show_db, opt_local_infile;
extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern my_bool opt_slave_compressed_protocol, use_temp_pool;
extern my_bool opt_readonly; extern my_bool opt_readonly, lower_case_file_system;
extern my_bool opt_enable_named_pipe, opt_sync_frm; extern my_bool opt_enable_named_pipe, opt_sync_frm;
extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
......
...@@ -287,8 +287,10 @@ char log_error_file[FN_REFLEN]; ...@@ -287,8 +287,10 @@ char log_error_file[FN_REFLEN];
bool opt_log, opt_update_log, opt_bin_log, opt_slow_log; bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
bool opt_error_log= IF_WIN(1,0); bool opt_error_log= IF_WIN(1,0);
bool opt_disable_networking=0, opt_skip_show_db=0; bool opt_disable_networking=0, opt_skip_show_db=0;
bool lower_case_table_names_used= 0;
my_bool opt_enable_named_pipe= 0, opt_debugging= 0; my_bool opt_enable_named_pipe= 0, opt_debugging= 0;
my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol; my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol;
my_bool lower_case_file_system= 0;
uint delay_key_write_options= (uint) DELAY_KEY_WRITE_ON; uint delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
uint lower_case_table_names; uint lower_case_table_names;
...@@ -2106,10 +2108,23 @@ int main(int argc, char **argv) ...@@ -2106,10 +2108,23 @@ int main(int argc, char **argv)
get corrupted if accesses with names of different case. get corrupted if accesses with names of different case.
*/ */
if (!lower_case_table_names && if (!lower_case_table_names &&
test_if_case_insensitive(mysql_real_data_home) == 1) (lower_case_file_system=
(test_if_case_insensitive(mysql_real_data_home) == 1)))
{ {
sql_print_error("Warning: Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home); if (lower_case_table_names_used)
lower_case_table_names= 2; {
sql_print_error("\
Warning: You have forced lower_case_table_names to 0 through a command line \
option, even if your file system '%s' is case insensitive. This means that \
you can corrupt an MyISAM table by accessing it with different cases. You \
should consider changing lower_case_table_names to 1 or 2",
mysql_real_data_home);
}
else
{
sql_print_error("Warning: Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home);
lower_case_table_names= 2;
}
} }
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
...@@ -4845,6 +4860,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -4845,6 +4860,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case OPT_LOWER_CASE_TABLE_NAMES: case OPT_LOWER_CASE_TABLE_NAMES:
lower_case_table_names= argument ? atoi(argument) : 1; lower_case_table_names= argument ? atoi(argument) : 1;
lower_case_table_names_used= 1;
break; break;
} }
return 0; return 0;
......
...@@ -329,9 +329,16 @@ static sys_var_rand_seed2 sys_rand_seed2("rand_seed2"); ...@@ -329,9 +329,16 @@ static sys_var_rand_seed2 sys_rand_seed2("rand_seed2");
static sys_var_thd_ulong sys_default_week_format("default_week_format", static sys_var_thd_ulong sys_default_week_format("default_week_format",
&SV::default_week_format); &SV::default_week_format);
static const char license[]= "GPL";
/* Read only variables */
sys_var_const_str sys_os("version_compile_os", SYSTEM_TYPE);
sys_var_const_str sys_license("license", license);
/* Global read-only variable describing server license */ /* Global read-only variable describing server license */
static const char license[]= "GPL";
/* /*
...@@ -368,6 +375,7 @@ sys_var *sys_variables[]= ...@@ -368,6 +375,7 @@ sys_var *sys_variables[]=
&sys_join_buffer_size, &sys_join_buffer_size,
&sys_key_buffer_size, &sys_key_buffer_size,
&sys_last_insert_id, &sys_last_insert_id,
&sys_license,
&sys_local_infile, &sys_local_infile,
&sys_log_binlog, &sys_log_binlog,
&sys_log_off, &sys_log_off,
...@@ -434,6 +442,7 @@ sys_var *sys_variables[]= ...@@ -434,6 +442,7 @@ sys_var *sys_variables[]=
&sys_trans_alloc_block_size, &sys_trans_alloc_block_size,
&sys_trans_prealloc_size, &sys_trans_prealloc_size,
&sys_tx_isolation, &sys_tx_isolation,
&sys_os,
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
&sys_innodb_max_dirty_pages_pct, &sys_innodb_max_dirty_pages_pct,
#endif #endif
...@@ -512,8 +521,8 @@ struct show_var_st init_vars[]= { ...@@ -512,8 +521,8 @@ struct show_var_st init_vars[]= {
{sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS}, {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
{sys_key_buffer_size.name, (char*) &sys_key_buffer_size, SHOW_SYS}, {sys_key_buffer_size.name, (char*) &sys_key_buffer_size, SHOW_SYS},
{"language", language, SHOW_CHAR}, {"language", language, SHOW_CHAR},
{"large_files_support", (char*) &opt_large_files, SHOW_BOOL}, {"large_files_support", (char*) &opt_large_files, SHOW_BOOL},
{"license", (char*) license, SHOW_CHAR}, {sys_license.name, (char*) &sys_license, SHOW_SYS},
{sys_local_infile.name, (char*) &sys_local_infile, SHOW_SYS}, {sys_local_infile.name, (char*) &sys_local_infile, SHOW_SYS},
#ifdef HAVE_MLOCKALL #ifdef HAVE_MLOCKALL
{"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL}, {"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL},
...@@ -526,6 +535,7 @@ struct show_var_st init_vars[]= { ...@@ -526,6 +535,7 @@ struct show_var_st init_vars[]= {
{sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS}, {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
{sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS}, {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
{sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS}, {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
{"lower_case_file_system", (char*) &lower_case_file_system, SHOW_BOOL},
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT}, {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
{sys_max_allowed_packet.name,(char*) &sys_max_allowed_packet, SHOW_SYS}, {sys_max_allowed_packet.name,(char*) &sys_max_allowed_packet, SHOW_SYS},
{sys_max_binlog_cache_size.name,(char*) &sys_max_binlog_cache_size, SHOW_SYS}, {sys_max_binlog_cache_size.name,(char*) &sys_max_binlog_cache_size, SHOW_SYS},
...@@ -606,6 +616,7 @@ struct show_var_st init_vars[]= { ...@@ -606,6 +616,7 @@ struct show_var_st init_vars[]= {
{sys_trans_prealloc_size.name, (char*) &sys_trans_prealloc_size, SHOW_SYS}, {sys_trans_prealloc_size.name, (char*) &sys_trans_prealloc_size, SHOW_SYS},
{"version", server_version, SHOW_CHAR}, {"version", server_version, SHOW_CHAR},
{"version_comment", (char*) MYSQL_COMPILATION_COMMENT, SHOW_CHAR}, {"version_comment", (char*) MYSQL_COMPILATION_COMMENT, SHOW_CHAR},
{sys_os.name, (char*) &sys_os, SHOW_SYS},
{sys_net_wait_timeout.name, (char*) &sys_net_wait_timeout, SHOW_SYS}, {sys_net_wait_timeout.name, (char*) &sys_net_wait_timeout, SHOW_SYS},
{NullS, NullS, SHOW_LONG} {NullS, NullS, SHOW_LONG}
}; };
......
...@@ -156,6 +156,31 @@ public: ...@@ -156,6 +156,31 @@ public:
}; };
class sys_var_const_str :public sys_var
{
public:
char *value; // Pointer to const value
sys_var_const_str(const char *name_arg, const char *value_arg)
:sys_var(name_arg), value((char*) value_arg)
{}
bool check(THD *thd, set_var *var)
{
return 1;
}
bool update(THD *thd, set_var *var)
{
return 1;
}
SHOW_TYPE type() { return SHOW_CHAR; }
byte *value_ptr(THD *thd, enum_var_type type) { return (byte*) value; }
bool check_update_type(Item_result type)
{
return 1;
}
bool check_default(enum_var_type type) { return 1; }
};
class sys_var_enum :public sys_var class sys_var_enum :public sys_var
{ {
uint *value; uint *value;
......
...@@ -1374,7 +1374,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, ...@@ -1374,7 +1374,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
sizeof(POSITION)*join->const_tables); sizeof(POSITION)*join->const_tables);
join->best_read=1.0; join->best_read=1.0;
} }
DBUG_RETURN(get_best_combination(join)); DBUG_RETURN(join->thd->killed || get_best_combination(join));
} }
...@@ -1904,6 +1904,8 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, ...@@ -1904,6 +1904,8 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
ha_rows rec; ha_rows rec;
double tmp; double tmp;
THD *thd= join->thd; THD *thd= join->thd;
if (thd->killed) // Abort
return;
if (!rest_tables) if (!rest_tables)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment