From c89c969b7c886167c67413454d4962d1cf7a54fd Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Thu, 6 Feb 2003 18:50:12 +0200 Subject: [PATCH 01/13] A fix for new conditions being defined and upper condition not updated --- mysql-test/r/type_datetime.result | 1 + mysql-test/t/type_datetime.test | 5 +++++ sql/sql_select.cc | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index dd34bc1cf86..6c461b10930 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -40,3 +40,4 @@ date numfacture expedition 0000-00-00 00:00:00 1212 0001-00-00 00:00:00 table type possible_keys key key_len ref rows Extra t1 ref expedition expedition 8 const 1 where used +a b diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 626dedad547..eed3f831383 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -50,3 +50,8 @@ INSERT INTO t1 (numfacture,expedition) VALUES ('1212','0001-00-00 00:00:00'); SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; drop table t1; +create table t1 (a datetime not null, b datetime not null); +insert into t1 values (now(), now()); +insert into t1 values (now(), now()); +select * from t1 where a is null or b is null; +drop table t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3596fdc0c05..8444a451965 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3009,6 +3009,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) == Item_func::COND_AND_FUNC; List_iterator li(*((Item_cond*) cond)->argument_list()); Item::cond_result tmp_cond_value; + bool should_fix_fields=0; *cond_value=Item::COND_UNDEF; Item *item; @@ -3028,6 +3029,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) delete item; // This may be shared #endif VOID(li.replace(new_item)); + should_fix_fields=1; } if (*cond_value == Item::COND_UNDEF) *cond_value=tmp_cond_value; @@ -3054,6 +3056,9 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) break; /* purecov: deadcode */ } } + if (should_fix_fields) + cond->fix_fields(current_thd,0); + if (!((Item_cond*) cond)->argument_list()->elements || *cond_value != Item::COND_OK) return (COND*) 0; From 58f20edf9ccdb3e8986df2010cbdd16ecd811ce1 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Mon, 10 Feb 2003 17:50:06 +0200 Subject: [PATCH 02/13] connect timeout bug fix --- libmysql/libmysql.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 179a942828c..af964bb9bfa 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -175,6 +175,9 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, * implementations of select that don't adjust tv upon * failure to reflect the time remaining */ +#ifdef HAVE_POLL + return(0); +#endif start_time = time(NULL); for (;;) { From 5376889e281d3115078ebcabe465b553f80a2f51 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Wed, 12 Feb 2003 20:42:46 +0200 Subject: [PATCH 03/13] Fixed YES/NO in Polish messages --- sql/share/polish/errmsg.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index af484b4c850..491068cdcdd 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -7,8 +7,8 @@ "hashchk", "isamchk", -"TAK", "NIE", +"TAK", "Nie można stworzyć pliku '%-.64s' (Kod błędu: %d)", "Nie można stworzyć tabeli '%-.64s' (Kod błędu: %d)", "Nie można stworzyć bazy danych '%-.64s'. Bł?d %d", From 4d83bdef2a357b57d9e5f19ae0f157887b1b3f80 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Tue, 4 Mar 2003 18:23:15 +0200 Subject: [PATCH 04/13] Fix for SHOW VARIABLES on 64-bit platforms --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c188a015ef3..7f7d3225b56 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3162,7 +3162,7 @@ struct show_var_st init_vars[]= { {"record_rnd_buffer", (char*) &record_rnd_cache_size, SHOW_LONG}, {"query_buffer_size", (char*) &query_buff_size, SHOW_LONG}, {"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL}, - {"server_id", (char*) &server_id, SHOW_LONG}, + {"server_id", (char*) &server_id, SHOW_INT}, {"slave_net_timeout", (char*) &slave_net_timeout, SHOW_LONG}, {"skip_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, {"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL}, From 80c34b2aefab3a009b5bc9c5a96318f72fcddf56 Mon Sep 17 00:00:00 2001 From: "serg@serg.mysql.com" <> Date: Tue, 4 Mar 2003 18:02:56 +0100 Subject: [PATCH 05/13] fixed Field::eq() to work with CHAR(0) fields --- .bzrignore | 2 ++ mysql-test/r/delete.result | 4 ++++ mysql-test/t/delete.test | 20 ++++++++++++++++++++ sql/field.h | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/delete.result diff --git a/.bzrignore b/.bzrignore index 5b35d1f6611..7929adbf881 100644 --- a/.bzrignore +++ b/.bzrignore @@ -333,3 +333,5 @@ innobase/autom4te.cache/requests innobase/autom4te.cache/traces.0 innobase/stamp-h1 stamp-h1 +configure.lineno +innobase/configure.lineno diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result new file mode 100644 index 00000000000..169232b72d8 --- /dev/null +++ b/mysql-test/r/delete.result @@ -0,0 +1,4 @@ +bool not_null misc +NULL c 6 +NULL d 7 +bool not_null misc diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 953e22cdd55..13fa617b3cf 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -35,3 +35,23 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); delete from t1 where a=27; drop table t1; + +# +# CHAR(0) bug - not actually DELETE bug, but anyway... +# + +CREATE TABLE t1 ( + bool char(0) default NULL, + not_null varchar(20) binary NOT NULL default '', + misc integer not null, + PRIMARY KEY (not_null) +) TYPE=MyISAM; + +INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7); + +select * from t1 where misc > 5 and bool is null; +delete from t1 where misc > 5 and bool is null; +select * from t1 where misc > 5 and bool is null; + +drop table t1; + diff --git a/sql/field.h b/sql/field.h index e822f6a71d6..fb3cf2178e2 100644 --- a/sql/field.h +++ b/sql/field.h @@ -64,7 +64,7 @@ public: virtual String *val_str(String*,String *)=0; virtual Item_result result_type () const=0; virtual Item_result cmp_type () const { return result_type(); } - bool eq(Field *field) { return ptr == field->ptr; } + bool eq(Field *field) { return ptr == field->ptr && null_ptr == field->null_ptr; } virtual bool eq_def(Field *field); virtual uint32 pack_length() const { return (uint32) field_length; } virtual void reset(void) { bzero(ptr,pack_length()); } From 9034ed296bca8ed505b547519fbf5ef62dcf8e1e Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Wed, 5 Mar 2003 15:34:58 +0200 Subject: [PATCH 06/13] A better, but larger fix for server_id bug .. --- client/mysqlbinlog.cc | 2 +- sql/log_event.h | 2 +- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 6 +++--- sql/sql_repl.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index e05fd63e344..6d1e711fa98 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -33,7 +33,7 @@ extern "C" #endif char server_version[SERVER_VERSION_LENGTH]; -uint32 server_id = 0; +ulong server_id = 0; // needed by net_serv.c ulong bytes_sent = 0L, bytes_received = 0L; diff --git a/sql/log_event.h b/sql/log_event.h index 7cd84a8c001..39ab1f7c6b4 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -59,7 +59,7 @@ enum Int_event_type { INVALID_INT_EVENT = 0, LAST_INSERT_ID_EVENT = 1, INSERT_ID class String; #endif -extern uint32 server_id; +extern ulong server_id; class Log_event { diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 49f1713bbc9..63f3069ef63 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -506,7 +506,7 @@ void sql_perror(const char *message); void sql_print_error(const char *format,...) __attribute__ ((format (printf, 1, 2))); -extern uint32 server_id; +extern ulong server_id; extern char mysql_data_home[2],server_version[SERVER_VERSION_LENGTH], max_sort_char, mysql_real_data_home[]; extern my_string mysql_unix_port,mysql_tmpdir; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7f7d3225b56..0ca8659e7f6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -273,7 +273,7 @@ I_List replicate_do_db, replicate_ignore_db; I_List binlog_do_db, binlog_ignore_db; /* if we guessed server_id , we need to know about it */ -uint32 server_id = 0; +ulong server_id = 0; bool server_id_supplied = 0; uint mysql_port; @@ -3162,7 +3162,7 @@ struct show_var_st init_vars[]= { {"record_rnd_buffer", (char*) &record_rnd_cache_size, SHOW_LONG}, {"query_buffer_size", (char*) &query_buff_size, SHOW_LONG}, {"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL}, - {"server_id", (char*) &server_id, SHOW_INT}, + {"server_id", (char*) &server_id, SHOW_LONG}, {"slave_net_timeout", (char*) &slave_net_timeout, SHOW_LONG}, {"skip_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, {"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL}, @@ -3966,7 +3966,7 @@ static void get_options(int argc,char **argv) break; } case OPT_SERVER_ID: - server_id = atoi(optarg); + server_id = atol(optarg); server_id_supplied = 1; break; case OPT_DELAY_KEY_WRITE: diff --git a/sql/sql_repl.h b/sql/sql_repl.h index aa07d859aec..3b8f161dcd0 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -5,7 +5,7 @@ extern char* master_host; extern my_string opt_bin_logname, master_info_file; -extern uint32 server_id; +extern ulong server_id; extern bool server_id_supplied; extern I_List binlog_do_db, binlog_ignore_db; From 937241aded9234fb305ae9f5cf832dde21f734a6 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Fri, 7 Mar 2003 14:40:37 +0200 Subject: [PATCH 07/13] Fixed an unlikely optimizer bug that casued a core dump in pt_range.cc::sel_cmp() --- mysql-test/r/join.result | 4 ++++ mysql-test/t/join.test | 24 ++++++++++++++++++++++++ sql/opt_range.cc | 12 ++++++++---- sql/sql_rename.cc | 4 ++-- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index 39331fc68e4..0c575d7505e 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -37,3 +37,7 @@ COUNT(t1.Title) t1_id t2_id type cost_unit min_value max_value t3_id item_id id name 22 1 Percent Cost 100 -1 6 291 1 s1 23 1 Percent Cost 100 -1 21 291 1 s1 +rate_code base_rate +cust 20 +rate_code base_rate +cust 20 diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index d31db5c4837..6a022e690f2 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -219,3 +219,27 @@ CREATE TABLE t2 ( INSERT INTO t2 VALUES (1,'s1'),(2,'s2'),(3,'s3'),(4,'s4'),(5,'s5'); select t1.*, t2.* from t1, t2 where t2.id=t1.t2_id limit 2; drop table t1,t2; + +# +# Bug in range optimiser with MAYBE_KEY +# + +CREATE TABLE t1 ( + siteid varchar(25) NOT NULL default '', + emp_id varchar(30) NOT NULL default '', + rate_code varchar(10) default NULL, + UNIQUE KEY site_emp (siteid,emp_id), + KEY siteid (siteid) +) TYPE=MyISAM; +INSERT INTO t1 VALUES ('rivercats','psmith','cust'), ('rivercats','KWalker','cust'); +CREATE TABLE t2 ( + siteid varchar(25) NOT NULL default '', + rate_code varchar(10) NOT NULL default '', + base_rate float NOT NULL default '0', + PRIMARY KEY (siteid,rate_code), + FULLTEXT KEY rate_code (rate_code) +) TYPE=MyISAM; +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; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index b2128c3eb4a..931093d548a 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1341,7 +1341,8 @@ key_and(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag) } if (((clone_flag & CLONE_KEY2_MAYBE) && - !(clone_flag & CLONE_KEY1_MAYBE)) || + !(clone_flag & CLONE_KEY1_MAYBE) && + key2->type != SEL_ARG::MAYBE_KEY) || key1->type == SEL_ARG::MAYBE_KEY) { // Put simple key in key2 swap(SEL_ARG *,key1,key2); @@ -1369,7 +1370,10 @@ key_and(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag) { key1->maybe_smaller(); if (key2->next_key_part) + { + key1->use_count--; // Incremented in and_all_keys return and_all_keys(key1,key2,clone_flag); + } key2->use_count--; // Key2 doesn't have a tree } return key1; @@ -2068,7 +2072,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root) { if (this == root && use_count != 1) { - sql_print_error("Use_count: Wrong count %lu for root",use_count); + sql_print_error("Note: Use_count: Wrong count %lu for root",use_count); return; } if (this->type != SEL_ARG::KEY_RANGE) @@ -2082,7 +2086,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root) ulong count=count_key_part_usage(root,pos->next_key_part); if (count > pos->next_key_part->use_count) { - sql_print_error("Use_count: Wrong count for key at %lx, %lu should be %lu", + sql_print_error("Note: Use_count: Wrong count for key at %lx, %lu should be %lu", pos,pos->next_key_part->use_count,count); return; } @@ -2090,7 +2094,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root) } } if (e_count != elements) - sql_print_error("Wrong use count: %u for tree at %lx", e_count, + sql_print_error("Warning: Wrong use count: %u for tree at %lx", e_count, (gptr) this); } diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 9eee8ccf7ac..c4af966d145 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -122,7 +122,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) if (!access(name,F_OK)) { my_error(ER_TABLE_EXISTS_ERROR,MYF(0),name); - return ren_table; // This can't be skipped + DBUG_RETURN(ren_table); // This can't be skipped } sprintf(name,"%s/%s/%s%s",mysql_data_home, ren_table->db,ren_table->real_name, @@ -131,7 +131,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) { my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno); if (!skip_error) - return ren_table; + DBUG_RETURN(ren_table); } else if (mysql_rename_table(table_type, ren_table->db, ren_table->real_name, From df1ebd2a254ab7a626886e24250e0eebbe2e162f Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Sat, 8 Mar 2003 19:35:44 +0200 Subject: [PATCH 08/13] A correct fix for the timeout problem --- libmysql/libmysql.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index af964bb9bfa..996d395776d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -121,7 +121,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, #if defined(__WIN__) || defined(OS2) return connect(s, (struct sockaddr*) name, namelen); #else - int flags, res, s_err; + int flags, res, s_err, result=0; SOCKOPT_OPTLEN_TYPE s_err_size = sizeof(uint); fd_set sfds; struct timeval tv; @@ -175,19 +175,16 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, * implementations of select that don't adjust tv upon * failure to reflect the time remaining */ -#ifdef HAVE_POLL - return(0); -#endif start_time = time(NULL); for (;;) { tv.tv_sec = (long) timeout; tv.tv_usec = 0; #if defined(HPUX) && defined(THREAD) - if ((res = select(s+1, NULL, (int*) &sfds, NULL, &tv)) >= 0) + if ((result = select(s+1, NULL, (int*) &sfds, NULL, &tv)) >= 0) break; #else - if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0) + if ((result = select(s+1, NULL, &sfds, NULL, &tv)) >= 0) break; #endif now_time=time(NULL); @@ -210,7 +207,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, errno = s_err; return(-1); /* but return an error... */ } - return(0); /* It's all good! */ + return((res) ? res : result); /* It's all good! */ #endif } From e3c64d30a5f6e4546deab872b12d1bf3b238125b Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Sat, 8 Mar 2003 22:37:22 +0200 Subject: [PATCH 09/13] Additional bug fix --- libmysql/libmysql.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 996d395776d..8a85df3c60f 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -207,6 +207,9 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, errno = s_err; return(-1); /* but return an error... */ } + if (res && result > 0) + result=res=0; // We did it in select() !!! + return((res) ? res : result); /* It's all good! */ #endif } From 6b016eb5faea43acb4036c593d175d99acf11672 Mon Sep 17 00:00:00 2001 From: "serg@serg.mysql.com" <> Date: Mon, 10 Mar 2003 00:21:04 +0100 Subject: [PATCH 10/13] .del-stamp-h.in~4a5d6676232516c5: Delete: innobase/stamp-h.in --- innobase/stamp-h.in | 1 - 1 file changed, 1 deletion(-) delete mode 100644 innobase/stamp-h.in diff --git a/innobase/stamp-h.in b/innobase/stamp-h.in deleted file mode 100644 index 9788f70238c..00000000000 --- a/innobase/stamp-h.in +++ /dev/null @@ -1 +0,0 @@ -timestamp From c43b3af78c9db45ed6901c39dbb83066c70fbd74 Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Mon, 10 Mar 2003 11:22:37 +0200 Subject: [PATCH 11/13] Don't allow BACKUP TABLE to overwrite files Fixed memory leak when replication restarts in debug mode --- include/my_sys.h | 1 + mysql-test/mysql-test-run.sh | 4 ++-- mysql-test/r/backup.result | 14 +++++++----- mysql-test/t/backup-master.sh | 5 +++++ mysql-test/t/backup.test | 39 +++++++++++++++++--------------- mysys/my_copy.c | 30 ++++++++++++++++++------- sql/ha_myisam.cc | 42 +++++++++++++++++------------------ sql/slave.cc | 34 +++++++++++++++------------- 8 files changed, 98 insertions(+), 71 deletions(-) create mode 100755 mysql-test/t/backup-master.sh diff --git a/include/my_sys.h b/include/my_sys.h index cd6ec62719a..924a6094416 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -73,6 +73,7 @@ extern int NEAR my_errno; /* Last error in mysys */ #define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */ #define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */ #define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */ +#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy; Don't overwrite file */ #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ #define MY_GIVE_INFO 2 /* Give time info about process*/ diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 8b1c8ff1b44..e6a52ba8756 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -604,7 +604,7 @@ start_slave() $EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT" if [ x$DO_DDD = x1 ] then - $ECHO "set args $master_args" > $GDB_SLAVE_INIT + $ECHO "set args $slave_args" > $GDB_SLAVE_INIT ddd --debugger "gdb -x $GDB_SLAVE_INIT" $SLAVE_MYSQLD & prompt_user "Hit enter to continue after you've started the slave" elif [ x$DO_GDB = x1 ] @@ -746,7 +746,7 @@ run_testcase () stop_master start_master else - if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] ; + if [ ! -z "$EXTRA_MASTER_OPT" ] || [ x$MASTER_RUNNING != x1 ] || [ -f $master_init_script ] then EXTRA_MASTER_OPT="" stop_master diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result index 2bbe15954dc..0d34cd7eae8 100644 --- a/mysql-test/r/backup.result +++ b/mysql-test/r/backup.result @@ -1,10 +1,13 @@ Table Op Msg_type Msg_text -test.t1 backup error Failed copying .frm file: errno = X -test.t1 backup status Operation failed +test.t4 backup error Failed copying .frm file (errno: X) +test.t4 backup status Operation failed Table Op Msg_type Msg_text -test.t1 backup status OK +test.t4 backup status OK Table Op Msg_type Msg_text -test.t1 restore status OK +test.t4 backup error Failed copying .frm file (errno: X) +test.t4 backup status Operation failed +Table Op Msg_type Msg_text +test.t4 restore status OK count(*) 0 Table Op Msg_type Msg_text @@ -18,7 +21,6 @@ n 45 67 Table Op Msg_type Msg_text -test.t1 backup status OK test.t2 backup status OK test.t3 backup status OK Table Op Msg_type Msg_text @@ -40,4 +42,4 @@ k Table Op Msg_type Msg_text test.t1 restore status OK Table Op Msg_type Msg_text -test.t1 backup status OK +test.t5 backup status OK diff --git a/mysql-test/t/backup-master.sh b/mysql-test/t/backup-master.sh new file mode 100755 index 00000000000..99da5857afe --- /dev/null +++ b/mysql-test/t/backup-master.sh @@ -0,0 +1,5 @@ +#!/bin/sh +if [ "$MYSQL_TEST_DIR" ] +then + rm -f $MYSQL_TEST_DIR/var/tmp/*.frm $MYSQL_TEST_DIR/var/tmp/*.MY? +fi diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test index 71343783d69..e4d5be00445 100644 --- a/mysql-test/t/backup.test +++ b/mysql-test/t/backup.test @@ -1,15 +1,23 @@ +# +# This test is a bit tricky as we can't use backup table to overwrite an old +# table +# connect (con1,localhost,root,,); connect (con2,localhost,root,,); connection con1; set SQL_LOG_BIN=0; -drop table if exists t1; +drop table if exists t1,t2,t3,t4; +create table t4(n int); +--replace_result "errno: 2" "errno: X" "errno: 22" "errno: X" "errno: 23" "errno: X" +backup table t4 to '../bogus'; +backup table t4 to '../tmp'; +--replace_result "errno: 17" "errno: X" +backup table t4 to '../tmp'; +drop table t4; +restore table t4 from '../tmp'; +select count(*) from t4; + create table t1(n int); ---replace_result "errno = 2" "errno = X" "errno = 22" "errno = X" "errno = 23" "errno = X" -backup table t1 to '../bogus'; -backup table t1 to '../tmp'; -drop table t1; -restore table t1 from '../tmp'; -select count(*) from t1; insert into t1 values (23),(45),(67); backup table t1 to '../tmp'; drop table t1; @@ -20,29 +28,24 @@ create table t2(m int not null primary key); create table t3(k int not null primary key); insert into t2 values (123),(145),(167); insert into t3 values (223),(245),(267); -backup table t1,t2,t3 to '../tmp'; +backup table t2,t3 to '../tmp'; drop table t1,t2,t3; restore table t1,t2,t3 from '../tmp'; select n from t1; select m from t2; select k from t3; -drop table t1,t2,t3; +drop table t1,t2,t3,t4; restore table t1 from '../tmp'; connection con2; +rename table t1 to t5; --send -lock tables t1 write; +lock tables t5 write; connection con1; --send -backup table t1 to '../tmp'; +backup table t5 to '../tmp'; connection con2; reap; unlock tables; connection con1; reap; -drop table t1; - - - - - - +drop table t5; diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 9b02d84d063..5bc4d1d51fa 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -32,17 +32,29 @@ struct utimbuf { #endif - /* - Ordinary ownership and accesstimes are copied from 'from-file' - if MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then - the modes of to-file isn't changed - Dont set MY_FNABP or MY_NABP bits on when calling this function ! - */ +/* + int my_copy(const char *from, const char *to, myf MyFlags) + + NOTES + Ordinary ownership and accesstimes are copied from 'from-file' + If MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then + the modes of to-file isn't changed + If MyFlags & MY_DONT_OVERWRITE_FILE is set, we will give an error + if the file existed. + + WARNING + Don't set MY_FNABP or MY_NABP bits on when calling this function ! + + RETURN + 0 ok + # Error + +*/ int my_copy(const char *from, const char *to, myf MyFlags) { uint Count; - int new_file_stat; + int new_file_stat, create_flag; File from_file,to_file; char buff[IO_SIZE]; struct stat stat_buff,new_stat_buff; @@ -63,8 +75,10 @@ int my_copy(const char *from, const char *to, myf MyFlags) } if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat) stat_buff=new_stat_buff; + create_flag= (MyFlags & MY_DONT_OVERWRITE_FILE) ? O_EXCL : O_TRUNC; + if ((to_file= my_create(to,(int) stat_buff.st_mode, - O_WRONLY | O_TRUNC | O_BINARY | O_SHARE, + O_WRONLY | create_flag | O_BINARY | O_SHARE, MyFlags)) < 0) goto err; diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 31a8d3c7109..1349e28b546 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -419,38 +419,38 @@ int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt) const char* errmsg = ""; if (!fn_format(dst_path, table_name, backup_dir, reg_ext, 4 + 64)) - { - errmsg = "Failed in fn_format() for .frm file: errno = %d"; - error = HA_ADMIN_INVALID; - goto err; - } + { + errmsg = "Failed in fn_format() for .frm file (errno: %d)"; + error = HA_ADMIN_INVALID; + goto err; + } if (my_copy(fn_format(src_path, table->path,"", reg_ext, 4), - dst_path, - MYF(MY_WME | MY_HOLD_ORIGINAL_MODES ))) + dst_path, + MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_DONT_OVERWRITE_FILE))) { error = HA_ADMIN_FAILED; - errmsg = "Failed copying .frm file: errno = %d"; + errmsg = "Failed copying .frm file (errno: %d)"; goto err; } if (!fn_format(dst_path, table_name, backup_dir, MI_NAME_DEXT, 4 + 64)) - { - errmsg = "Failed in fn_format() for .MYD file: errno = %d"; - error = HA_ADMIN_INVALID; - goto err; - } + { + errmsg = "Failed in fn_format() for .MYD file (errno: %d)"; + error = HA_ADMIN_INVALID; + goto err; + } if (my_copy(fn_format(src_path, table->path,"", MI_NAME_DEXT, 4), dst_path, - MYF(MY_WME | MY_HOLD_ORIGINAL_MODES )) ) - { - errmsg = "Failed copying .MYD file: errno = %d"; - error= HA_ADMIN_FAILED; - goto err; - } + MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_DONT_OVERWRITE_FILE))) + { + errmsg = "Failed copying .MYD file (errno: %d)"; + error= HA_ADMIN_FAILED; + goto err; + } return HA_ADMIN_OK; - err: +err: { MI_CHECK param; myisamchk_init(¶m); @@ -459,7 +459,7 @@ int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt) param.db_name = table->table_cache_key; param.table_name = table->table_name; param.testflag = 0; - mi_check_print_error(¶m,errmsg, errno ); + mi_check_print_error(¶m, errmsg, my_errno); return error; } } diff --git a/sql/slave.cc b/sql/slave.cc index a1972dc5a5d..358a908e0cc 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1270,6 +1270,17 @@ This may also be a network problem, or just a bug in the master or slave code.\ pthread_handler_decl(handle_slave,arg __attribute__((unused))) { + // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff + my_thread_init(); + if (!server_id) + { + pthread_cond_broadcast(&COND_slave_start); + sql_print_error("Server id not set, will not start slave"); + my_thread_end(); + pthread_exit((void*)1); + } + DBUG_ENTER("handle_slave"); + #ifndef DBUG_OFF slave_begin: #endif @@ -1278,20 +1289,14 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused))) char llbuff[22]; pthread_mutex_lock(&LOCK_slave); - if (!server_id) + + if (slave_running) { pthread_cond_broadcast(&COND_slave_start); pthread_mutex_unlock(&LOCK_slave); - sql_print_error("Server id not set, will not start slave"); - pthread_exit((void*)1); + my_thread_end(); + pthread_exit((void*)1); // safety just in case } - - if(slave_running) - { - pthread_cond_broadcast(&COND_slave_start); - pthread_mutex_unlock(&LOCK_slave); - pthread_exit((void*)1); // safety just in case - } slave_running = 1; abort_slave = 0; #ifndef DBUG_OFF @@ -1304,11 +1309,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused))) bool retried_once = 0; ulonglong last_failed_pos = 0; - // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff - my_thread_init(); slave_thd = thd = new THD; // note that contructor of THD uses DBUG_ ! thd->set_time(); - DBUG_ENTER("handle_slave"); pthread_detach_this_thread(); if (init_slave_thread(thd) || init_master_info(&glob_mi)) @@ -1518,18 +1520,18 @@ position %s", abort_slave = 0; save_temporary_tables = thd->temporary_tables; thd->temporary_tables = 0; // remove tempation from destructor to close them - pthread_cond_broadcast(&COND_slave_stopped); // tell the world we are done - pthread_mutex_unlock(&LOCK_slave); net_end(&thd->net); // destructor will not free it, because we are weird slave_thd = 0; (void) pthread_mutex_lock(&LOCK_thread_count); delete thd; (void) pthread_mutex_unlock(&LOCK_thread_count); - my_thread_end(); + pthread_mutex_unlock(&LOCK_slave); + pthread_cond_broadcast(&COND_slave_stopped); // tell the world we are done #ifndef DBUG_OFF if(abort_slave_event_count && !events_till_abort) goto slave_begin; #endif + my_thread_end(); pthread_exit(0); DBUG_RETURN(0); // Can't return anything here } From 11016134146276ed9976859a161d7a891eae55d6 Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Mon, 10 Mar 2003 11:50:46 +0200 Subject: [PATCH 12/13] Better fix for connect timeout problem. --- libmysql/libmysql.c | 71 +++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 8a85df3c60f..c50193c5e2c 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -121,15 +121,16 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, #if defined(__WIN__) || defined(OS2) return connect(s, (struct sockaddr*) name, namelen); #else - int flags, res, s_err, result=0; + int flags, res, s_err; SOCKOPT_OPTLEN_TYPE s_err_size = sizeof(uint); fd_set sfds; struct timeval tv; time_t start_time, now_time; - /* If they passed us a timeout of zero, we should behave - * exactly like the normal connect() call does. - */ + /* + If they passed us a timeout of zero, we should behave + exactly like the normal connect() call does. + */ if (timeout == 0) return connect(s, (struct sockaddr*) name, namelen); @@ -150,30 +151,31 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, if (res == 0) /* Connected quickly! */ return(0); - /* Otherwise, our connection is "in progress." We can use - * the select() call to wait up to a specified period of time - * for the connection to suceed. If select() returns 0 - * (after waiting howevermany seconds), our socket never became - * writable (host is probably unreachable.) Otherwise, if - * select() returns 1, then one of two conditions exist: - * - * 1. An error occured. We use getsockopt() to check for this. - * 2. The connection was set up sucessfully: getsockopt() will - * return 0 as an error. - * - * Thanks goes to Andrew Gierth - * who posted this method of timing out a connect() in - * comp.unix.programmer on August 15th, 1997. - */ + /* + Otherwise, our connection is "in progress." We can use + the select() call to wait up to a specified period of time + for the connection to suceed. If select() returns 0 + (after waiting howevermany seconds), our socket never became + writable (host is probably unreachable.) Otherwise, if + select() returns 1, then one of two conditions exist: + + 1. An error occured. We use getsockopt() to check for this. + 2. The connection was set up sucessfully: getsockopt() will + return 0 as an error. + + Thanks goes to Andrew Gierth + who posted this method of timing out a connect() in + comp.unix.programmer on August 15th, 1997. + */ FD_ZERO(&sfds); FD_SET(s, &sfds); /* - * select could be interrupted by a signal, and if it is, - * the timeout should be adjusted and the select restarted - * to work around OSes that don't restart select and - * implementations of select that don't adjust tv upon - * failure to reflect the time remaining + select could be interrupted by a signal, and if it is, + the timeout should be adjusted and the select restarted + to work around OSes that don't restart select and + implementations of select that don't adjust tv upon + failure to reflect the time remaining */ start_time = time(NULL); for (;;) @@ -181,22 +183,25 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, tv.tv_sec = (long) timeout; tv.tv_usec = 0; #if defined(HPUX) && defined(THREAD) - if ((result = select(s+1, NULL, (int*) &sfds, NULL, &tv)) >= 0) + if ((res = select(s+1, NULL, (int*) &sfds, NULL, &tv)) > 0) break; #else - if ((result = select(s+1, NULL, &sfds, NULL, &tv)) >= 0) + if ((res = select(s+1, NULL, &sfds, NULL, &tv)) > 0) break; #endif + if (res == 0) /* timeout */ + return -1; now_time=time(NULL); timeout-= (uint) (now_time - start_time); if (errno != EINTR || (int) timeout <= 0) return -1; } - /* select() returned something more interesting than zero, let's - * see if we have any errors. If the next two statements pass, - * we've got an open socket! - */ + /* + select() returned something more interesting than zero, let's + see if we have any errors. If the next two statements pass, + we've got an open socket! + */ s_err=0; if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*) &s_err, &s_err_size) != 0) @@ -207,10 +212,8 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, errno = s_err; return(-1); /* but return an error... */ } - if (res && result > 0) - result=res=0; // We did it in select() !!! - - return((res) ? res : result); /* It's all good! */ + return (0); /* ok */ + #endif } From c231b747e3d5bea9bf636528bf5491dd29ebab8e Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Mon, 10 Mar 2003 12:24:22 +0200 Subject: [PATCH 13/13] Don't allow multiple --user options to mysqld (First one is used) --- scripts/safe_mysqld.sh | 8 ++++++-- sql/mysqld.cc | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/safe_mysqld.sh b/scripts/safe_mysqld.sh index c1b231eb001..a8ca3537cb3 100644 --- a/scripts/safe_mysqld.sh +++ b/scripts/safe_mysqld.sh @@ -33,8 +33,12 @@ parse_arguments() { --basedir=*) MY_BASEDIR_VERSION=`echo "$arg" | sed -e "s;--[^=]*=;;"` ;; --datadir=*) DATADIR=`echo "$arg" | sed -e "s;--[^=]*=;;"` ;; --pid-file=*) pid_file=`echo "$arg" | sed -e "s;--[^=]*=;;"` ;; - --user=*) user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1 ;; - + --user=*) + if [ $SET_USER == 0 ] + then + user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1 + fi + ;; # these two might have been set in a [safe_mysqld] section of my.cnf # they get passed via environment variables to safe_mysqld --socket=*) MYSQL_UNIX_PORT=`echo "$arg" | sed -e "s;--[^=]*=;;"` ;; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0ca8659e7f6..83933e6e8ad 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3639,7 +3639,10 @@ static void get_options(int argc,char **argv) use_temp_pool=1; break; case 'u': - mysqld_user=optarg; + if (!mysqld_user) + mysqld_user=optarg; + else + fprintf(stderr, "Warning: Ignoring user change to '%s' becasue the user is set to '%s' earlier on the command line\n", optarg, mysqld_user); break; case 'v': case 'V':