From cf97cbd1db762c443aa3c1412f3e788559aaa5dd Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Mar 2003 02:51:16 +0200 Subject: [PATCH 01/11] Fix of 'halloween bug' with UPDATE of InnoDB tables. mysql-test/r/innodb.result: Test of 'halloween bug' mysql-test/t/innodb.test: Test of 'halloween bug' strings/strto.c: Portability fix --- mysql-test/r/innodb.result | 10 ++++++++++ mysql-test/t/innodb.test | 11 +++++++++++ sql/key.cc | 8 ++++++++ strings/strto.c | 2 ++ 4 files changed, 31 insertions(+) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 0930e3aa5fd..06663e36007 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -501,3 +501,13 @@ table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 4 Field Type Null Key Default Extra testint int(11) 1 +a b +1 1 +102 2 +103 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index a962f120d4e..0362ec69ebf 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -537,3 +537,14 @@ drop table t1; create table t1 (testint int not null default 1) type=innodb; desc t1; drop table t1; + +# +# Check update with conflicting key +# + +CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) type=innodb; +INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); +# We need the a < 1000 test here to quard against the halloween problems +UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000; +SELECT * from t1; +drop table t1; diff --git a/sql/key.cc b/sql/key.cc index f2488ab74cb..9f5379487c3 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -269,5 +269,13 @@ bool check_if_key_used(TABLE *table, uint idx, List &fields) return 1; } } + + /* + If table handler has primary key as part of the index, check that primary + key is not updated + */ + if (idx != table->primary_key && table->primary_key < MAX_KEY && + (table->file->option_flag() & HA_PRIMARY_KEY_IN_READ_INDEX)) + return check_if_key_used(table, table->primary_key, fields); return 0; } diff --git a/strings/strto.c b/strings/strto.c index d3392c794e9..54ff2214f60 100644 --- a/strings/strto.c +++ b/strings/strto.c @@ -36,6 +36,8 @@ it can be compiled with the UNSIGNED and/or LONGLONG flag set */ +#define strtoll glob_strtoll /* Fix for True64 */ + #include #include "m_string.h" #include "m_ctype.h" From 8f739cd674ad03cc19f92038bb4e29dd7995a82f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Mar 2003 15:16:51 +0100 Subject: [PATCH 02/11] Do not silently do RESET MASTER when one does 'mysqldump --master-data' ; only do it if the user specifies --delete-master-logs (new option). Safer + fixes bug #159. client/client_priv.h: New option --delete-master-logs for mysqldump client/mysqldump.c: New option --delete-master-logs for mysqldump BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + client/client_priv.h | 3 ++- client/mysqldump.c | 25 +++++++++++++++++-------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 3f58a7aea48..a6699f7c515 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -5,6 +5,7 @@ bar@bar.mysql.r18.ru bar@bar.udmsearch.izhnet.ru bell@sanja.is.com.ua bk@admin.bk +guilhem@mysql.com heikki@donna.mysql.fi heikki@hundin.mysql.fi jani@hynda.mysql.fi diff --git a/client/client_priv.h b/client/client_priv.h index 56eaf311070..147670005f2 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -30,4 +30,5 @@ enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS, OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE, OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES, - OPT_MASTER_DATA, OPT_AUTOCOMMIT, OPT_LOCAL_INFILE}; + OPT_MASTER_DATA, OPT_AUTOCOMMIT, OPT_LOCAL_INFILE, + OPT_DELETE_MASTER_LOGS}; diff --git a/client/mysqldump.c b/client/mysqldump.c index d7d54a13c57..34f01e1581b 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -73,7 +73,8 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0, ignore=0,opt_drop=0,opt_keywords=0,opt_lock=0,opt_compress=0, opt_delayed=0,create_options=0,opt_quoted=0,opt_databases=0, opt_alldbs=0,opt_create_db=0,opt_first_slave=0, - opt_autocommit=0,opt_master_data,opt_disable_keys=0,opt_xml=0; + opt_autocommit=0,opt_master_data,opt_disable_keys=0,opt_xml=0, + opt_delete_master_logs=0; static MYSQL mysql_connection,*sock=0; static char insert_pat[12 * 1024],*opt_password=0,*current_user=0, *current_host=0,*path=0,*fields_terminated=0, @@ -101,6 +102,7 @@ static struct option long_options[] = {"debug", optional_argument, 0, '#'}, {"default-character-set", required_argument, 0, OPT_DEFAULT_CHARSET}, {"delayed-insert", no_argument, 0, OPT_DELAYED}, + {"delete-master-logs", no_argument, 0, OPT_DELETE_MASTER_LOGS}, {"disable-keys", no_argument, 0, 'K'}, {"extended-insert", no_argument, 0, 'e'}, {"fields-terminated-by", required_argument, 0, (int) OPT_FTB}, @@ -206,9 +208,12 @@ static void usage(void) --add-locks Add locks around insert statements.\n\ --allow-keywords Allow creation of column names that are keywords.\n\ --delayed-insert Insert rows with INSERT DELAYED.\n\ + --delete-master-logs Issue RESET MASTER on the master just after taking\n\ + the dump, and before unlocking tables.\n\ + This will automatically enable --first-slave.\n\ --master-data This will cause the master position and filename to \n\ - be appended to your output. This will automagically \n\ - enable --first-slave.\n\ + be appended to your output, before unlocking tables.\n\ + This will automatically enable --first-slave.\n\ -F, --flush-logs Flush logs file in server before starting dump.\n\ -f, --force Continue even if we get an sql-error.\n\ -h, --host=... Connect to host.\n"); @@ -317,6 +322,10 @@ static int get_options(int *argc,char ***argv) opt_master_data=1; opt_first_slave=1; break; + case OPT_DELETE_MASTER_LOGS: + opt_delete_master_logs=1; + opt_first_slave=1; + break; case OPT_AUTOCOMMIT: opt_autocommit=1; break; @@ -1489,6 +1498,11 @@ int main(int argc, char **argv) if (opt_first_slave) { + if (opt_delete_master_logs && mysql_query(sock, "FLUSH MASTER")) + { + my_printf_error(0, "Error: Couldn't execute 'FLUSH MASTER': %s", + MYF(0), mysql_error(sock)); + } if (opt_master_data) { if (mysql_query(sock, "SHOW MASTER STATUS") || @@ -1511,11 +1525,6 @@ int main(int argc, char **argv) mysql_free_result(master); } } - if (mysql_query(sock, "FLUSH MASTER")) - { - my_printf_error(0, "Error: Couldn't execute 'FLUSH MASTER': %s", - MYF(0), mysql_error(sock)); - } if (mysql_query(sock, "UNLOCK TABLES")) { my_printf_error(0, "Error: Couldn't execute 'UNLOCK TABLES': %s", From 3b0438c8dd343da6ff77480ce3a814dbc11a0e42 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Mar 2003 23:24:45 +0200 Subject: [PATCH 03/11] Fixed bug that binary log was not locked during a DELETE FROM TABLE_NAME; --- sql/sql_delete.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 278e98533c9..2372e908152 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -30,6 +30,7 @@ int generate_table(THD *thd, TABLE_LIST *table_list, TABLE *locked_table) char path[FN_REFLEN]; int error; TABLE **table_ptr; + my_bool lock_open_locked= 0; DBUG_ENTER("generate_table"); thd->proc_info="generate_table"; @@ -102,7 +103,7 @@ int generate_table(THD *thd, TABLE_LIST *table_list, TABLE *locked_table) error= ha_create_table(path,&create_info,1) ? -1 : 0; if (thd->locked_tables && reopen_tables(thd,1,0)) error= -1; - VOID(pthread_mutex_unlock(&LOCK_open)); + lock_open_locked= 1; // Unlock mutex before return } if (!error) { @@ -114,6 +115,8 @@ int generate_table(THD *thd, TABLE_LIST *table_list, TABLE *locked_table) } send_ok(&thd->net); // This should return record count } + if (lock_open_locked) + VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(error ? -1 : 0); } From f9df0feecbdd8c576d043731558a8d1b80b78be2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Mar 2003 14:49:43 +0200 Subject: [PATCH 04/11] A fix for a bug in MyISAM with large number of NULL columns and at least one BLOB column. --- myisam/mi_dynrec.c | 4 ++-- mysql-test/t/myisam.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index c9fe493744d..4f321c268f1 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -62,8 +62,8 @@ int _mi_write_blob_record(MI_INFO *info, const byte *record) extra=ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+ MI_DYN_DELETE_BLOCK_HEADER+1; - reclength=info->s->base.pack_reclength+ - _my_calc_total_blob_length(info,record)+ extra; + reclength= (info->s->base.pack_reclength+ info->s->base.pack_bits+ + _my_calc_total_blob_length(info,record)+ extra); if (reclength > MI_DYN_MAX_ROW_LENGTH) { my_errno=HA_ERR_TO_BIG_ROW; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 92f22d35b81..c9cb77d2a3a 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -244,7 +244,7 @@ int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974 int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982 int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990 int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998 -int, i999 int, i1000 int) row_format=dynamic; +int, i999 int, i1000 int, b blob) row_format=dynamic; 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, @@ -283,6 +283,6 @@ 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, 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; From 241b6c058dc24f67687a6c9a5e6411066b6a5eca Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Apr 2003 18:19:15 +0200 Subject: [PATCH 05/11] Small-and-safe fix for bug #218: "LOAD DATA INFILE IGNORE is well logged, but read as LOAD DATA INFILE REPLACE" This was just bad && instead of &, but nasty consequences. This should be merged to 4.0 BUT it will not be automatic (some code has moved from log_event.h to log_event.cc, and log_event.cc has changed); please Merging Man, do 'bk grep REPLACE_FLAG' in 4.0/sql to find all the new places. sql/log_event.cc: & instead of && when testing flags sql/slave.cc: & instead of && when testing flags --- sql/log_event.cc | 6 +++--- sql/slave.cc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index c30d03adaf5..7c4c893a823 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -671,9 +671,9 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) fprintf(file, "LOAD DATA INFILE '%s' ", fname); - if(sql_ex.opt_flags && REPLACE_FLAG ) + if(sql_ex.opt_flags & REPLACE_FLAG ) fprintf(file," REPLACE "); - else if(sql_ex.opt_flags && IGNORE_FLAG ) + else if(sql_ex.opt_flags & IGNORE_FLAG ) fprintf(file," IGNORE "); fprintf(file, "INTO TABLE %s ", table_name); @@ -685,7 +685,7 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) if(!(sql_ex.empty_flags & ENCLOSED_EMPTY)) { - if(sql_ex.opt_flags && OPT_ENCLOSED_FLAG ) + if(sql_ex.opt_flags & OPT_ENCLOSED_FLAG ) fprintf(file," OPTIONALLY "); fprintf(file, " ENCLOSED BY "); pretty_print_char(file, sql_ex.enclosed); diff --git a/sql/slave.cc b/sql/slave.cc index 358a908e0cc..ac65bd2bdc3 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1100,9 +1100,9 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) else { enum enum_duplicates handle_dup = DUP_IGNORE; - if(lev->sql_ex.opt_flags && REPLACE_FLAG) + if(lev->sql_ex.opt_flags & REPLACE_FLAG) handle_dup = DUP_REPLACE; - sql_exchange ex((char*)lev->fname, lev->sql_ex.opt_flags && + sql_exchange ex((char*)lev->fname, lev->sql_ex.opt_flags & DUMPFILE_FLAG ); String field_term(&lev->sql_ex.field_term, 1), enclosed(&lev->sql_ex.enclosed, 1), From 68fc04c4236b57a3a83d5731fb991329d6be95ef Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Apr 2003 12:10:38 +0300 Subject: [PATCH 06/11] Portability fix (for AMD hammer) sql/log.cc: Portability fix (for hammer) --- sql/log.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/log.cc b/sql/log.cc index 5e5d5b9368e..f72917427b7 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1067,6 +1067,7 @@ void sql_print_error(const char *format,...) char buff[1024]; my_vsnprintf(buff,sizeof(buff)-1,format,args); DBUG_PRINT("error",("%s",buff)); + va_start(args,format); } #endif skr=time(NULL); From 2090bc6e4347fe69189302a5b520ae3051785746 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Apr 2003 13:07:42 +0300 Subject: [PATCH 07/11] Fixed bug in memory allocation that could affect 64 bit systems (affected hammer) mysys/my_vsnprintf.c: safety fix sql/log.cc: safety fix --- mysys/my_vsnprintf.c | 9 ++++++++- sql/ha_myisam.cc | 2 +- sql/log.cc | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mysys/my_vsnprintf.c b/mysys/my_vsnprintf.c index ab8edec4d7b..9bc33e28ba1 100644 --- a/mysys/my_vsnprintf.c +++ b/mysys/my_vsnprintf.c @@ -21,13 +21,18 @@ #include #include + int my_snprintf(char* to, size_t n, const char* fmt, ...) { + int result; va_list args; va_start(args,fmt); - return my_vsnprintf(to, n, fmt, args); + result= my_vsnprintf(to, n, fmt, args); + va_end(args); + return result; } + int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) { char *start=to, *end=to+n-1; @@ -79,6 +84,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) return (uint) (to - start); } + #ifdef MAIN static void my_printf(const char * fmt, ...) { @@ -92,6 +98,7 @@ static void my_printf(const char * fmt, ...) va_end(ar); } + int main() { diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 895558320fd..d0d68156bac 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -953,7 +953,7 @@ int ha_myisam::create(const char *name, register TABLE *form, &keydef, form->keys*sizeof(MI_KEYDEF), &keyseg, ((form->key_parts + form->keys) * sizeof(MI_KEYSEG)), - 0))) + NullS))) DBUG_RETURN(1); pos=form->key_info; diff --git a/sql/log.cc b/sql/log.cc index f72917427b7..d189f1f1fe3 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1067,6 +1067,7 @@ void sql_print_error(const char *format,...) char buff[1024]; my_vsnprintf(buff,sizeof(buff)-1,format,args); DBUG_PRINT("error",("%s",buff)); + va_end(args); va_start(args,format); } #endif From 654d1026e4517c760372b828fe3c9457aa86972b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Apr 2003 20:26:13 -0400 Subject: [PATCH 08/11] fux bug #183 BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- 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 da68e3d69ff23aa89322bc4460a214aa57798c5b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Apr 2003 21:36:45 +0300 Subject: [PATCH 09/11] 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: Changed name of created test database sql/ha_innobase.cc: Changed innobase_flush_log_at_trx_commit to be 1 as default sql/mini_client.cc: Fixed problem with not freed thr_alarm() sql/mysqld.cc: Allocate some extra thr_alarm slots just to be safe sql/slave.cc: Simple code cleanup --- 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 963d57a39446490ce2fb91c773ac2466c3723aa1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Apr 2003 00:13:37 +0300 Subject: [PATCH 10/11] 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: New test results mysql-test/t/join.test: Test for bug 212 sql/log_event.cc: Removed wrong cast sql/log_event.h: Fixed problem with timestamps in binary log on 64 bit machines sql/sql_list.h: Fix for bug 212 (back ported from 4.1) --- 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 418467e32ad8617c1546870f1b24493601ca4d47 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Apr 2003 17:57:19 +0300 Subject: [PATCH 11/11] Fix possible memory overrun when reading broken character set files sql/mysqld.cc: Safety fix. --- 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();