From bf5be93a133c5c55f8ae4533d5df53e01ffd0f36 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Sat, 27 Sep 2003 17:16:19 +0200 Subject: [PATCH 1/4] backport of a fix made in 4.0 to make replication work in 64-bit binaries. The 4.0 changeset was: ChangeSet@1.1579.3.1, 2003-09-26 23:43:22+02:00, guilhem@mysql.com Fix for 64-bit machines. I am almost sure this is the cause for BUG#1381 [Opn]: Bug in replication on HP-UX 64 bit binaries? BUG#1256 [CRp]: Replication slave fails to connect to master in 64-bit version (Solaris) The reason why I think it's wrong is that the normal client code has uint32 ip_addr. (of course on 32-bit machines it does not matter, but on 64-bit it does). --- sql/mini_client.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mini_client.cc b/sql/mini_client.cc index 2c74eb96bf9..c7beeea37b8 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -496,7 +496,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, { char buff[100],*end,*host_info; my_socket sock; - ulong ip_addr; + uint32 ip_addr; struct sockaddr_in sock_addr; uint pkt_length; NET *net= &mysql->net; From 293f27df35a2bddf3226b2854a163db910699275 Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Mon, 29 Sep 2003 15:42:33 -0400 Subject: [PATCH 2/4] fixed processing of COM_BINLOG_DUMP to use in mysqlbinlog --- sql/sql_parse.cc | 3 ++- sql/sql_repl.cc | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 81233c038a1..3f6fa8d24ad 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -929,7 +929,8 @@ bool do_command(THD *thd) pos = uint4korr(packet + 1); flags = uint2korr(packet + 5); pthread_mutex_lock(&LOCK_server_id); - kill_zombie_dump_threads(slave_server_id = uint4korr(packet+7)); + if ((slave_server_id = uint4korr(packet+7))) + kill_zombie_dump_threads(slave_server_id); thd->server_id = slave_server_id; pthread_mutex_unlock(&LOCK_server_id); mysql_binlog_send(thd, thd->strdup(packet + 11), pos, flags); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 1940ff360c2..ec5d45bca90 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -442,6 +442,11 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags) break; case LOG_READ_EOF: DBUG_PRINT("wait",("waiting for data on binary log")); + if (thd->server_id==0) + { + pthread_mutex_unlock(log_lock); + goto end; + } if (!thd->killed) pthread_cond_wait(&COND_binlog_update, log_lock); break; @@ -523,6 +528,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags) } } +end: end_io_cache(&log); (void)my_close(file, MYF(MY_WME)); @@ -532,7 +538,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags) thd->current_linfo = 0; pthread_mutex_unlock(&LOCK_thread_count); DBUG_VOID_RETURN; - err: +err: thd->proc_info = "waiting to finalize termination"; end_io_cache(&log); pthread_mutex_lock(&LOCK_thread_count); From 498e1c6d959ebc57968637b4b90624751ad6b875 Mon Sep 17 00:00:00 2001 From: "monty@mishka.mysql.fi" <> Date: Wed, 8 Oct 2003 21:02:53 +0300 Subject: [PATCH 3/4] Fixed memory leak in send_file --- BitKeeper/etc/logging_ok | 1 + mysql-test/t/myisam.test | 3 +-- sql/sql_repl.cc | 9 +-------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 8238e85a5be..777c590ce62 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -22,6 +22,7 @@ monty@bitch.mysql.fi monty@donna.mysql.fi monty@hundin.mysql.fi monty@mashka.mysql.fi +monty@mishka.mysql.fi monty@narttu. monty@narttu.mysql.fi monty@tik. diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index c9cb77d2a3a..e6772c4c0ac 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -284,5 +284,4 @@ insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "Sergei"); -drop table if exists t1; - +drop table t1; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 1940ff360c2..49e13f0e415 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -66,10 +66,10 @@ static int send_file(THD *thd) NET* net = &thd->net; int fd = -1,bytes, error = 1; char fname[FN_REFLEN+1]; - char *buf; const char *errmsg = 0; int old_timeout; uint packet_len; + char buf[IO_SIZE]; // It's safe to alloc this DBUG_ENTER("send_file"); // the client might be slow loading the data, give him wait_timeout to do @@ -77,13 +77,6 @@ static int send_file(THD *thd) old_timeout = thd->net.timeout; thd->net.timeout = thd->inactive_timeout; - // spare the stack - if(!(buf = alloc_root(&thd->mem_root,IO_SIZE))) - { - errmsg = "Out of memory"; - goto err; - } - // we need net_flush here because the client will not know it needs to send // us the file name until it has processed the load event entry if (net_flush(net) || (packet_len = my_net_read(net)) == packet_error) From d0a21a0aeb883602345484a2015d6a4ad80d7f68 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Mon, 20 Oct 2003 15:35:03 +0200 Subject: [PATCH 4/4] Fix for Bug #1595 "mysqlbinlog can't read a password from the console". Make mysqlbinlog prompt for the password if mysqlbinlog -p instead of printing the usage(). This makes mysqlbinlog behave like other clients, which is the reason why we fix this in 3.23. This new code was almost copied from mysqldump. Note that before, one could use mysqlbinlog -p pass and now one must use mysqlbinlog -ppass (putting a space will ask for the password). --- client/mysqlbinlog.cc | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 6d1e711fa98..e0cee438f1b 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -54,7 +54,7 @@ static struct option long_options[] = {"help", no_argument, 0, '?'}, {"host", required_argument, 0, 'h'}, {"offset", required_argument, 0, 'o'}, - {"password", required_argument, 0, 'p'}, + {"password", optional_argument, 0, 'p'}, {"port", required_argument, 0, 'P'}, {"position", required_argument, 0, 'j'}, {"result-file", required_argument, 0, 'r'}, @@ -71,7 +71,7 @@ static ulonglong offset = 0; static const char* host = "localhost"; static int port = MYSQL_PORT; static const char* user = "test"; -static const char* pass = ""; +static char* pass = 0; static ulonglong position = 0; static bool use_remote = 0; static short binlog_flags = 0; @@ -84,6 +84,7 @@ static void dump_log_entries(const char* logname); static void dump_remote_file(NET* net, const char* fname); static void dump_remote_table(NET* net, const char* db, const char* table); static void die(const char* fmt, ...); +static void cleanup(); static MYSQL* safe_connect(); @@ -97,6 +98,11 @@ void sql_print_error(const char *format,...) va_end(args); } +static void cleanup() +{ + my_free(pass,MYF(MY_ALLOW_ZERO_PTR)); +} + static void die(const char* fmt, ...) { va_list args; @@ -105,6 +111,7 @@ static void die(const char* fmt, ...) vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); + cleanup(); exit(1); } @@ -177,9 +184,10 @@ static void dump_remote_file(NET* net, const char* fname) static int parse_args(int *argc, char*** argv) { int c, opt_index = 0; + bool tty_password= 0; result_file = stdout; - while((c = getopt_long(*argc, *argv, "so:#::h:j:u:p:P:r:t:?V", long_options, + while((c = getopt_long(*argc, *argv, "so:#::h:j:u:p::P:r:t:?V", long_options, &opt_index)) != EOF) { switch(c) @@ -213,7 +221,17 @@ static int parse_args(int *argc, char*** argv) case 'p': use_remote = 1; - pass = my_strdup(optarg, MYF(0)); + if (optarg) + { + char *start=optarg; + my_free(pass,MYF(MY_ALLOW_ZERO_PTR)); + pass= my_strdup(optarg,MYF(MY_FAE)); + while (*optarg) *optarg++= 'x'; /* Destroy argument */ + if (*start) + start[1]=0; /* Cut length of argument */ + } + else + tty_password=1; break; case 'r': @@ -244,6 +262,8 @@ static int parse_args(int *argc, char*** argv) (*argc)-=optind; (*argv)+=optind; + if (tty_password) + pass= get_tty_password(NullS); return 0; } @@ -457,6 +477,7 @@ int main(int argc, char** argv) my_fclose(result_file, MYF(0)); if (use_remote) mysql_close(mysql); + cleanup(); return 0; }