From f237ae457a0adc6daaeebb49293da435ef673076 Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Thu, 3 Apr 2003 20:26:13 -0400 Subject: [PATCH 1/4] fux bug #183 --- BitKeeper/etc/logging_ok | 1 + sql/slave.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index a6699f7c515..705b336440b 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -35,5 +35,6 @@ serg@build.mysql2.com serg@serg.mysql.com serg@sergbook.mysql.com sinisa@rhols221.adsl.netsonic.fi +vva@eagle.mysql.r18.ru walrus@mysql.com zak@balfor.local diff --git a/sql/slave.cc b/sql/slave.cc index ac65bd2bdc3..acc443b2296 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1139,7 +1139,7 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) List fields; lev->set_fields(fields); - thd->slave_proxy_id = thd->thread_id; + thd->slave_proxy_id = thread_id; thd->net.vio = net->vio; // mysql_load will use thd->net to read the file thd->net.pkt_nr = net->pkt_nr; From 9f6aa117694308387f13fd9e9d93339c9b5dce19 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Mon, 7 Apr 2003 21:36:45 +0300 Subject: [PATCH 2/4] Changed innobase_flush_log_at_trx_commit to be 1 as default Fixed problem with not freed thr_alarm() on slave connect --- mysql-test/t/rpl_alter.test | 22 +++++++++++----------- sql/ha_innobase.cc | 2 +- sql/mini_client.cc | 12 +++++------- sql/mysqld.cc | 8 ++++++-- sql/slave.cc | 5 +---- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/mysql-test/t/rpl_alter.test b/mysql-test/t/rpl_alter.test index a65605f703e..61ac55843cf 100644 --- a/mysql-test/t/rpl_alter.test +++ b/mysql-test/t/rpl_alter.test @@ -1,21 +1,21 @@ source include/master-slave.inc; connection master; use test; -drop database if exists d1; -create database d1; -create table d1.t1 ( n int); -alter table d1.t1 add m int; -insert into d1.t1 values (1,2); -create table d1.t2 (n int); -insert into d1.t2 values (45); -rename table d1.t2 to d1.t3, d1.t1 to d1.t2; +drop database if exists test_$1; +create database test_$1; +create table test_$1.t1 ( n int); +alter table test_$1.t1 add m int; +insert into test_$1.t1 values (1,2); +create table test_$1.t2 (n int); +insert into test_$1.t2 values (45); +rename table test_$1.t2 to test_$1.t3, test_$1.t1 to test_$1.t2; save_master_pos; connection slave; sync_with_master; -select * from d1.t2; -select * from d1.t3; +select * from test_$1.t2; +select * from test_$1.t3; connection master; -drop database d1; +drop database test_$1; save_master_pos; connection slave; sync_with_master; diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index c0aea197b1f..b8a794a61a0 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -113,7 +113,7 @@ my_bool innobase_fast_shutdown = TRUE; 2 : write to the log file at each commit, but flush to disk only once per second */ -long innobase_flush_log_at_trx_commit = 0; +long innobase_flush_log_at_trx_commit = 1; /* The following counter is used to convey information to InnoDB about server activity: in selects it is not sensible to call diff --git a/sql/mini_client.cc b/sql/mini_client.cc index 453f27822d9..2c74eb96bf9 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -515,8 +515,6 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, host ? host : "(Null)", db ? db : "(Null)", user ? user : "(Null)")); - thr_alarm_init(&alarmed); - thr_alarm(&alarmed,(uint) net_read_timeout,&alarm_buff); bzero((char*) &mysql->options,sizeof(mysql->options)); net->vio = 0; /* If something goes wrong */ @@ -598,7 +596,11 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, host=LOCAL_HOST; sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host); DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port)); - if ((sock = socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR) + thr_alarm_init(&alarmed); + thr_alarm(&alarmed, net_read_timeout, &alarm_buff); + sock = (my_socket) socket(AF_INET,SOCK_STREAM,0); + thr_end_alarm(&alarmed); + if (sock == SOCKET_ERROR) { net->last_errno=CR_IPSOCK_ERROR; sprintf(net->last_error,ER(net->last_errno),socket_errno); @@ -641,12 +643,8 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, socket_errno,host)); net->last_errno= CR_CONN_HOST_ERROR; sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno); - if (thr_alarm_in_use(&alarmed)) - thr_end_alarm(&alarmed); goto error; } - if (thr_alarm_in_use(&alarmed)) - thr_end_alarm(&alarmed); } if (!net->vio || my_net_init(net, net->vio)) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9a227ef5034..a10ad60a3e7 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1433,8 +1433,12 @@ static void *signal_hand(void *arg __attribute__((unused))) my_thread_init(); // Init new thread DBUG_ENTER("signal_hand"); - /* Setup alarm handler */ - init_thr_alarm(max_connections+max_insert_delayed_threads); + /* + Setup alarm handler + This should actually be '+ max_number_of_slaves' instead of +10, + but the +10 should be quite safe. + */ + init_thr_alarm(max_connections+max_insert_delayed_threads+10); #if SIGINT != THR_KILL_SIGNAL (void) sigemptyset(&set); // Setup up SIGINT for debug (void) sigaddset(&set,SIGINT); // For debugging diff --git a/sql/slave.cc b/sql/slave.cc index ac65bd2bdc3..cce13c5ea78 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -784,10 +784,7 @@ static int safe_sleep(THD* thd, int sec) */ thr_alarm(&alarmed, 2 * nap_time,&alarm_buff); sleep(nap_time); - // if we wake up before the alarm goes off, hit the button - // so it will not wake up the wife and kids :-) - if (thr_alarm_in_use(&alarmed)) - thr_end_alarm(&alarmed); + thr_end_alarm(&alarmed); if (slave_killed(thd)) return 1; From 1621dd9818ae4f281b39403d9ec6ad279a9289e5 Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Wed, 23 Apr 2003 00:13:37 +0300 Subject: [PATCH 3/4] Fixed problem with timestamps in binary log on 64 bit machines Backported fix from 4.1 for bug 212: SELECT query containing a NATURAL JOIN and parentheses in the WHERE clause --- mysql-test/r/join.result | 3 +++ mysql-test/t/join.test | 14 ++++++++++++++ sql/log_event.cc | 2 +- sql/log_event.h | 8 ++++---- sql/sql_list.h | 2 ++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index 0c575d7505e..713d7736585 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -41,3 +41,6 @@ rate_code base_rate cust 20 rate_code base_rate cust 20 +ID Value1 ID Value2 +ID Value1 ID Value2 +ID Value1 ID Value2 diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 6a022e690f2..5fe1834873f 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -243,3 +243,17 @@ INSERT INTO t2 VALUES ('rivercats','cust',20); SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND lr.siteid = 'rivercats'; SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE lr.siteid = 'rivercats' AND emp.emp_id = 'psmith'; drop table t1,t2; + +# +# Problem with internal list handling when reducing WHERE +# + +CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, Value1 VARCHAR(255)); +CREATE TABLE t2 (ID INTEGER NOT NULL PRIMARY KEY, Value2 VARCHAR(255)); +INSERT INTO t1 VALUES (1, 'A'); +INSERT INTO t2 VALUES (1, 'B'); + +SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND (Value1 = 'A' AND Value2 <> 'B'); +SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND Value1 = 'A' AND Value2 <> 'B'; +SELECT * FROM t1 NATURAL JOIN t2 WHERE (Value1 = 'A' AND Value2 <> 'B') AND 1; +drop table t1,t2; diff --git a/sql/log_event.cc b/sql/log_event.cc index 7c4c893a823..da25f842bd0 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -304,7 +304,7 @@ void Start_log_event::print(FILE* file, bool short_form, char* last_db) print_header(file); fprintf(file, "\tStart: binlog v %d, server v %s created ", binlog_version, server_version); - print_timestamp(file, (time_t*)&created); + print_timestamp(file, &created); fputc('\n', file); fflush(file); } diff --git a/sql/log_event.h b/sql/log_event.h index 39ab1f7c6b4..68696442490 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -327,13 +327,13 @@ extern char server_version[SERVER_VERSION_LENGTH]; class Start_log_event: public Log_event { public: - uint32 created; + time_t created; uint16 binlog_version; char server_version[50]; Start_log_event() :Log_event(time(NULL)),binlog_version(BINLOG_VERSION) { - created = (uint32) when; + created = (time_t) when; memcpy(server_version, ::server_version, sizeof(server_version)); } Start_log_event(IO_CACHE* file, time_t when_arg, uint32 server_id_arg) : @@ -345,7 +345,7 @@ public: binlog_version = uint2korr(buf+4); memcpy(server_version, buf + 6, sizeof(server_version)); server_version[sizeof(server_version)-1]=0; - created = uint4korr(buf + 6 + sizeof(server_version)); + created = (time_t) uint4korr(buf + 6 + sizeof(server_version)); } Start_log_event(const char* buf); @@ -354,7 +354,7 @@ public: int write_data(IO_CACHE* file); int get_data_size() { - // sizeof(binlog_version) + sizeof(server_version) sizeof(created) + // size(binlog_version) + sizeof(server_version) + size(created) return 2 + sizeof(server_version) + 4; } void print(FILE* file, bool short_form = 0, char* last_db = 0); diff --git a/sql/sql_list.h b/sql/sql_list.h index d21f2e658dc..f6851385f80 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -160,6 +160,8 @@ public: *new_list.last=current->next; current->info=new_list.first->info; current->next=new_list.first->next; + if (list->last == ¤t->next && new_list.elements > 1) + list->last= new_list.last; list->elements+=new_list.elements-1; } return ret_value; // return old element From f88097eee92ac4efbcc38e325f751a60677dab6f Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Sat, 26 Apr 2003 17:57:19 +0300 Subject: [PATCH 4/4] Fix possible memory overrun when reading broken character set files --- mysys/charset.c | 2 +- sql/mysqld.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysys/charset.c b/mysys/charset.c index 9d9ede2b0c4..4cd32e7e3da 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -85,7 +85,7 @@ static my_bool get_word(struct simpleconfig_buf_st *fb, char *buf) endptr = fb->buf; } - while (!isspace(*endptr)) + while (*endptr && !isspace(*endptr)) *buf++= *endptr++; *buf=0; fb->p = endptr; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a10ad60a3e7..4e88a6fcb32 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -785,7 +785,7 @@ void clean_up(bool print_message) if (!opt_bootstrap) (void) my_delete(pidfile_name,MYF(0)); // This may not always exist #endif - if (print_message) + if (print_message && errmesg) sql_print_error(ER(ER_SHUTDOWN_COMPLETE),my_progname); x_free((gptr) my_errmsg[ERRMAPP]); /* Free messages */ my_thread_end();