mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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
This commit is contained in:
3
mysql-test/r/lowercase0.require
Normal file
3
mysql-test/r/lowercase0.require
Normal file
@ -0,0 +1,3 @@
|
||||
Variable_name Value
|
||||
lower_case_file_system ON
|
||||
lower_case_table_names 0
|
10
mysql-test/r/lowercase_table3.result
Normal file
10
mysql-test/r/lowercase_table3.result
Normal file
@ -0,0 +1,10 @@
|
||||
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;
|
2
mysql-test/r/true.require
Normal file
2
mysql-test/r/true.require
Normal file
@ -0,0 +1,2 @@
|
||||
TRUE
|
||||
1
|
37
mysql-test/t/lowercase_table3.test
Normal file
37
mysql-test/t/lowercase_table3.test
Normal file
@ -0,0 +1,37 @@
|
||||
#
|
||||
# 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)
|
||||
static longlong getopt_ll(char *arg, const struct my_option *optp, int *err)
|
||||
{
|
||||
longlong num;
|
||||
ulonglong block_size= (optp->block_size ? (ulonglong) optp->block_size : 1L);
|
||||
|
||||
num= eval_num_suffix(arg, err, (char*) optp->name);
|
||||
if (num < (longlong) optp->min_value)
|
||||
num= (longlong) optp->min_value;
|
||||
else if (num > 0 && (ulonglong) num > (ulonglong) (ulong) optp->max_value
|
||||
&& optp->max_value) /* if max value is not set -> no upper limit */
|
||||
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= ((num - (longlong) optp->sub_size) / (optp->block_size ?
|
||||
(ulonglong) optp->block_size :
|
||||
1L));
|
||||
return (longlong) (num * (optp->block_size ? (ulonglong) optp->block_size :
|
||||
1L));
|
||||
num= ((num - (longlong) optp->sub_size) / block_size);
|
||||
num= (longlong) (num * block_size);
|
||||
return max(num, optp->min_value);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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_safe_show_db, opt_local_infile;
|
||||
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 MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
|
||||
|
@ -287,8 +287,10 @@ char log_error_file[FN_REFLEN];
|
||||
bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
|
||||
bool opt_error_log= IF_WIN(1,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_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 lower_case_table_names;
|
||||
|
||||
@ -2106,10 +2108,23 @@ int main(int argc, char **argv)
|
||||
get corrupted if accesses with names of different case.
|
||||
*/
|
||||
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);
|
||||
lower_case_table_names= 2;
|
||||
if (lower_case_table_names_used)
|
||||
{
|
||||
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
|
||||
@ -4845,6 +4860,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
break;
|
||||
case OPT_LOWER_CASE_TABLE_NAMES:
|
||||
lower_case_table_names= argument ? atoi(argument) : 1;
|
||||
lower_case_table_names_used= 1;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
@ -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",
|
||||
&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 */
|
||||
|
||||
static const char license[]= "GPL";
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -368,6 +375,7 @@ sys_var *sys_variables[]=
|
||||
&sys_join_buffer_size,
|
||||
&sys_key_buffer_size,
|
||||
&sys_last_insert_id,
|
||||
&sys_license,
|
||||
&sys_local_infile,
|
||||
&sys_log_binlog,
|
||||
&sys_log_off,
|
||||
@ -434,6 +442,7 @@ sys_var *sys_variables[]=
|
||||
&sys_trans_alloc_block_size,
|
||||
&sys_trans_prealloc_size,
|
||||
&sys_tx_isolation,
|
||||
&sys_os,
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
&sys_innodb_max_dirty_pages_pct,
|
||||
#endif
|
||||
@ -512,8 +521,8 @@ struct show_var_st init_vars[]= {
|
||||
{sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
|
||||
{sys_key_buffer_size.name, (char*) &sys_key_buffer_size, SHOW_SYS},
|
||||
{"language", language, SHOW_CHAR},
|
||||
{"large_files_support", (char*) &opt_large_files, SHOW_BOOL},
|
||||
{"license", (char*) license, SHOW_CHAR},
|
||||
{"large_files_support", (char*) &opt_large_files, SHOW_BOOL},
|
||||
{sys_license.name, (char*) &sys_license, SHOW_SYS},
|
||||
{sys_local_infile.name, (char*) &sys_local_infile, SHOW_SYS},
|
||||
#ifdef HAVE_MLOCKALL
|
||||
{"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL},
|
||||
@ -526,6 +535,7 @@ struct show_var_st init_vars[]= {
|
||||
{sys_log_warnings.name, (char*) &sys_log_warnings, 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},
|
||||
{"lower_case_file_system", (char*) &lower_case_file_system, SHOW_BOOL},
|
||||
{"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_binlog_cache_size.name,(char*) &sys_max_binlog_cache_size, SHOW_SYS},
|
||||
@ -606,6 +616,7 @@ struct show_var_st init_vars[]= {
|
||||
{sys_trans_prealloc_size.name, (char*) &sys_trans_prealloc_size, SHOW_SYS},
|
||||
{"version", server_version, 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},
|
||||
{NullS, NullS, SHOW_LONG}
|
||||
};
|
||||
|
@ -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
|
||||
{
|
||||
uint *value;
|
||||
|
@ -1374,7 +1374,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
|
||||
sizeof(POSITION)*join->const_tables);
|
||||
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,
|
||||
ha_rows rec;
|
||||
double tmp;
|
||||
THD *thd= join->thd;
|
||||
if (thd->killed) // Abort
|
||||
return;
|
||||
|
||||
if (!rest_tables)
|
||||
{
|
||||
|
Reference in New Issue
Block a user