diff options
author | unknown <cmiller@zippy.cornsilk.net> | 2006-08-17 10:53:12 -0400 |
---|---|---|
committer | unknown <cmiller@zippy.cornsilk.net> | 2006-08-17 10:53:12 -0400 |
commit | 860c385346a41c957ca856e40aa2c001d2ebc957 (patch) | |
tree | 53e78f8f9537035834520b4d555619e9ccdd835b | |
parent | 7faa9efe4b2fbc236960580687583dfa4051303f (diff) | |
parent | c0af010f29d7cabec603b8bc10f9cb955226f2ca (diff) | |
download | mariadb-git-860c385346a41c957ca856e40aa2c001d2ebc957.tar.gz |
Merge zippy.cornsilk.net:/home/cmiller/work/mysql/merge/tmp_merge
into zippy.cornsilk.net:/home/cmiller/work/mysql/merge/mysql-5.0
client/mysql.cc:
Auto merged
tests/mysql_client_test.c:
Auto merged
-rw-r--r-- | client/mysql.cc | 42 | ||||
-rw-r--r-- | server-tools/instance-manager/listener.cc | 8 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 6 |
3 files changed, 47 insertions, 9 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 4ee66cd61dd..6af9be965bb 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -136,7 +136,8 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, tty_password= 0, opt_nobeep=0, opt_reconnect=1, default_charset_used= 0, opt_secure_auth= 0, default_pager_set= 0, opt_sigint_ignore= 0, - show_warnings = 0; + show_warnings= 0; +static volatile int executing_query= 0, interrupted_query= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; static my_string opt_mysql_unix_port=0; @@ -338,6 +339,7 @@ static void end_timer(ulong start_time,char *buff); static void mysql_end_timer(ulong start_time,char *buff); static void nice_time(double sec,char *buff,bool part_second); static sig_handler mysql_end(int sig); +static sig_handler mysql_sigint(int sig); int main(int argc,char *argv[]) @@ -420,7 +422,7 @@ int main(int argc,char *argv[]) if (opt_sigint_ignore) signal(SIGINT, SIG_IGN); else - signal(SIGINT, mysql_end); // Catch SIGINT to clean up + signal(SIGINT, mysql_sigint); // Catch SIGINT to clean up signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up /* @@ -488,6 +490,28 @@ int main(int argc,char *argv[]) #endif } +sig_handler mysql_sigint(int sig) +{ + char kill_buffer[40]; + MYSQL *kill_mysql= NULL; + + signal(SIGINT, mysql_sigint); + + /* terminate if no query being executed, or we already tried interrupting */ + if (!executing_query || interrupted_query++) + mysql_end(sig); + + kill_mysql= mysql_init(kill_mysql); + if (!mysql_real_connect(kill_mysql,current_host, current_user, opt_password, + "", opt_mysql_port, opt_mysql_unix_port,0)) + mysql_end(sig); + /* kill_buffer is always big enough because max length of %lu is 15 */ + sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql)); + mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer)); + mysql_close(kill_mysql); + tee_fprintf(stdout, "Query aborted by Ctrl+C\n"); +} + sig_handler mysql_end(int sig) { mysql_close(&mysql); @@ -1006,6 +1030,8 @@ static int read_and_execute(bool interactive) if (opt_outfile && glob_buffer.is_empty()) fflush(OUTFILE); + interrupted_query= 0; + #if defined( __WIN__) || defined(OS2) || defined(__NETWARE__) tee_fputs(prompt, stdout); #if defined(__NETWARE__) @@ -2007,6 +2033,8 @@ com_go(String *buffer,char *line __attribute__((unused))) timer=start_timer(); + executing_query= 1; + error= mysql_real_query_for_lazy(buffer->ptr(),buffer->length()); #ifdef HAVE_READLINE @@ -2021,6 +2049,7 @@ com_go(String *buffer,char *line __attribute__((unused))) if (error) { buffer->length(0); // Remove query on error + executing_query= 0; return error; } error=0; @@ -2031,13 +2060,19 @@ com_go(String *buffer,char *line __attribute__((unused))) if (quick) { if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql)) + { + executing_query= 0; return put_error(&mysql); + } } else { error= mysql_store_result_for_lazy(&result); if (error) + { + executing_query= 0; return error; + } } if (verbose >= 3 || !opt_silent) @@ -2098,6 +2133,9 @@ com_go(String *buffer,char *line __attribute__((unused))) fflush(stdout); mysql_free_result(result); } while (!(err= mysql_next_result(&mysql))); + + executing_query= 0; + if (err >= 1) error= put_error(&mysql); diff --git a/server-tools/instance-manager/listener.cc b/server-tools/instance-manager/listener.cc index 67d798a1700..500b25bec03 100644 --- a/server-tools/instance-manager/listener.cc +++ b/server-tools/instance-manager/listener.cc @@ -88,7 +88,7 @@ Listener_thread::~Listener_thread() void Listener_thread::run() { - int n= 0; + int i, n= 0; #ifndef __WIN__ /* we use this var to check whether we are running on LinuxThreads */ @@ -117,7 +117,7 @@ void Listener_thread::run() #endif /* II. Listen sockets and spawn childs */ - for (int i= 0; i < num_sockets; i++) + for (i= 0; i < num_sockets; i++) n= max(n, sockets[i]); n++; @@ -176,7 +176,7 @@ void Listener_thread::run() log_info("Listener_thread::run(): shutdown requested, exiting..."); - for (int i= 0; i < num_sockets; i++) + for (i= 0; i < num_sockets; i++) close(sockets[i]); #ifndef __WIN__ @@ -189,7 +189,7 @@ void Listener_thread::run() err: // we have to close the ip sockets in case of error - for (int i= 0; i < num_sockets; i++) + for (i= 0; i < num_sockets; i++) close(sockets[i]); thread_registry.unregister_thread(&thread_info); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 4e9cfeebaf7..f8c091e37f7 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -14927,7 +14927,7 @@ static void test_bug17667() { "insert into bug17667 (c) values ('5 NULs=\0\0\0\0\0')", 48 }, { "/* NUL=\0 with comment */ insert into bug17667 (c) values ('encore')", 67 }, { "drop table bug17667", 19 }, - { NULL, 0 } }; + { NULL, 0 } }; struct buffer_and_length *statement_cursor; FILE *log_file; @@ -14957,8 +14957,8 @@ static void test_bug17667() for (statement_cursor= statements; statement_cursor->buffer != NULL; statement_cursor++) { - char line_buffer[MAX_TEST_QUERY_LENGTH*2]; - /* more than enough room for the query and some marginalia. */ + char line_buffer[MAX_TEST_QUERY_LENGTH*2]; + /* more than enough room for the query and some marginalia. */ do { memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); |