Commit 592a05fd authored by Patrick Crews's avatar Patrick Crews

merge.

parents 64c32d5a 191ccc23
...@@ -72,7 +72,7 @@ extern void my_cleanup_options(const struct my_option *options); ...@@ -72,7 +72,7 @@ extern void my_cleanup_options(const struct my_option *options);
extern void my_print_help(const struct my_option *options); extern void my_print_help(const struct my_option *options);
extern void my_print_variables(const struct my_option *options); extern void my_print_variables(const struct my_option *options);
extern void my_getopt_register_get_addr(uchar ** (*func_addr)(const char *, uint, extern void my_getopt_register_get_addr(uchar ** (*func_addr)(const char *, uint,
const struct my_option *)); const struct my_option *, int *));
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
my_bool *fix); my_bool *fix);
......
...@@ -43,6 +43,15 @@ extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE]; ...@@ -43,6 +43,15 @@ extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
static my_bool emb_read_query_result(MYSQL *mysql); static my_bool emb_read_query_result(MYSQL *mysql);
extern "C" void unireg_clear(int exit_code)
{
DBUG_ENTER("unireg_clear");
clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
DBUG_VOID_RETURN;
}
/* /*
Reads error information from the MYSQL_DATA and puts Reads error information from the MYSQL_DATA and puts
it into proper MYSQL members it into proper MYSQL members
......
...@@ -692,3 +692,29 @@ unlock tables; ...@@ -692,3 +692,29 @@ unlock tables;
drop table t1; drop table t1;
--error ER_UNKNOWN_TABLE --error ER_UNKNOWN_TABLE
handler t1 read a next; handler t1 read a next;
#
# Bug#41110: crash with handler command when used concurrently with alter table
# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a int);
insert into t1 values (1);
handler t1 open;
connect(con1,localhost,root,,);
send alter table t1 engine=memory;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "rename result table" and info = "alter table t1 engine=memory";
--source include/wait_condition.inc
--error ER_ILLEGAL_HA
handler t1 read a next;
handler t1 close;
connection con1;
--reap
drop table t1;
connection default;
...@@ -730,3 +730,12 @@ unlock tables; ...@@ -730,3 +730,12 @@ unlock tables;
drop table t1; drop table t1;
handler t1 read a next; handler t1 read a next;
ERROR 42S02: Unknown table 't1' in HANDLER ERROR 42S02: Unknown table 't1' in HANDLER
drop table if exists t1;
create table t1 (a int);
insert into t1 values (1);
handler t1 open;
alter table t1 engine=memory;
handler t1 read a next;
ERROR HY000: Table storage engine for 't1' doesn't have this option
handler t1 close;
drop table t1;
...@@ -728,3 +728,12 @@ unlock tables; ...@@ -728,3 +728,12 @@ unlock tables;
drop table t1; drop table t1;
handler t1 read a next; handler t1 read a next;
ERROR 42S02: Unknown table 't1' in HANDLER ERROR 42S02: Unknown table 't1' in HANDLER
drop table if exists t1;
create table t1 (a int);
insert into t1 values (1);
handler t1 open;
alter table t1 engine=memory;
handler t1 read a next;
ERROR HY000: Table storage engine for 't1' doesn't have this option
handler t1 close;
drop table t1;
...@@ -411,17 +411,6 @@ drop table t1; ...@@ -411,17 +411,6 @@ drop table t1;
1 1
drop table t1; drop table t1;
shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql
set @@global.server_id= 4294967295;
reset master;
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog"))
is not null;
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog"))
is not null
1
*** Unsigned server_id 4294967295 is found: 1 ***
set @@global.server_id= 1;
End of 5.0 tests
flush logs; flush logs;
BUG#31611: Security risk with BINLOG statement BUG#31611: Security risk with BINLOG statement
SET BINLOG_FORMAT=ROW; SET BINLOG_FORMAT=ROW;
...@@ -471,4 +460,15 @@ an_int 1000 ...@@ -471,4 +460,15 @@ an_int 1000
a_decimal 907.79 a_decimal 907.79
a_string Just a test a_string Just a test
DROP TABLE t1; DROP TABLE t1;
set @@global.server_id= 4294967295;
reset master;
flush logs;
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog"))
is not null;
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog"))
is not null
1
*** Unsigned server_id 4294967295 is found: 1 ***
set @@global.server_id= 1;
End of 5.1 tests End of 5.1 tests
...@@ -278,27 +278,6 @@ echo shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql ...@@ -278,27 +278,6 @@ echo shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql
error 1; error 1;
exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql; exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql;
#
# Bug #37313 BINLOG Contains Incorrect server id
#
let $save_server_id= `select @@global.server_id`;
let $s_id_max=`select (1 << 32) - 1`;
eval set @@global.server_id= $s_id_max;
reset master;
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog"))
is not null;
let $s_id_unsigned= `select @a like "%server id $s_id_max%" /* must return 1 */`;
echo *** Unsigned server_id $s_id_max is found: $s_id_unsigned ***;
eval set @@global.server_id= $save_server_id;
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog
--echo End of 5.0 tests
# #
# Test --disable-force-if-open and --force-if-open # Test --disable-force-if-open and --force-if-open
...@@ -363,4 +342,25 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug32580.sql; ...@@ -363,4 +342,25 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug32580.sql;
query_vertical SELECT * FROM t1; query_vertical SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #37313 BINLOG Contains Incorrect server id
#
let $save_server_id= `select @@global.server_id`;
let $s_id_max=`select (1 << 32) - 1`;
eval set @@global.server_id= $s_id_max;
reset master;
flush logs;
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog"))
is not null;
let $s_id_unsigned= `select @a like "%server id $s_id_max%" /* must return 1 */`;
echo *** Unsigned server_id $s_id_max is found: $s_id_unsigned ***;
eval set @@global.server_id= $save_server_id;
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -144,6 +144,7 @@ static char *remove_end_comment(char *ptr); ...@@ -144,6 +144,7 @@ static char *remove_end_comment(char *ptr);
RETURN RETURN
0 ok 0 ok
1 given cinf_file doesn't exist 1 given cinf_file doesn't exist
2 out of memory
The global variable 'my_defaults_group_suffix' is updated with value for The global variable 'my_defaults_group_suffix' is updated with value for
--defaults_group_suffix --defaults_group_suffix
...@@ -190,7 +191,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv, ...@@ -190,7 +191,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
if (!(extra_groups= if (!(extra_groups=
(const char**)alloc_root(ctx->alloc, (const char**)alloc_root(ctx->alloc,
(2*group->count+1)*sizeof(char*)))) (2*group->count+1)*sizeof(char*))))
goto err; DBUG_RETURN(2);
for (i= 0; i < group->count; i++) for (i= 0; i < group->count; i++)
{ {
...@@ -199,7 +200,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv, ...@@ -199,7 +200,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
len= strlen(extra_groups[i]); len= strlen(extra_groups[i]);
if (!(ptr= alloc_root(ctx->alloc, len+instance_len+1))) if (!(ptr= alloc_root(ctx->alloc, len+instance_len+1)))
goto err; DBUG_RETURN(2);
extra_groups[i+group->count]= ptr; extra_groups[i+group->count]= ptr;
...@@ -254,12 +255,11 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv, ...@@ -254,12 +255,11 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
} }
} }
DBUG_RETURN(error); DBUG_RETURN(0);
err: err:
fprintf(stderr,"Fatal error in defaults handling. Program aborted\n"); fprintf(stderr,"Fatal error in defaults handling. Program aborted\n");
exit(1); DBUG_RETURN(1);
return 0; /* Keep compiler happy */
} }
......
...@@ -100,10 +100,10 @@ static void default_reporter(enum loglevel level, ...@@ -100,10 +100,10 @@ static void default_reporter(enum loglevel level,
one. Call function 'get_one_option()' once for each option. one. Call function 'get_one_option()' once for each option.
*/ */
static uchar** (*getopt_get_addr)(const char *, uint, const struct my_option *); static uchar** (*getopt_get_addr)(const char *, uint, const struct my_option *, int *);
void my_getopt_register_get_addr(uchar** (*func_addr)(const char *, uint, void my_getopt_register_get_addr(uchar** (*func_addr)(const char *, uint,
const struct my_option *)) const struct my_option *, int *))
{ {
getopt_get_addr= func_addr; getopt_get_addr= func_addr;
} }
...@@ -362,8 +362,12 @@ int handle_options(int *argc, char ***argv, ...@@ -362,8 +362,12 @@ int handle_options(int *argc, char ***argv,
my_progname, optp->name); my_progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED; return EXIT_NO_ARGUMENT_ALLOWED;
} }
error= 0;
value= optp->var_type & GET_ASK_ADDR ? value= optp->var_type & GET_ASK_ADDR ?
(*getopt_get_addr)(key_name, (uint) strlen(key_name), optp) : optp->value; (*getopt_get_addr)(key_name, (uint) strlen(key_name), optp, &error) :
optp->value;
if (error)
return error;
if (optp->arg_type == NO_ARG) if (optp->arg_type == NO_ARG)
{ {
...@@ -1092,7 +1096,7 @@ static void init_variables(const struct my_option *options, ...@@ -1092,7 +1096,7 @@ static void init_variables(const struct my_option *options,
if (options->value) if (options->value)
init_one_value(options, options->value, options->def_value); init_one_value(options, options->value, options->def_value);
if (options->var_type & GET_ASK_ADDR && if (options->var_type & GET_ASK_ADDR &&
(variable= (*getopt_get_addr)("", 0, options))) (variable= (*getopt_get_addr)("", 0, options, 0)))
init_one_value(options, variable, options->def_value); init_one_value(options, variable, options->def_value);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -1196,7 +1200,7 @@ void my_print_variables(const struct my_option *options) ...@@ -1196,7 +1200,7 @@ void my_print_variables(const struct my_option *options)
for (optp= options; optp->id; optp++) for (optp= options; optp->id; optp++)
{ {
uchar* *value= (optp->var_type & GET_ASK_ADDR ? uchar* *value= (optp->var_type & GET_ASK_ADDR ?
(*getopt_get_addr)("", 0, optp) : optp->value); (*getopt_get_addr)("", 0, optp, 0) : optp->value);
if (value) if (value)
{ {
printf("%s ", optp->name); printf("%s ", optp->name);
......
...@@ -1258,7 +1258,7 @@ void Log_event::print_header(IO_CACHE* file, ...@@ -1258,7 +1258,7 @@ void Log_event::print_header(IO_CACHE* file,
my_b_printf(file, "#"); my_b_printf(file, "#");
print_timestamp(file); print_timestamp(file);
my_b_printf(file, " server id %lu end_log_pos %s ", server_id, my_b_printf(file, " server id %lu end_log_pos %s ", (ulong) server_id,
llstr(log_pos,llbuff)); llstr(log_pos,llbuff));
/* mysqlbinlog --hexdump */ /* mysqlbinlog --hexdump */
......
...@@ -2411,7 +2411,8 @@ extern "C" void unireg_abort(int exit_code) __attribute__((noreturn)); ...@@ -2411,7 +2411,8 @@ extern "C" void unireg_abort(int exit_code) __attribute__((noreturn));
void kill_delayed_threads(void); void kill_delayed_threads(void);
bool check_stack_overrun(THD *thd, long margin, uchar *dummy); bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
#else #else
#define unireg_abort(exit_code) DBUG_RETURN(exit_code) extern "C" void unireg_clear(int exit_code);
#define unireg_abort(exit_code) do { unireg_clear(exit_code); DBUG_RETURN(exit_code); } while(0)
inline void kill_delayed_threads(void) {} inline void kill_delayed_threads(void) {}
#define check_stack_overrun(A, B, C) 0 #define check_stack_overrun(A, B, C) 0
#endif #endif
......
...@@ -747,12 +747,12 @@ uint connection_count= 0; ...@@ -747,12 +747,12 @@ uint connection_count= 0;
pthread_handler_t signal_hand(void *arg); pthread_handler_t signal_hand(void *arg);
static int mysql_init_variables(void); static int mysql_init_variables(void);
static void get_options(int *argc,char **argv); static int get_options(int *argc,char **argv);
extern "C" my_bool mysqld_get_one_option(int, const struct my_option *, char *); extern "C" my_bool mysqld_get_one_option(int, const struct my_option *, char *);
static void set_server_version(void); static void set_server_version(void);
static int init_thread_environment(); static int init_thread_environment();
static char *get_relative_path(const char *path); static char *get_relative_path(const char *path);
static void fix_paths(void); static int fix_paths(void);
pthread_handler_t handle_connections_sockets(void *arg); pthread_handler_t handle_connections_sockets(void *arg);
pthread_handler_t kill_server_thread(void *arg); pthread_handler_t kill_server_thread(void *arg);
static void bootstrap(FILE *file); static void bootstrap(FILE *file);
...@@ -766,7 +766,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg); ...@@ -766,7 +766,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg);
pthread_handler_t handle_slave(void *arg); pthread_handler_t handle_slave(void *arg);
static ulong find_bit_type(const char *x, TYPELIB *bit_lib); static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib, static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
const char *option); const char *option, int *error);
static void clean_up(bool print_message); static void clean_up(bool print_message);
static int test_if_case_insensitive(const char *dir_name); static int test_if_case_insensitive(const char *dir_name);
...@@ -1190,7 +1190,8 @@ extern "C" void unireg_abort(int exit_code) ...@@ -1190,7 +1190,8 @@ extern "C" void unireg_abort(int exit_code)
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
exit(exit_code); /* purecov: inspected */ exit(exit_code); /* purecov: inspected */
} }
#endif
#endif /*EMBEDDED_LIBRARY*/
void clean_up(bool print_message) void clean_up(bool print_message)
...@@ -3226,7 +3227,8 @@ static int init_common_variables(const char *conf_file_name, int argc, ...@@ -3226,7 +3227,8 @@ static int init_common_variables(const char *conf_file_name, int argc,
load_defaults(conf_file_name, groups, &argc, &argv); load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv; defaults_argv=argv;
defaults_argc=argc; defaults_argc=argc;
get_options(&defaults_argc, defaults_argv); if (get_options(&defaults_argc, defaults_argv))
return 1;
set_server_version(); set_server_version();
DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname,
...@@ -7497,6 +7499,7 @@ To see what values a running MySQL server is using, type\n\ ...@@ -7497,6 +7499,7 @@ To see what values a running MySQL server is using, type\n\
static int mysql_init_variables(void) static int mysql_init_variables(void)
{ {
int error;
/* Things reset to zero */ /* Things reset to zero */
opt_skip_slave_start= opt_reckless_slave = 0; opt_skip_slave_start= opt_reckless_slave = 0;
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0; mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
...@@ -7554,7 +7557,10 @@ static int mysql_init_variables(void) ...@@ -7554,7 +7557,10 @@ static int mysql_init_variables(void)
delay_key_write_options= (uint) DELAY_KEY_WRITE_ON; delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
slave_exec_mode_options= 0; slave_exec_mode_options= 0;
slave_exec_mode_options= (uint) slave_exec_mode_options= (uint)
find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL); find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL,
&error);
if (error)
return 1;
opt_specialflag= SPECIAL_ENGLISH; opt_specialflag= SPECIAL_ENGLISH;
unix_sock= ip_sock= INVALID_SOCKET; unix_sock= ip_sock= INVALID_SOCKET;
mysql_home_ptr= mysql_home; mysql_home_ptr= mysql_home;
...@@ -7732,6 +7738,8 @@ mysqld_get_one_option(int optid, ...@@ -7732,6 +7738,8 @@ mysqld_get_one_option(int optid,
const struct my_option *opt __attribute__((unused)), const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
int error;
switch(optid) { switch(optid) {
case '#': case '#':
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -7775,7 +7783,9 @@ mysqld_get_one_option(int optid, ...@@ -7775,7 +7783,9 @@ mysqld_get_one_option(int optid,
break; break;
case OPT_SLAVE_EXEC_MODE: case OPT_SLAVE_EXEC_MODE:
slave_exec_mode_options= (uint) slave_exec_mode_options= (uint)
find_bit_type_or_exit(argument, &slave_exec_mode_typelib, ""); find_bit_type_or_exit(argument, &slave_exec_mode_typelib, "", &error);
if (error)
return 1;
break; break;
#endif #endif
case OPT_SAFEMALLOC_MEM_LIMIT: case OPT_SAFEMALLOC_MEM_LIMIT:
...@@ -7843,18 +7853,16 @@ mysqld_get_one_option(int optid, ...@@ -7843,18 +7853,16 @@ mysqld_get_one_option(int optid,
if (!(p= strstr(argument, "->"))) if (!(p= strstr(argument, "->")))
{ {
fprintf(stderr, sql_print_error("Bad syntax in replicate-rewrite-db - missing '->'!\n");
"Bad syntax in replicate-rewrite-db - missing '->'!\n"); return 1;
exit(1);
} }
val= p--; val= p--;
while (my_isspace(mysqld_charset, *p) && p > argument) while (my_isspace(mysqld_charset, *p) && p > argument)
*p-- = 0; *p-- = 0;
if (p == argument) if (p == argument)
{ {
fprintf(stderr, sql_print_error("Bad syntax in replicate-rewrite-db - empty FROM db!\n");
"Bad syntax in replicate-rewrite-db - empty FROM db!\n"); return 1;
exit(1);
} }
*val= 0; *val= 0;
val+= 2; val+= 2;
...@@ -7862,9 +7870,8 @@ mysqld_get_one_option(int optid, ...@@ -7862,9 +7870,8 @@ mysqld_get_one_option(int optid,
*val++; *val++;
if (!*val) if (!*val)
{ {
fprintf(stderr, sql_print_error("Bad syntax in replicate-rewrite-db - empty TO db!\n");
"Bad syntax in replicate-rewrite-db - empty TO db!\n"); return 1;
exit(1);
} }
rpl_filter->add_db_rewrite(key, val); rpl_filter->add_db_rewrite(key, val);
...@@ -7892,8 +7899,8 @@ mysqld_get_one_option(int optid, ...@@ -7892,8 +7899,8 @@ mysqld_get_one_option(int optid,
{ {
if (rpl_filter->add_do_table(argument)) if (rpl_filter->add_do_table(argument))
{ {
fprintf(stderr, "Could not add do table rule '%s'!\n", argument); sql_print_error("Could not add do table rule '%s'!\n", argument);
exit(1); return 1;
} }
break; break;
} }
...@@ -7901,8 +7908,8 @@ mysqld_get_one_option(int optid, ...@@ -7901,8 +7908,8 @@ mysqld_get_one_option(int optid,
{ {
if (rpl_filter->add_wild_do_table(argument)) if (rpl_filter->add_wild_do_table(argument))
{ {
fprintf(stderr, "Could not add do table rule '%s'!\n", argument); sql_print_error("Could not add do table rule '%s'!\n", argument);
exit(1); return 1;
} }
break; break;
} }
...@@ -7910,8 +7917,8 @@ mysqld_get_one_option(int optid, ...@@ -7910,8 +7917,8 @@ mysqld_get_one_option(int optid,
{ {
if (rpl_filter->add_wild_ignore_table(argument)) if (rpl_filter->add_wild_ignore_table(argument))
{ {
fprintf(stderr, "Could not add ignore table rule '%s'!\n", argument); sql_print_error("Could not add ignore table rule '%s'!\n", argument);
exit(1); return 1;
} }
break; break;
} }
...@@ -7919,8 +7926,8 @@ mysqld_get_one_option(int optid, ...@@ -7919,8 +7926,8 @@ mysqld_get_one_option(int optid,
{ {
if (rpl_filter->add_ignore_table(argument)) if (rpl_filter->add_ignore_table(argument))
{ {
fprintf(stderr, "Could not add ignore table rule '%s'!\n", argument); sql_print_error("Could not add ignore table rule '%s'!\n", argument);
exit(1); return 1;
} }
break; break;
} }
...@@ -7941,7 +7948,9 @@ mysqld_get_one_option(int optid, ...@@ -7941,7 +7948,9 @@ mysqld_get_one_option(int optid,
{ {
log_output_str= argument; log_output_str= argument;
log_output_options= log_output_options=
find_bit_type_or_exit(argument, &log_output_typelib, opt->name); find_bit_type_or_exit(argument, &log_output_typelib, opt->name, &error);
if (error)
return 1;
} }
break; break;
} }
...@@ -7951,7 +7960,7 @@ mysqld_get_one_option(int optid, ...@@ -7951,7 +7960,7 @@ mysqld_get_one_option(int optid,
sql_perror("Event scheduler is not supported in embedded build."); sql_perror("Event scheduler is not supported in embedded build.");
#else #else
if (Events::set_opt_event_scheduler(argument)) if (Events::set_opt_event_scheduler(argument))
exit(1); return 1;
#endif #endif
break; break;
case (int) OPT_SKIP_NEW: case (int) OPT_SKIP_NEW:
...@@ -7990,7 +7999,7 @@ mysqld_get_one_option(int optid, ...@@ -7990,7 +7999,7 @@ mysqld_get_one_option(int optid,
case (int) OPT_SKIP_NETWORKING: case (int) OPT_SKIP_NETWORKING:
#if defined(__NETWARE__) #if defined(__NETWARE__)
sql_perror("Can't start server: skip-networking option is currently not supported on NetWare"); sql_perror("Can't start server: skip-networking option is currently not supported on NetWare");
exit(1); return 1;
#endif #endif
opt_disable_networking=1; opt_disable_networking=1;
mysqld_port=0; mysqld_port=0;
...@@ -8161,7 +8170,10 @@ mysqld_get_one_option(int optid, ...@@ -8161,7 +8170,10 @@ mysqld_get_one_option(int optid,
{ {
myisam_recover_options_str=argument; myisam_recover_options_str=argument;
myisam_recover_options= myisam_recover_options=
find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name); find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name,
&error);
if (error)
return 1;
} }
ha_open_options|=HA_OPEN_ABORT_IF_CRASHED; ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
break; break;
...@@ -8206,7 +8218,9 @@ mysqld_get_one_option(int optid, ...@@ -8206,7 +8218,9 @@ mysqld_get_one_option(int optid,
{ {
sql_mode_str= argument; sql_mode_str= argument;
global_system_variables.sql_mode= global_system_variables.sql_mode=
find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name); find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name, &error);
if (error)
return 1;
global_system_variables.sql_mode= fix_sql_mode(global_system_variables. global_system_variables.sql_mode= fix_sql_mode(global_system_variables.
sql_mode); sql_mode);
break; break;
...@@ -8245,13 +8259,17 @@ mysqld_get_one_option(int optid, ...@@ -8245,13 +8259,17 @@ mysqld_get_one_option(int optid,
/** Handle arguments for multiple key caches. */ /** Handle arguments for multiple key caches. */
extern "C" uchar **mysql_getopt_value(const char *keyname, uint key_length, extern "C" int mysql_getopt_value(uchar **value,
const struct my_option *option); const char *keyname, uint key_length,
const struct my_option *option,
int *error);
uchar* * static uchar* *
mysql_getopt_value(const char *keyname, uint key_length, mysql_getopt_value(const char *keyname, uint key_length,
const struct my_option *option) const struct my_option *option, int *error)
{ {
if (error)
*error= 0;
switch (option->id) { switch (option->id) {
case OPT_KEY_BUFFER_SIZE: case OPT_KEY_BUFFER_SIZE:
case OPT_KEY_CACHE_BLOCK_SIZE: case OPT_KEY_CACHE_BLOCK_SIZE:
...@@ -8260,7 +8278,11 @@ mysql_getopt_value(const char *keyname, uint key_length, ...@@ -8260,7 +8278,11 @@ mysql_getopt_value(const char *keyname, uint key_length,
{ {
KEY_CACHE *key_cache; KEY_CACHE *key_cache;
if (!(key_cache= get_or_create_key_cache(keyname, key_length))) if (!(key_cache= get_or_create_key_cache(keyname, key_length)))
exit(1); {
if (error)
*error= EXIT_OUT_OF_MEMORY;
return 0;
}
switch (option->id) { switch (option->id) {
case OPT_KEY_BUFFER_SIZE: case OPT_KEY_BUFFER_SIZE:
return (uchar**) &key_cache->param_buff_size; return (uchar**) &key_cache->param_buff_size;
...@@ -8298,7 +8320,7 @@ void option_error_reporter(enum loglevel level, const char *format, ...) ...@@ -8298,7 +8320,7 @@ void option_error_reporter(enum loglevel level, const char *format, ...)
@todo @todo
- FIXME add EXIT_TOO_MANY_ARGUMENTS to "mysys_err.h" and return that code? - FIXME add EXIT_TOO_MANY_ARGUMENTS to "mysys_err.h" and return that code?
*/ */
static void get_options(int *argc,char **argv) static int get_options(int *argc,char **argv)
{ {
int ho_error; int ho_error;
...@@ -8312,7 +8334,7 @@ static void get_options(int *argc,char **argv) ...@@ -8312,7 +8334,7 @@ static void get_options(int *argc,char **argv)
if ((ho_error= handle_options(argc, &argv, my_long_options, if ((ho_error= handle_options(argc, &argv, my_long_options,
mysqld_get_one_option))) mysqld_get_one_option)))
exit(ho_error); return ho_error;
(*argc)++; /* add back one for the progname handle_options removes */ (*argc)++; /* add back one for the progname handle_options removes */
/* no need to do this for argv as we are discarding it. */ /* no need to do this for argv as we are discarding it. */
...@@ -8351,7 +8373,8 @@ static void get_options(int *argc,char **argv) ...@@ -8351,7 +8373,8 @@ static void get_options(int *argc,char **argv)
max_allowed_packet= global_system_variables.max_allowed_packet; max_allowed_packet= global_system_variables.max_allowed_packet;
net_buffer_length= global_system_variables.net_buffer_length; net_buffer_length= global_system_variables.net_buffer_length;
#endif #endif
fix_paths(); if (fix_paths())
return 1;
/* /*
Set some global variables from the global_system_variables Set some global variables from the global_system_variables
...@@ -8378,7 +8401,7 @@ static void get_options(int *argc,char **argv) ...@@ -8378,7 +8401,7 @@ static void get_options(int *argc,char **argv)
&global_system_variables.time_format) || &global_system_variables.time_format) ||
init_global_datetime_format(MYSQL_TIMESTAMP_DATETIME, init_global_datetime_format(MYSQL_TIMESTAMP_DATETIME,
&global_system_variables.datetime_format)) &global_system_variables.datetime_format))
exit(1); return 1;
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
one_thread_scheduler(&thread_scheduler); one_thread_scheduler(&thread_scheduler);
...@@ -8391,6 +8414,7 @@ static void get_options(int *argc,char **argv) ...@@ -8391,6 +8414,7 @@ static void get_options(int *argc,char **argv)
else else
pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */ pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */
#endif #endif
return 0;
} }
...@@ -8454,7 +8478,7 @@ fn_format_relative_to_data_home(char * to, const char *name, ...@@ -8454,7 +8478,7 @@ fn_format_relative_to_data_home(char * to, const char *name,
} }
static void fix_paths(void) static int fix_paths(void)
{ {
char buff[FN_REFLEN],*pos; char buff[FN_REFLEN],*pos;
convert_dirname(mysql_home,mysql_home,NullS); convert_dirname(mysql_home,mysql_home,NullS);
...@@ -8501,12 +8525,12 @@ static void fix_paths(void) ...@@ -8501,12 +8525,12 @@ static void fix_paths(void)
charsets_dir=mysql_charsets_dir; charsets_dir=mysql_charsets_dir;
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir)) if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
exit(1); return 1;
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
if (!slave_load_tmpdir) if (!slave_load_tmpdir)
{ {
if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE)))) if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE))))
exit(1); return 1;
} }
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
/* /*
...@@ -8519,30 +8543,37 @@ static void fix_paths(void) ...@@ -8519,30 +8543,37 @@ static void fix_paths(void)
my_free(opt_secure_file_priv, MYF(0)); my_free(opt_secure_file_priv, MYF(0));
opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE)); opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE));
} }
return 0;
} }
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib, static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
const char *option) const char *option, int *error)
{ {
ulong res; ulong result;
const char **ptr; const char **ptr;
if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0) *error= 0;
if ((result= find_bit_type(x, bit_lib)) == ~(ulong) 0)
{ {
char *buff= (char *) my_alloca(2048);
char *cbuf;
ptr= bit_lib->type_names; ptr= bit_lib->type_names;
if (!*x) cbuf= buff + ((!*x) ?
fprintf(stderr, "No option given to %s\n", option); my_snprintf(buff, 2048, "No option given to %s\n", option) :
else my_snprintf(buff, 2048, "Wrong option to %s. Option(s) given: %s\n",
fprintf(stderr, "Wrong option to %s. Option(s) given: %s\n", option, x); option, x));
fprintf(stderr, "Alternatives are: '%s'", *ptr); cbuf+= my_snprintf(cbuf, 2048 - (cbuf-buff), "Alternatives are: '%s'", *ptr);
while (*++ptr) while (*++ptr)
fprintf(stderr, ",'%s'", *ptr); cbuf+= my_snprintf(cbuf, 2048 - (cbuf-buff), ",'%s'", *ptr);
fprintf(stderr, "\n"); my_snprintf(cbuf, 2048 - (cbuf-buff), "\n");
exit(1); sql_perror(buff);
*error= 1;
my_afree(buff);
return 0;
} }
return res;
return result;
} }
......
...@@ -160,6 +160,9 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables, ...@@ -160,6 +160,9 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables,
table->query_id= thd->query_id; table->query_id= thd->query_id;
table->open_by_handler= 0; table->open_by_handler= 0;
} }
/* Mark table as closed, ready for re-open if necessary. */
tables->table= NULL;
} }
/* /*
...@@ -177,8 +180,7 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables, ...@@ -177,8 +180,7 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables,
'reopen' is set when a handler table is to be re-opened. In this case, 'reopen' is set when a handler table is to be re-opened. In this case,
'tables' is the pointer to the hashed TABLE_LIST object which has been 'tables' is the pointer to the hashed TABLE_LIST object which has been
saved on the original open. saved on the original open.
'reopen' is also used to suppress the sending of an 'ok' message or 'reopen' is also used to suppress the sending of an 'ok' message.
error messages.
RETURN RETURN
FALSE OK FALSE OK
...@@ -214,7 +216,6 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) ...@@ -214,7 +216,6 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
strlen(tables->alias) + 1)) strlen(tables->alias) + 1))
{ {
DBUG_PRINT("info",("duplicate '%s'", tables->alias)); DBUG_PRINT("info",("duplicate '%s'", tables->alias));
if (! reopen)
my_error(ER_NONUNIQ_TABLE, MYF(0), tables->alias); my_error(ER_NONUNIQ_TABLE, MYF(0), tables->alias);
goto err; goto err;
} }
...@@ -259,7 +260,6 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) ...@@ -259,7 +260,6 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
/* There can be only one table in '*tables'. */ /* There can be only one table in '*tables'. */
if (! (tables->table->file->ha_table_flags() & HA_CAN_SQL_HANDLER)) if (! (tables->table->file->ha_table_flags() & HA_CAN_SQL_HANDLER))
{ {
if (! reopen)
my_error(ER_ILLEGAL_HA, MYF(0), tables->alias); my_error(ER_ILLEGAL_HA, MYF(0), tables->alias);
goto err; goto err;
} }
...@@ -479,8 +479,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -479,8 +479,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
if (need_reopen) if (need_reopen)
{ {
mysql_ha_close_table(thd, tables, FALSE); mysql_ha_close_table(thd, hash_tables, FALSE);
hash_tables->table= NULL;
/* /*
The lock might have been aborted, we need to manually reset The lock might have been aborted, we need to manually reset
thd->some_tables_deleted because handler's tables are closed thd->some_tables_deleted because handler's tables are closed
...@@ -761,11 +760,7 @@ void mysql_ha_flush(THD *thd) ...@@ -761,11 +760,7 @@ void mysql_ha_flush(THD *thd)
{ {
hash_tables= (TABLE_LIST*) hash_element(&thd->handler_tables_hash, i); hash_tables= (TABLE_LIST*) hash_element(&thd->handler_tables_hash, i);
if (hash_tables->table && hash_tables->table->needs_reopen_or_name_lock()) if (hash_tables->table && hash_tables->table->needs_reopen_or_name_lock())
{
mysql_ha_close_table(thd, hash_tables, TRUE); mysql_ha_close_table(thd, hash_tables, TRUE);
/* Mark table as closed, ready for re-open. */
hash_tables->table= NULL;
}
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
...@@ -4252,7 +4252,6 @@ convert_search_mode_to_innobase( ...@@ -4252,7 +4252,6 @@ convert_search_mode_to_innobase(
case HA_READ_MBR_WITHIN: case HA_READ_MBR_WITHIN:
case HA_READ_MBR_DISJOINT: case HA_READ_MBR_DISJOINT:
case HA_READ_MBR_EQUAL: case HA_READ_MBR_EQUAL:
my_error(ER_TABLE_CANT_HANDLE_SPKEYS, MYF(0));
return(PAGE_CUR_UNSUPP); return(PAGE_CUR_UNSUPP);
/* do not use "default:" in order to produce a gcc warning: /* do not use "default:" in order to produce a gcc warning:
enumeration value '...' not handled in switch enumeration value '...' not handled in switch
...@@ -5803,7 +5802,7 @@ ha_innobase::records_in_range( ...@@ -5803,7 +5802,7 @@ ha_innobase::records_in_range(
mode2); mode2);
} else { } else {
n_rows = 0; n_rows = HA_POS_ERROR;
} }
dtuple_free_for_mysql(heap1); dtuple_free_for_mysql(heap1);
......
...@@ -1789,6 +1789,8 @@ int ha_myisam::extra(enum ha_extra_function operation) ...@@ -1789,6 +1789,8 @@ int ha_myisam::extra(enum ha_extra_function operation)
{ {
if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_KEYREAD) if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_KEYREAD)
return 0; return 0;
if (operation == HA_EXTRA_MMAP && !opt_myisam_use_mmap)
return 0;
return mi_extra(file, operation, 0); return mi_extra(file, operation, 0);
} }
......
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