From 45e3de8f32d40986ba6755adba6856cc71bd086d Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Wed, 19 Mar 2003 15:16:51 +0100 Subject: [PATCH 1/5] 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. --- 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 8b5ce819db3c8f5e74f5241157a5f3ecf8f7c0c3 Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Mon, 24 Mar 2003 23:24:45 +0200 Subject: [PATCH 2/5] 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 a496daf777c64a3bfdd89ea084023c6c40e15460 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Tue, 25 Mar 2003 14:49:43 +0200 Subject: [PATCH 3/5] 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 1211b9a513df1b17198235375770a0ddf585a789 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Tue, 1 Apr 2003 18:19:15 +0200 Subject: [PATCH 4/5] 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 | 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 3cdc8ae55b4fd0d711b9784897e3c4a1481ccb04 Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Thu, 3 Apr 2003 12:10:38 +0300 Subject: [PATCH 5/5] Portability fix (for AMD 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);