From a90b2f309eed146670390b7d4a31a20192685ac7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 May 2002 15:07:30 +0300 Subject: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. Changed some exit code names and corresponding numbers. Fixed a bug in mysqld.cc, in replication related options. Added a global flag in my_getopt, which can be set by any program that is using my_getopt, which tells whether the client should print the error message itself, or whether my_getopt should do it. The default is that my_getopt will print the error messages. client/mysql.cc: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/mysqladmin.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/mysqlbinlog.cc: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/mysqlcheck.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/mysqldump.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/mysqlimport.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/mysqlmanager-pwgen.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/mysqlmanagerc.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/mysqlshow.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/mysqltest.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. client/thread_test.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. extra/my_print_defaults.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. extra/mysql_install.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. extra/perror.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. extra/resolve_stack_dump.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. extra/resolveip.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. include/my_getopt.h: Added global (flag) variable which tells my_getopt whether to print errors or just silently exit with proper error code. include/mysys_err.h: Changed exit code names and corresponding numbers. isam/isamchk.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. isam/pack_isam.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. myisam/ft_dump.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. myisam/ft_eval.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. myisam/ft_test1.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. myisam/mi_test1.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. myisam/myisamchk.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. myisam/myisampack.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. mysys/my_getopt.c: Changed exit code names and corresponding numbers. Added a flag for checking whether my_getopt should print the error message, or whether it should be printed by the client itself. sql/gen_lex_hash.cc: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. sql/mysqld.cc: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. Fixed a bug when compiling in non-debug mode, some replication related options were not enabled while they should be. This made 'make test' to fail in rpl000010 when --with-debug was not used. tools/mysqlmanager.c: Added useful exit error code for programs using my_getopt in case of an error in option handling. This can sometimes be useful in scripts. --- sql/gen_lex_hash.cc | 9 +++------ sql/mysqld.cc | 8 +------- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'sql') diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index ba1d27f2bf6..a4f0791d105 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -356,7 +356,7 @@ void print_arrays() static void usage(int version) { - printf("%s Ver 3.4 Distrib %s, for %s (%s)\n", + printf("%s Ver 3.5 Distrib %s, for %s (%s)\n", my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); if (version) return; @@ -394,11 +394,8 @@ static int get_options(int argc, char **argv) int ho_error; if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) - { - printf("%s: handle_options() failed with error %d\n", my_progname, - ho_error); - exit(1); - } + exit(ho_error); + if (argc >= 1) { usage(0); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2a118be100a..b8675e99b53 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3053,7 +3053,6 @@ static struct my_option my_long_options[] = */ {"memlock", OPT_MEMLOCK, "Lock mysqld in memory", (gptr*) &locked_in_memory, (gptr*) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, -#ifndef DBUG_OFF {"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT, "Undocumented: Meant for debugging and testing of replication", (gptr*) &disconnect_slave_event_count, @@ -3070,7 +3069,6 @@ static struct my_option my_long_options[] = (gptr*) &opt_sporadic_binlog_dump_fail, (gptr*) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, -#endif {"safemalloc-mem-limit", OPT_SAFEMALLOC_MEM_LIMIT, "Simulate memory shortage when compiled with the --with-debug=full option", 0, 0, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -4421,11 +4419,7 @@ static void get_options(int argc,char **argv) #endif if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) - { - printf("%s: handle_options() failed with error %d\n", my_progname, - ho_error); - exit(1); - } + exit(ho_error); fix_paths(); default_table_type_name=ha_table_typelib.type_names[default_table_type-1]; -- cgit v1.2.1 From 75d312bc1fb3aad87dc36610bf2fc65131ee227f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 May 2002 15:20:36 +0300 Subject: Fixed a bug in make test, non-debug version. sql/slave.cc: Released some variables in non-debug version. These are needed in mysqld.cc my_getopt struct, which defines some options, which are used by mysql_test in a non-debug version. sql/sql_repl.cc: Released some variables in non-debug version. These are needed in mysqld.cc my_getopt struct, which defines some options, which are used by mysql_test in a non-debug version. --- sql/slave.cc | 2 -- sql/sql_repl.cc | 2 -- 2 files changed, 4 deletions(-) (limited to 'sql') diff --git a/sql/slave.cc b/sql/slave.cc index b473d8ab1e3..8a0c95ba49c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -48,12 +48,10 @@ ulong relay_log_space_limit = 0; /* TODO: fix variables to access ulonglong // can re-use them on slave start // TODO: move the vars below under MASTER_INFO -#ifndef DBUG_OFF int disconnect_slave_event_count = 0, abort_slave_event_count = 0; static int events_till_disconnect = -1; int events_till_abort = -1; static int stuck_count = 0; -#endif typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 398ff443ad4..b6c7c98a4cf 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -27,11 +27,9 @@ extern const char* any_db; -#ifndef DBUG_OFF int max_binlog_dump_events = 0; // unlimited bool opt_sporadic_binlog_dump_fail = 0; static int binlog_dump_count = 0; -#endif int check_binlog_magic(IO_CACHE* log, const char** errmsg) { -- cgit v1.2.1 From aea0ae808f28983bbe2d9dcff7f1c83e781903cb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 May 2002 15:21:06 +0300 Subject: Some fixes for user resources management --- sql/sql_parse.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'sql') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 123a95070b9..4b4c085814a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -160,7 +160,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, uc->connections = 1; uc->questions=uc->updates=uc->conn_per_hour=0; uc->user_resources=*mqh; - if (mqh->connections > max_user_connections) + if (max_user_connections && mqh->connections > max_user_connections) uc->user_resources.connections = max_user_connections; uc->intime=thd->thr_create_time; if (hash_insert(&hash_user_connections, (byte*) uc)) @@ -298,7 +298,7 @@ static int check_for_max_user_connections(USER_CONN *uc) goto end; } uc->connections++; -if (uc->user_resources.connections && uc->conn_per_hour++ >= uc->user_resources.connections) + if (uc->user_resources.connections && uc->conn_per_hour++ >= uc->user_resources.connections) { net_printf(¤t_thd->net, ER_USER_LIMIT_REACHED, uc->user, "max_connections", (long) uc->user_resources.connections); @@ -317,12 +317,7 @@ static void decrease_user_connections(USER_CONN *uc) */ DBUG_ENTER("decrease_user_connections"); - if (mqh_used) - { - if (uc->conn_per_hour) - uc->conn_per_hour--; - } - else if (!--uc->connections) + if (!mqh_used && uc->connections && !--uc->connections) { /* Last connection for user; Delete it */ (void) pthread_mutex_lock(&LOCK_user_conn); -- cgit v1.2.1 From b7529249294f20f1b966ea48e46c8e907bae007d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 May 2002 15:29:42 +0300 Subject: Fixed a bug. sql/slave.h: Fixed a bug in option handling. sql/sql_repl.h: Fixed a bug in option handling. --- sql/slave.h | 2 -- sql/sql_repl.h | 2 -- 2 files changed, 4 deletions(-) (limited to 'sql') diff --git a/sql/slave.h b/sql/slave.h index 34df17f2851..16735891815 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -415,9 +415,7 @@ extern bool do_table_inited, ignore_table_inited, wild_do_table_inited, wild_ignore_table_inited; extern bool table_rules_on; -#ifndef DBUG_OFF extern int disconnect_slave_event_count, abort_slave_event_count ; -#endif // the master variables are defaults read from my.cnf or command line extern uint master_port, master_connect_retry, report_port; diff --git a/sql/sql_repl.h b/sql/sql_repl.h index 360fd50a1e3..b15c72a0bde 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -21,10 +21,8 @@ extern uint32 server_id; extern bool server_id_supplied; extern I_List binlog_do_db, binlog_ignore_db; -#ifndef DBUG_OFF extern int max_binlog_dump_events; extern bool opt_sporadic_binlog_dump_fail; -#endif #define KICK_SLAVE(thd) thd->awake(0 /* do not prepare to die*/); -- cgit v1.2.1 From 96a1daa6d255290ed6a1e7ff0ed789b67d4b019f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 May 2002 21:20:28 +0300 Subject: A very nasty bug in multi-table deletes & updates --- sql/sql_parse.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4b4c085814a..3f2d4808cbe 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1792,6 +1792,7 @@ mysql_execute_command(void) tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege); if ((res=open_and_lock_tables(thd,tables))) break; + thd->select_limit=HA_POS_ERROR; if (!setup_fields(thd,tables,select_lex->item_list,1,0,0) && !setup_fields(thd,tables,lex->value_list,0,0,0) && ! thd->fatal_error && (result=new multi_update(thd,tables,select_lex->item_list,lex->duplicates, @@ -2741,7 +2742,7 @@ void mysql_init_multi_delete(LEX *lex) { lex->sql_command = SQLCOM_DELETE_MULTI; mysql_init_select(lex); - lex->select->select_limit=HA_POS_ERROR; + lex->select->select_limit=lex->thd->select_limit=HA_POS_ERROR; lex->auxilliary_table_list=lex->select_lex.table_list; lex->select->table_list.elements=0; lex->select->table_list.first=0; -- cgit v1.2.1 From 0720fe5927cfe4715b2eb3922bddf5268425b9fb Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 May 2002 17:31:25 -0700 Subject: Fixed bug: load table from master w/empty master would hang. Now it properly returns error. Added respective test case. sql/repl_failsafe.cc: fixed bug: load table from master w/ empty master would hang. Now it properly returns error. --- sql/repl_failsafe.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql') diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 257418d1682..fab1491fc2b 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -608,6 +608,9 @@ int show_slave_hosts(THD* thd) int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi) { + if (!mi->host || !*mi->host) /* empty host */ + return 1; + if (!mc_mysql_connect(mysql, mi->host, mi->user, mi->password, 0, mi->port, 0, 0)) { -- cgit v1.2.1