From 530accbaae6d243885d5bcc5b04d55b61bd87ce7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 May 2003 14:54:02 -0400 Subject: fixed 'STARTING BY' in replication mysql-test/r/rpl_loaddata.result: added test for 'STARTING BY' mysql-test/std_data/rpl_loaddata2.dat: added test for 'STARTING BY' mysql-test/t/rpl_loaddata.test: added test for 'STARTING BY' sql/log_event.cc: fixed 'STARTING BY' --- sql/log_event.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/log_event.cc b/sql/log_event.cc index 3b499b8d502..dfa44e19ffc 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -309,15 +309,19 @@ void Load_log_event::pack_info(String* packet) pretty_print_str(&tmp, sql_ex.escaped, sql_ex.escaped_len); } + bool line_lexem_added= false; if (sql_ex.line_term_len) { tmp.append(" LINES TERMINATED BY "); pretty_print_str(&tmp, sql_ex.line_term, sql_ex.line_term_len); + line_lexem_added= true; } if (sql_ex.line_start_len) { - tmp.append(" LINES STARTING BY "); + if (!line_lexem_added) + tmp.append(" LINES"); + tmp.append(" STARTING BY "); pretty_print_str(&tmp, sql_ex.line_start, sql_ex.line_start_len); } @@ -1299,15 +1303,19 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) pretty_print_str(file, sql_ex.escaped, sql_ex.escaped_len); } + bool line_lexem_added= false; if (sql_ex.line_term) { fprintf(file," LINES TERMINATED BY "); pretty_print_str(file, sql_ex.line_term, sql_ex.line_term_len); + line_lexem_added= true; } if (sql_ex.line_start) { - fprintf(file," LINES STARTING BY "); + if (!line_lexem_added) + fprintf(file," LINES"); + fprintf(file," STARTING BY "); pretty_print_str(file, sql_ex.line_start, sql_ex.line_start_len); } -- cgit v1.2.1 From bddd75d28eba0c5dade8facd7484d0ad67f20176 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 May 2003 15:16:56 -0400 Subject: fixed "LINES STARTING" in load data replication BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- sql/log_event.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/log_event.cc b/sql/log_event.cc index 7c4c893a823..9cf67e78029 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -697,15 +697,19 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) pretty_print_char(file, sql_ex.escaped); } + bool line_lexem_added= false; if(!(sql_ex.empty_flags & LINE_TERM_EMPTY)) { fprintf(file," LINES TERMINATED BY "); pretty_print_char(file, sql_ex.line_term); + line_lexem_added= true; } if(!(sql_ex.empty_flags & LINE_START_EMPTY)) { - fprintf(file," LINES STARTING BY "); + if (!line_lexem_added) + fprintf(file," LINES"); + fprintf(file," STARTING BY "); pretty_print_char(file, sql_ex.line_start); } -- cgit v1.2.1 From 7dcf24a3a49802897cc75ca37191d8dc0db1bdd6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 May 2003 16:40:21 +0200 Subject: Fix for #468 [Ver]: SHOW VARIABLES trims innodb_data_file_path (this bug was already fixed in 4.0, I just copied and pasted two lines). --- sql/ha_innobase.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index b8a794a61a0..34ad45bfb18 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -107,6 +107,8 @@ my_bool innobase_log_archive = FALSE; my_bool innobase_use_native_aio = FALSE; my_bool innobase_fast_shutdown = TRUE; +static char *internal_innobase_data_file_path = NULL; + /* innodb_flush_log_at_trx_commit can now have 3 values: 0 : write to the log file once per second and flush it to disk; 1 : write to the log file at each commit and flush it to disk; @@ -522,8 +524,14 @@ innobase_init(void) srv_arch_dir = (innobase_log_arch_dir ? innobase_log_arch_dir : current_dir); - ret = (bool) - srv_parse_data_file_paths_and_sizes(innobase_data_file_path, + /* Since InnoDB edits the argument in the next call, we make another + copy of it: */ + + internal_innobase_data_file_path = my_strdup(innobase_data_file_path, + MYF(MY_WME)); + + ret = (bool) srv_parse_data_file_paths_and_sizes( + internal_innobase_data_file_path, &srv_data_file_names, &srv_data_file_sizes, &srv_data_file_is_raw_partition, -- cgit v1.2.1 From 73e80314aa17b13d8bb0a6f0f230b99c439bee8a Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 May 2003 16:43:53 +0200 Subject: Fix for bug #490 and #491 (see details below) mysql-test/r/insert_select.result: Result update. mysql-test/r/rpl_insert_id.result: Test update mysql-test/t/insert_select.test: Check if a partly completed INSERT SELECT (failing because of "Duplicate key" after successfully inserting other rows) is written to the binlog if the table is not transactional and at least one row has been inserted (bug #491) mysql-test/t/rpl_insert_id.test: Test for bug #490 (INSERT SELECT in auto_increment) sql/sql_insert.cc: - In INSERT ... SELECT, if it fails with error but one row has been inserted and the table is not transactional, we must write to the binlog (the slave will stop because of the error code in the binlog event, this is normal). bug 491. - we must set INSERT_ID before writing to the binlog (bug 490 accidentally introduced by another dev in 4.0.13). --- sql/sql_insert.cc | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'sql') diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 33a13fabdc6..167ccf974c7 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1350,6 +1350,24 @@ void select_insert::send_error(uint errcode,const char *err) ::send_error(&thd->net,errcode,err); table->file->extra(HA_EXTRA_NO_CACHE); table->file->activate_all_index(thd); + /* + If at least one row has been inserted/modified and will stay in the table + (the table doesn't have transactions) (example: we got a duplicate key + error while inserting into a MyISAM table) we must write to the binlog (and + the error code will make the slave stop). + */ + if ((info.copied || info.deleted) && !table->file->has_transactions()) + { + if (last_insert_id) + thd->insert_id(last_insert_id); // For binary log + mysql_update_log.write(thd,thd->query,thd->query_length); + if (mysql_bin_log.is_open()) + { + Query_log_event qinfo(thd, thd->query, thd->query_length, + table->file->has_transactions()); + mysql_bin_log.write(&qinfo); + } + } ha_rollback_stmt(thd); if (info.copied || info.deleted) { @@ -1365,7 +1383,10 @@ bool select_insert::send_eof() error=table->file->activate_all_index(thd); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); + if (last_insert_id) + thd->insert_id(last_insert_id); // For binary log /* Write to binlog before commiting transaction */ + mysql_update_log.write(thd,thd->query,thd->query_length); if (mysql_bin_log.is_open()) { Query_log_event qinfo(thd, thd->query, thd->query_length, @@ -1393,10 +1414,7 @@ bool select_insert::send_eof() else sprintf(buff,ER(ER_INSERT_INFO),info.records,info.deleted, thd->cuted_fields); - if (last_insert_id) - thd->insert_id(last_insert_id); // For update log ::send_ok(&thd->net,info.copied+info.deleted,last_insert_id,buff); - mysql_update_log.write(thd,thd->query,thd->query_length); return 0; } } -- cgit v1.2.1 From dc90f5ccd798c411a85b7fbc98768728fb1bc888 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 May 2003 23:37:32 +0300 Subject: log.cc: If FOREIGN_KEY_CHECKS=0, wrap in binlog SQL statements inside SET FOREIGN_...=0; ... ; SET FOREIGN_...=1 sql/log.cc: If FOREIGN_KEY_CHECKS=0, wrap in binlog SQL statements inside SET FOREIGN_...=0; ... ; SET FOREIGN_...=1 --- sql/log.cc | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/log.cc b/sql/log.cc index 79ee59eedf8..8bf51100147 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1071,6 +1071,12 @@ bool MYSQL_LOG::write(Log_event* event_info) No check for auto events flag here - this write method should never be called if auto-events are enabled */ + + /* + 1. Write first log events which describe the 'run environment' + of the SQL command + */ + if (thd) { if (thd->last_insert_id_used) @@ -1109,11 +1115,50 @@ bool MYSQL_LOG::write(Log_event* event_info) if (e.write(file)) goto err; } + + /* If the user has set FOREIGN_KEY_CHECKS=0 we wrap every SQL + command in the binlog inside: + SET FOREIGN_KEY_CHECKS=0; + ; + SET FOREIGN_KEY_CHECKS=1; */ + + if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) + { + char buf[256], *p; + p= strmov(buf, "SET FOREIGN_KEY_CHECKS=0"); + Query_log_event e(thd, buf, (ulong) (p - buf), 0); + e.set_log_pos(this); + if (e.write(file)) + goto err; + } } + + /* + 2. Write the SQL command + */ + event_info->set_log_pos(this); if (event_info->write(file) || - file == &log_file && flush_io_cache(file)) + file == &log_file && flush_io_cache(file)) goto err; + + /* + 3. Write log events to reset the 'run environment' of the SQL command + */ + + if (thd && thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) + { + char buf[256], *p; + + p= strmov(buf, "SET FOREIGN_KEY_CHECKS=1"); + Query_log_event e(thd, buf, (ulong) (p - buf), 0); + e.set_log_pos(this); + + if (e.write(file) || + file == &log_file && flush_io_cache(file)) + goto err; + } + error=0; /* -- cgit v1.2.1 From 2917fdb9d38c798cdc8e9341bec667ce4cb3c281 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 May 2003 23:09:46 +0200 Subject: - Fix for memory leak if the SQL slave thread is killed just after reading an event. - A few more mutex locks and unlocks of rli.log_space_lock for doing clean reads of rli.ignore_log_space_limit - Broadcast after unlock, not before (small speed optimisation). --- sql/slave.cc | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/slave.cc b/sql/slave.cc index e6215356ad1..b620603dc63 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1322,6 +1322,8 @@ static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli) !rli->ignore_log_space_limit) { pthread_cond_wait(&rli->log_space_cond, &rli->log_space_lock); + /* Re-acquire the mutex as pthread_cond_wait released it */ + pthread_mutex_lock(&rli->log_space_lock); } thd->proc_info = save_proc_info; pthread_mutex_unlock(&rli->log_space_lock); @@ -2028,7 +2030,11 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) Log_event * ev = next_event(rli); DBUG_ASSERT(rli->sql_thd==thd); if (sql_slave_killed(thd,rli)) + { + /* do not forget to free ev ! */ + if (ev) delete ev; return 1; + } if (ev) { int type_code = ev->get_type_code(); @@ -2302,6 +2308,18 @@ reconnect done to recover from failed read"); goto err; } flush_master_info(mi); + /* + See if the relay logs take too much space. + We don't lock mi->rli.log_space_lock here; this dirty read saves time + and does not introduce any problem: + - if mi->rli.ignore_log_space_limit is 1 but becomes 0 just after (so + the clean value is 0), then we are reading only one more event as we + should, and we'll block only at the next event. No big deal. + - if mi->rli.ignore_log_space_limit is 0 but becomes 1 just after (so + the clean value is 1), then we are going into wait_for_relay_log_space() + for no reason, but this function will do a clean read, notice the clean + value and exit immediately. + */ if (mi->rli.log_space_limit && mi->rli.log_space_limit < mi->rli.log_space_total && !mi->rli.ignore_log_space_limit) @@ -2416,7 +2434,9 @@ slave_begin: rli->pending = 0; //tell the I/O thread to take relay_log_space_limit into account from now on + pthread_mutex_lock(&rli->log_space_lock); rli->ignore_log_space_limit= 0; + pthread_mutex_unlock(&rli->log_space_lock); if (init_relay_log_pos(rli, rli->relay_log_name, @@ -3122,9 +3142,14 @@ Log_event* next_event(RELAY_LOG_INFO* rli) pthread_mutex_lock(&rli->log_space_lock); // prevent the I/O thread from blocking next times rli->ignore_log_space_limit= 1; - // If the I/O thread is blocked, unblock it - pthread_cond_broadcast(&rli->log_space_cond); + /* + If the I/O thread is blocked, unblock it. + Ok to broadcast after unlock, because the mutex is only destroyed in + ~st_relay_log_info(), i.e. when rli is destroyed, and rli will not be + destroyed before we exit the present function. + */ pthread_mutex_unlock(&rli->log_space_lock); + pthread_cond_broadcast(&rli->log_space_cond); // Note that wait_for_update unlocks lock_log ! rli->relay_log.wait_for_update(rli->sql_thd); // re-acquire data lock since we released it earlier -- cgit v1.2.1 From ea99087e8843a80948edd98df09474118b7e31d2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 May 2003 06:16:50 +0300 Subject: Added missing free for last patch --- sql/ha_innobase.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql') diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 34ad45bfb18..d1db50dfa89 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -637,6 +637,7 @@ innobase_end(void) err = innobase_shutdown_for_mysql(); hash_free(&innobase_open_tables); + my_free(internal_innobase_data_file_path,MYF(MY_ALLOW_ZERO_PTR)); if (err != DB_SUCCESS) { -- cgit v1.2.1 From e864f2592de68f04891d9611b0debfb123e8fd88 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 May 2003 11:47:03 +0300 Subject: Added testing of LOAD DATA ... STARTING BY Added read_only variable mysql-test/r/loaddata.result: Added testing of STARTING BY mysql-test/t/loaddata.test: Added testing of STARTING BY sql/log_event.cc: Code cleanup sql/set_var.cc: Added read_only variable sql/sql_update.cc: Remove not used variable --- sql/log_event.cc | 3 +-- sql/set_var.cc | 5 ++--- sql/sql_update.cc | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'sql') diff --git a/sql/log_event.cc b/sql/log_event.cc index bbea89bfd3f..76151026590 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1946,8 +1946,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, sql_error= ER_UNKNOWN_ERROR; slave_print_error(rli,sql_error, "Error '%s' running load data infile", - sql_error ? thd->net.last_error : - ER_SAFE(ER_UNKNOWN_ERROR)); + ER_SAFE(sql_error)); free_root(&thd->mem_root,0); return 1; } diff --git a/sql/set_var.cc b/sql/set_var.cc index 2ca12cdb802..1da187598c4 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -185,6 +185,7 @@ sys_var_thd_ulong sys_net_retry_count("net_retry_count", sys_var_thd_bool sys_new_mode("new", &SV::new_mode); sys_var_thd_ulong sys_read_buff_size("read_buffer_size", &SV::read_buff_size); +sys_var_bool_ptr sys_readonly("read_only", &opt_readonly); sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size", &SV::read_rnd_buff_size); sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank", @@ -204,8 +205,6 @@ sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol", &opt_slave_compressed_protocol); sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout", &slave_net_timeout); -sys_var_bool_ptr sys_readonly("read_only", - &opt_readonly); sys_var_long_ptr sys_slow_launch_time("slow_launch_time", &slow_launch_time); sys_var_thd_ulong sys_sort_buffer("sort_buffer_size", @@ -516,6 +515,7 @@ struct show_var_st init_vars[]= { {"port", (char*) &mysql_port, SHOW_INT}, {"protocol_version", (char*) &protocol_version, SHOW_INT}, {sys_read_buff_size.name, (char*) &sys_read_buff_size, SHOW_SYS}, + {sys_readonly.name, (char*) &sys_readonly, SHOW_SYS}, {sys_read_rnd_buff_size.name,(char*) &sys_read_rnd_buff_size, SHOW_SYS}, {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS}, #ifdef HAVE_QUERY_CACHE @@ -525,7 +525,6 @@ struct show_var_st init_vars[]= { #endif /* HAVE_QUERY_CACHE */ {sys_server_id.name, (char*) &sys_server_id, SHOW_SYS}, {sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout, SHOW_SYS}, - {sys_readonly.name, (char*) &sys_readonly, SHOW_SYS}, {"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, {"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL}, {"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL}, diff --git a/sql/sql_update.cc b/sql/sql_update.cc index ed4d6fd9b81..b4e7750addf 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -182,7 +182,6 @@ int mysql_update(THD *thd, */ uint length; SORT_FIELD *sortorder; - List fields; ha_rows examined_rows; table->io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE), -- cgit v1.2.1 From 306b74fcc86b946577aa0a87231d43aac0b20395 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 May 2003 13:10:08 +0300 Subject: Fixed core dump bug when shuting down mysqld --- sql/mysqld.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 67fb7798ebd..2992fcfd908 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -596,7 +596,7 @@ static void close_connections(void) unix_sock= INVALID_SOCKET; } #endif - end_thr_alarm(); // Don't allow alarms + end_thr_alarm(0); // Abort old alarms. end_slave(); /* First signal all threads that it's time to die */ @@ -905,6 +905,7 @@ void clean_up(bool print_message) #endif (void) ha_panic(HA_PANIC_CLOSE); /* close all tables and logs */ end_key_cache(); + end_thr_alarm(1); /* Free allocated memory */ #ifdef USE_RAID end_raid(); #endif @@ -2313,14 +2314,14 @@ The server will not act as a slave."); if (opt_bootstrap) { int error=bootstrap(stdin); - end_thr_alarm(); // Don't allow alarms + end_thr_alarm(1); // Don't allow alarms unireg_abort(error ? 1 : 0); } if (opt_init_file) { if (read_init_file(opt_init_file)) { - end_thr_alarm(); // Don't allow alarms + end_thr_alarm(1); // Don't allow alarms unireg_abort(1); } } -- cgit v1.2.1 From ecdd47a72fe49738549e3e0b2cccec776a6fba26 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 May 2003 15:08:17 +0300 Subject: code cleanup mysql-test/r/rpl_insert_id.result: Test logging of FOREIGN_KEY_CHECKS mysql-test/t/rpl_insert_id.test: Test logging of FOREIGN_KEY_CHECKS sql/log.cc: Code cleanup --- sql/log.cc | 57 +++++++++++++++++++++++++-------------------------------- 1 file changed, 25 insertions(+), 32 deletions(-) (limited to 'sql') diff --git a/sql/log.cc b/sql/log.cc index 8bf51100147..99bc6ee32b4 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1116,50 +1116,38 @@ bool MYSQL_LOG::write(Log_event* event_info) goto err; } - /* If the user has set FOREIGN_KEY_CHECKS=0 we wrap every SQL - command in the binlog inside: - SET FOREIGN_KEY_CHECKS=0; - ; - SET FOREIGN_KEY_CHECKS=1; */ + /* + If the user has set FOREIGN_KEY_CHECKS=0 we wrap every SQL + command in the binlog inside: + SET FOREIGN_KEY_CHECKS=0; + ; + SET FOREIGN_KEY_CHECKS=1; + */ if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { - char buf[256], *p; - p= strmov(buf, "SET FOREIGN_KEY_CHECKS=0"); - Query_log_event e(thd, buf, (ulong) (p - buf), 0); + Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=0", 24, 0); e.set_log_pos(this); if (e.write(file)) goto err; } } - /* - 2. Write the SQL command - */ + /* Write the SQL command */ event_info->set_log_pos(this); - if (event_info->write(file) || - file == &log_file && flush_io_cache(file)) + if (event_info->write(file)) goto err; - /* - 3. Write log events to reset the 'run environment' of the SQL command - */ + /* Write log events to reset the 'run environment' of the SQL command */ if (thd && thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { - char buf[256], *p; - - p= strmov(buf, "SET FOREIGN_KEY_CHECKS=1"); - Query_log_event e(thd, buf, (ulong) (p - buf), 0); + Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=1", 24, 0); e.set_log_pos(this); - - if (e.write(file) || - file == &log_file && flush_io_cache(file)) + if (e.write(file)) goto err; } - - error=0; /* Tell for transactional table handlers up to which position in the @@ -1180,6 +1168,9 @@ bool MYSQL_LOG::write(Log_event* event_info) if (file == &log_file) // we are writing to the real log (disk) { + if (flush_io_cache(file)) + goto err; + if (opt_using_transactions && !my_b_tell(&thd->transaction.trans_log)) { /* @@ -1189,8 +1180,8 @@ bool MYSQL_LOG::write(Log_event* event_info) handler if the log event type is appropriate. */ - if (event_info->get_type_code() == QUERY_EVENT - || event_info->get_type_code() == EXEC_LOAD_EVENT) + if (event_info->get_type_code() == QUERY_EVENT || + event_info->get_type_code() == EXEC_LOAD_EVENT) { error = ha_report_binlog_offset_and_commit(thd, log_file_name, file->pos_in_file); @@ -1200,6 +1191,7 @@ bool MYSQL_LOG::write(Log_event* event_info) /* we wrote to the real log, check automatic rotation */ should_rotate= (my_b_tell(file) >= (my_off_t) max_binlog_size); } + error=0; err: if (error) @@ -1222,13 +1214,14 @@ err: pthread_mutex_unlock(&LOCK_log); - /* Flush the transactional handler log file now that we have released - LOCK_log; the flush is placed here to eliminate the bottleneck on the - group commit */ + /* + Flush the transactional handler log file now that we have released + LOCK_log; the flush is placed here to eliminate the bottleneck on the + group commit + */ - if (called_handler_commit) { + if (called_handler_commit) ha_commit_complete(thd); - } DBUG_RETURN(error); } -- cgit v1.2.1 From 1ed4e006bd7e70f50d29950c03024d09aaec64f0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 May 2003 17:24:16 +0300 Subject: Fixed problem with 'kill pid-of-mysqld' on Mac OS X --- sql/mysqld.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 4e88a6fcb32..f729dcfd17a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1346,6 +1346,7 @@ information that should help you find out what is causing the crash\n"); static void init_signals(void) { sigset_t set; + struct sigaction sa; DBUG_ENTER("init_signals"); sigset(THR_KILL_SIGNAL,end_thread_signal); @@ -1353,7 +1354,6 @@ static void init_signals(void) if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL)) { - struct sigaction sa; sa.sa_flags = SA_RESETHAND | SA_NODEFER; sigemptyset(&sa.sa_mask); sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL); @@ -1378,15 +1378,22 @@ static void init_signals(void) sigaddset(&set,SIGQUIT); sigaddset(&set,SIGTERM); sigaddset(&set,SIGHUP); - sigset(SIGTERM,print_signal_warning); // If it's blocked by parent - signal(SIGHUP,print_signal_warning); // If it's blocked by parent + + /* Fix signals if blocked by parents (can happen on Mac OS X) */ + sa.sa_flags = 0; + sa.sa_handler = print_signal_warning; + sigaction(SIGTERM, &sa, (struct sigaction*) 0); + sa.sa_flags = 0; + sa.sa_handler = print_signal_warning; + sigaction(SIGHUP, &sa, (struct sigaction*) 0); #ifdef SIGTSTP sigaddset(&set,SIGTSTP); #endif sigaddset(&set,THR_SERVER_ALARM); sigdelset(&set,THR_KILL_SIGNAL); // May be SIGINT sigdelset(&set,THR_CLIENT_ALARM); // For alarms - (void) pthread_sigmask(SIG_SETMASK,&set,NULL); + sigprocmask(SIG_SETMASK,&set,NULL); + pthread_sigmask(SIG_SETMASK,&set,NULL); DBUG_VOID_RETURN; } -- cgit v1.2.1 From cd554e9ed61f3140cf213f62b8ce17bdf197467b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 May 2003 20:09:53 +0300 Subject: Fixed bug when installing mysqld as a service with 2 arguments (option + service-name) --- sql/mysqld.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f729dcfd17a..b0b9837dff3 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2230,9 +2230,12 @@ int main(int argc, char **argv) return 0; if (Service.IsService(argv[2])) { - /* start an optional service */ + /* + mysqld was started as + mysqld --defaults-file=my_path\my.ini service-name + */ use_opt_args=1; - opt_argc=argc; + opt_argc= 2; // Skip service-name opt_argv=argv; start_mode= 1; Service.Init(argv[2], mysql_service); -- cgit v1.2.1 From 4920a3326fc96be2cfa661232b6fe5f731b22eae Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 May 2003 16:40:14 +0300 Subject: Fixed problem with mysql prompt when server disconnect. (Bug 356) Fixed problem with localtime -> gmt where some times resulted in different (but correct) timestamps. Now MySQL should use the smallest possible timestamp value in this case. (Bug 316) client/mysql.cc: Fixed problem with prompt when server disconnect. (Bug 356) client/mysqltest.c: More debug information mysql-test/mysql-test-run.sh: Added support for --timezone in -master.opt mysql-test/t/raid.test: Fixed test if raid is enabled sql/field.cc: New my_gmt_sec() parameters sql/mysql_priv.h: New my_gmt_sec() parameters sql/mysqld.cc: Remove LOCK_timezone. Code cleanup sql/time.cc: Fixed problem with localtime -> gmt where some times resulted in different (but correct) timestamps. Now MySQL should use the smallest possible timestamp value in this case. (Bug 316) --- sql/field.cc | 3 ++- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 10 ---------- sql/time.cc | 56 +++++++++++++++++++++++++++++++++++--------------------- 4 files changed, 38 insertions(+), 33 deletions(-) (limited to 'sql') diff --git a/sql/field.cc b/sql/field.cc index a2663626723..9babe069300 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2552,6 +2552,7 @@ void Field_timestamp::store(longlong nr) if ((nr=fix_datetime(nr))) { + long not_used; part1=(long) (nr/LL(1000000)); part2=(long) (nr - (longlong) part1*LL(1000000)); l_time.year= (int) (part1/10000L); part1%=10000L; @@ -2560,7 +2561,7 @@ void Field_timestamp::store(longlong nr) l_time.hour= (int) (part2/10000L); part2%=10000L; l_time.minute=(int) part2 / 100; l_time.second=(int) part2 % 100; - timestamp=my_gmt_sec(&l_time); + timestamp=my_gmt_sec(&l_time, ¬_used); } else timestamp=0; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2c28fcf03bb..614cb8cadf6 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -755,7 +755,7 @@ uint calc_days_in_year(uint year); void get_date_from_daynr(long daynr,uint *year, uint *month, uint *day); void init_time(void); -long my_gmt_sec(TIME *); +long my_gmt_sec(TIME *, long *current_timezone); time_t str_to_timestamp(const char *str,uint length); bool str_to_time(const char *str,uint length,TIME *l_time); longlong str_to_datetime(const char *str,uint length,bool fuzzy_date); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e4f86a1818c..c2ee940af49 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -968,7 +968,6 @@ static void clean_up_mutexes() (void) pthread_mutex_destroy(&LOCK_crypt); (void) pthread_mutex_destroy(&LOCK_bytes_sent); (void) pthread_mutex_destroy(&LOCK_bytes_received); - (void) pthread_mutex_destroy(&LOCK_timezone); (void) pthread_mutex_destroy(&LOCK_user_conn); (void) pthread_mutex_destroy(&LOCK_rpl_status); (void) pthread_mutex_destroy(&LOCK_active_mi); @@ -1998,19 +1997,11 @@ int main(int argc, char **argv) } #endif #ifdef HAVE_TZNAME -#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT) { struct tm tm_tmp; localtime_r(&start_time,&tm_tmp); strmov(time_zone,tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]); } -#else - { - struct tm *start_tm; - start_tm=localtime(&start_time); - strmov(time_zone,tzname[start_tm->tm_isdst != 0 ? 1 : 0]); - } -#endif #endif if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0) @@ -2067,7 +2058,6 @@ int main(int argc, char **argv) (void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST); - (void) pthread_mutex_init(&LOCK_timezone,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST); diff --git a/sql/time.cc b/sql/time.cc index cc8cd4fbcf9..321a8ba16e5 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -28,7 +28,6 @@ uchar *days_in_month= (uchar*) "\037\034\037\036\037\036\037\037\036\037\036\037 /* Currently only my_time_zone is inited */ static long my_time_zone=0; -pthread_mutex_t LOCK_timezone; void init_time(void) { @@ -39,14 +38,14 @@ void init_time(void) seconds= (time_t) time((time_t*) 0); localtime_r(&seconds,&tm_tmp); l_time= &tm_tmp; - my_time_zone=0; + my_time_zone= 3600; /* Comp. for -3600 in my_gmt_sec */ my_time.year= (uint) l_time->tm_year+1900; my_time.month= (uint) l_time->tm_mon+1; my_time.day= (uint) l_time->tm_mday; my_time.hour= (uint) l_time->tm_hour; my_time.minute= (uint) l_time->tm_min; - my_time.second= (uint) l_time->tm_sec; - VOID(my_gmt_sec(&my_time)); /* Init my_time_zone */ + my_time.second= (uint) l_time->tm_sec; + my_gmt_sec(&my_time, &my_time_zone); /* Init my_time_zone */ } /* @@ -57,26 +56,39 @@ void init_time(void) */ -long my_gmt_sec(TIME *t) +long my_gmt_sec(TIME *t, long *my_timezone) { uint loop; time_t tmp; struct tm *l_time,tm_tmp; - long diff; + long diff, current_timezone; if (t->hour >= 24) { /* Fix for time-loop */ t->day+=t->hour/24; t->hour%=24; } - pthread_mutex_lock(&LOCK_timezone); - tmp=(time_t) ((calc_daynr((uint) t->year,(uint) t->month,(uint) t->day) - - (long) days_at_timestart)*86400L + (long) t->hour*3600L + - (long) (t->minute*60 + t->second)) + (time_t) my_time_zone; + + /* + Calculate the gmt time based on current time and timezone + The -1 on the end is to ensure that if have a date that exists twice + (like 2002-10-27 02:00:0 MET), we will find the initial date. + + By doing -3600 we will have to call localtime_r() several times, but + I couldn't come up with a better way to get a repeatable result :( + + We can't use mktime() as it's buggy on many platforms and not thread safe. + */ + tmp=(time_t) (((calc_daynr((uint) t->year,(uint) t->month,(uint) t->day) - + (long) days_at_timestart)*86400L + (long) t->hour*3600L + + (long) (t->minute*60 + t->second)) + (time_t) my_time_zone - + 3600); + current_timezone= my_time_zone; + localtime_r(&tmp,&tm_tmp); l_time=&tm_tmp; for (loop=0; - loop < 3 && + loop < 2 && (t->hour != (uint) l_time->tm_hour || t->minute != (uint) l_time->tm_min); loop++) @@ -89,14 +101,16 @@ long my_gmt_sec(TIME *t) days= -1; diff=(3600L*(long) (days*24+((int) t->hour - (int) l_time->tm_hour)) + (long) (60*((int) t->minute - (int) l_time->tm_min))); - my_time_zone+=diff; - tmp+=(time_t) diff; + current_timezone+= diff+3600; // Compensate for -3600 above + tmp+= (time_t) diff; localtime_r(&tmp,&tm_tmp); l_time=&tm_tmp; } - /* Fix that if we are in the not existing daylight saving time hour - we move the start of the next real hour */ - if (loop == 3 && t->hour != (uint) l_time->tm_hour) + /* + Fix that if we are in the not existing daylight saving time hour + we move the start of the next real hour + */ + if (loop == 2 && t->hour != (uint) l_time->tm_hour) { int days= t->day - l_time->tm_mday; if (days < -1) @@ -108,11 +122,9 @@ long my_gmt_sec(TIME *t) if (diff == 3600) tmp+=3600 - t->minute*60 - t->second; // Move to next hour else if (diff == -3600) - tmp-=t->minute*60 + t->second; // Move to next hour + tmp-=t->minute*60 + t->second; // Move to previous hour } - if ((my_time_zone >=0 ? my_time_zone: -my_time_zone) > 3600L*12) - my_time_zone=0; /* Wrong date */ - pthread_mutex_unlock(&LOCK_timezone); + *my_timezone= current_timezone; return (long) tmp; } /* my_gmt_sec */ @@ -399,6 +411,8 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date) time_t str_to_timestamp(const char *str,uint length) { TIME l_time; + long not_used; + if (str_to_TIME(str,length,&l_time,0) == TIMESTAMP_NONE) return(0); if (l_time.year >= TIMESTAMP_MAX_YEAR || l_time.year < 1900+YY_PART_YEAR) @@ -406,7 +420,7 @@ time_t str_to_timestamp(const char *str,uint length) current_thd->cuted_fields++; return(0); } - return(my_gmt_sec(&l_time)); + return(my_gmt_sec(&l_time, ¬_used)); } -- cgit v1.2.1 From c1607401de71e400b5d2c1e1e1351edbe428cd4e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 May 2003 18:16:50 +0200 Subject: Removed bad mutex locking --- sql/slave.cc | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sql') diff --git a/sql/slave.cc b/sql/slave.cc index b620603dc63..b655b17c258 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1320,11 +1320,7 @@ static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli) while (rli->log_space_limit < rli->log_space_total && !(slave_killed=io_slave_killed(thd,mi)) && !rli->ignore_log_space_limit) - { pthread_cond_wait(&rli->log_space_cond, &rli->log_space_lock); - /* Re-acquire the mutex as pthread_cond_wait released it */ - pthread_mutex_lock(&rli->log_space_lock); - } thd->proc_info = save_proc_info; pthread_mutex_unlock(&rli->log_space_lock); DBUG_RETURN(slave_killed); -- cgit v1.2.1 From 99d306b77e9502aa14bcb6d76af724ce6ab28b34 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 May 2003 11:24:48 +0500 Subject: item_cmpfunc.cc: Fix for multibyte charsets sql/item_cmpfunc.cc: Fix for multibyte charsets --- sql/item_cmpfunc.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql') diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index d96069a17aa..3344f2bc01d 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1454,7 +1454,11 @@ bool Item_func_like::fix_fields(THD *thd,struct st_table_list *tlist) { const char* tmp = first + 1; for (; *tmp != wild_many && *tmp != wild_one && *tmp != escape; tmp++) ; +#ifdef USE_MB + canDoTurboBM = (tmp == last) && !use_mb(default_charset_info); +#else canDoTurboBM = tmp == last; +#endif } if (canDoTurboBM) -- cgit v1.2.1 From 0829e8706dd7d3ebb415865493ea71297d5d8781 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 May 2003 14:52:25 +0500 Subject: Fix for bug #529 ("x509" no allowed as field name) --- sql/sql_yacc.yy | 1 + 1 file changed, 1 insertion(+) (limited to 'sql') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 340fbc1b3dc..c79750c8014 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3397,6 +3397,7 @@ keyword: | USE_FRM {} | VARIABLES {} | WORK_SYM {} + | X509_SYM {} | YEAR_SYM {}; /* Option functions */ -- cgit v1.2.1 From fadfa46796576b5566ee3f45920b07e2f2326552 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 May 2003 18:41:19 +0500 Subject: Fix for compiling MySQL-4.0.13 with SSL support on OpenBSD --- sql/mysql_priv.h | 1 + 1 file changed, 1 insertion(+) (limited to 'sql') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 614cb8cadf6..b191a702efe 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -458,6 +458,7 @@ Field *find_field_in_tables(THD *thd,Item_field *item,TABLE_LIST *tables); Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length, bool check_grant,bool allow_rowid); #ifdef HAVE_OPENSSL +#include struct st_des_keyblock { des_cblock key1, key2, key3; -- cgit v1.2.1 From 185f0092bc8b8ee558a2bad15308168623e94b42 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 31 May 2003 01:41:11 +0300 Subject: fixed bug 549 - incorect query cache memory formating on very small query cache sizes mysql-test/r/query_cache.result: test of 2 parts of bug 549 mysql-test/t/query_cache.test: test of 2 parts of bug 549 sql/sql_cache.cc: fixed query cache size showing fixed query cache low memory detection --- sql/sql_cache.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'sql') diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 59430d6a486..1fcd0d1456b 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -731,7 +731,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg) query_cache_size_arg)); free_cache(0); query_cache_size= query_cache_size_arg; - DBUG_RETURN(init_cache()); + DBUG_RETURN(::query_cache_size= init_cache()); } @@ -1282,6 +1282,12 @@ ulong Query_cache::init_cache() mem_bin_steps = 1; mem_bin_size = max_mem_bin_size >> QUERY_CACHE_MEM_BIN_STEP_PWR2; prev_size = 0; + if (mem_bin_size <= min_allocation_unit) + { + DBUG_PRINT("qcache", ("too small query cache => query cache disabled")); + // TODO here (and above) should be warning in 4.1 + goto err; + } while (mem_bin_size > min_allocation_unit) { mem_bin_num += mem_bin_count; @@ -1308,14 +1314,6 @@ ulong Query_cache::init_cache() query_cache_size -= additional_data_size; STRUCT_LOCK(&structure_guard_mutex); - if (max_mem_bin_size <= min_allocation_unit) - { - DBUG_PRINT("qcache", - (" max bin size (%lu) <= min_allocation_unit => cache disabled", - max_mem_bin_size)); - STRUCT_UNLOCK(&structure_guard_mutex); - goto err; - } if (!(cache = (byte *) my_malloc_lock(query_cache_size+additional_data_size, MYF(0)))) -- cgit v1.2.1 From 2ef52d46a4f5b0c34bee26b0f70d672b6ee9325e Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Jun 2003 12:32:53 +0300 Subject: Fixed bug in ALTER TABLE DISABLE KEYS and INSERT DELAYED. Bug #478 mysql-test/r/alter_table.result: new results mysql-test/r/lowercase_table.result: new results mysql-test/t/alter_table.test: Test of ALTER TABLE DISABLE KEYS + INSERT DELAYED mysql-test/t/lowercase_table.test: Added test of alias name comparison sql/mysql_priv.h: Made closed_cached_table local sql/sql_table.cc: Fixed bug in ALTER TABLE DISABLE KEYS and INSERT DELAYED --- sql/mysql_priv.h | 1 - sql/sql_table.cc | 133 +++++++++++++++++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 53 deletions(-) (limited to 'sql') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 614cb8cadf6..41a39f0d24c 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -422,7 +422,6 @@ bool mysql_rename_table(enum db_type base, const char * old_name, const char *new_db, const char * new_name); -bool close_cached_table(THD *thd,TABLE *table); int mysql_create_index(THD *thd, TABLE_LIST *table_list, List &keys); int mysql_drop_index(THD *thd, TABLE_LIST *table_list, List &drop_list); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 07ec1d67538..f3620b860a7 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -912,58 +912,76 @@ mysql_rename_table(enum db_type base, } /* - close table in this thread and force close + reopen in other threads - This assumes that the calling thread has lock on LOCK_open - Win32 clients must also have a WRITE LOCK on the table ! + Force all other threads to stop using the table + + SYNOPSIS + wait_while_table_is_used() + thd Thread handler + table Table to remove from cache + + NOTES + When returning, the table will be unusable for other threads until + the table is closed. + + PREREQUISITES + Lock on LOCK_open + Win32 clients must also have a WRITE LOCK on the table ! */ -static void safe_remove_from_cache(THD *thd,TABLE *table) +static void wait_while_table_is_used(THD *thd,TABLE *table) { - DBUG_ENTER("safe_remove_from_cache"); - if (table) - { - DBUG_PRINT("enter",("table: %s", table->real_name)); - VOID(table->file->extra(HA_EXTRA_FORCE_REOPEN)); // Close all data files - /* Mark all tables that are in use as 'old' */ - mysql_lock_abort(thd,table); // end threads waiting on lock + DBUG_PRINT("enter",("table: %s", table->real_name)); + DBUG_ENTER("wait_while_table_is_used"); + safe_mutex_assert_owner(&LOCK_open); -#if defined(USING_TRANSACTIONS) || defined( __WIN__) || defined( __EMX__) || !defined(OS2) - /* Wait until all there are no other threads that has this table open */ - while (remove_table_from_cache(thd,table->table_cache_key, - table->real_name)) - { - dropping_tables++; - (void) pthread_cond_wait(&COND_refresh,&LOCK_open); - dropping_tables--; - } -#else - (void) remove_table_from_cache(thd,table->table_cache_key, - table->real_name); -#endif - /* When lock on LOCK_open is freed other threads can continue */ - pthread_cond_broadcast(&COND_refresh); + VOID(table->file->extra(HA_EXTRA_FORCE_REOPEN)); // Close all data files + /* Mark all tables that are in use as 'old' */ + mysql_lock_abort(thd, table); // end threads waiting on lock + + /* Wait until all there are no other threads that has this table open */ + while (remove_table_from_cache(thd,table->table_cache_key, + table->real_name)) + { + dropping_tables++; + (void) pthread_cond_wait(&COND_refresh,&LOCK_open); + dropping_tables--; } DBUG_VOID_RETURN; } +/* + Close a cached table + + SYNOPSIS + clsoe_cached_table() + thd Thread handler + table Table to remove from cache -bool close_cached_table(THD *thd,TABLE *table) + NOTES + Function ends by signaling threads waiting for the table to try to + reopen the table. + + PREREQUISITES + Lock on LOCK_open + Win32 clients must also have a WRITE LOCK on the table ! +*/ + +static bool close_cached_table(THD *thd, TABLE *table) { DBUG_ENTER("close_cached_table"); - safe_mutex_assert_owner(&LOCK_open); - - if (table) + + wait_while_table_is_used(thd,table); + /* Close lock if this is not got with LOCK TABLES */ + if (thd->lock) { - safe_remove_from_cache(thd,table); - /* Close lock if this is not got with LOCK TABLES */ - if (thd->lock) - { - mysql_unlock_tables(thd, thd->lock); - thd->lock=0; // Start locked threads - } - /* Close all copies of 'table'. This also frees all LOCK TABLES lock */ - thd->open_tables=unlink_open_table(thd,thd->open_tables,table); + mysql_unlock_tables(thd, thd->lock); + thd->lock=0; // Start locked threads } + /* Close all copies of 'table'. This also frees all LOCK TABLES lock */ + thd->open_tables=unlink_open_table(thd,thd->open_tables,table); + + /* When lock on LOCK_open is freed other threads can continue */ + pthread_cond_broadcast(&COND_refresh); DBUG_RETURN(0); } @@ -1094,10 +1112,13 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list, sprintf(tmp,"%s-%lx_%lx", from, current_pid, thd->thread_id); - pthread_mutex_lock(&LOCK_open); - close_cached_table(thd,table_list->table); - pthread_mutex_unlock(&LOCK_open); - + /* If we could open the table, close it */ + if (table_list->table) + { + pthread_mutex_lock(&LOCK_open); + close_cached_table(thd, table); + pthread_mutex_unlock(&LOCK_open); + } if (lock_and_wait_for_table_name(thd,table_list)) { error= -1; @@ -1494,11 +1515,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, else { *fn_ext(new_name)=0; - close_cached_table(thd,table); + close_cached_table(thd, table); if (mysql_rename_table(old_db_type,db,table_name,new_db,new_name)) error= -1; } - VOID(pthread_cond_broadcast(&COND_refresh)); VOID(pthread_mutex_unlock(&LOCK_open)); } if (!error) @@ -1507,12 +1527,18 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, case LEAVE_AS_IS: break; case ENABLE: - safe_remove_from_cache(thd,table); - error= table->file->activate_all_index(thd); + VOID(pthread_mutex_lock(&LOCK_open)); + wait_while_table_is_used(thd, table); + VOID(pthread_mutex_unlock(&LOCK_open)); + error= table->file->activate_all_index(thd); + /* COND_refresh will be signaled in close_thread_tables() */ break; case DISABLE: - safe_remove_from_cache(thd,table); + VOID(pthread_mutex_lock(&LOCK_open)); + wait_while_table_is_used(thd, table); + VOID(pthread_mutex_unlock(&LOCK_open)); table->file->deactivate_non_unique_index(HA_POS_ERROR); + /* COND_refresh will be signaled in close_thread_tables() */ break; } } @@ -1936,7 +1962,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, close the original table at before doing the rename */ table_name=thd->strdup(table_name); // must be saved - if (close_cached_table(thd,table)) + if (close_cached_table(thd, table)) { // Aborted VOID(quick_rm_table(new_db_type,new_db,tmp_name)); VOID(pthread_mutex_unlock(&LOCK_open)); @@ -1970,7 +1996,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, This shouldn't happen. We solve this the safe way by closing the locked table. */ - close_cached_table(thd,table); + if (table) + close_cached_table(thd,table); VOID(pthread_mutex_unlock(&LOCK_open)); goto err; } @@ -1980,7 +2007,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, Not table locking or alter table with rename free locks and remove old table */ - close_cached_table(thd,table); + if (table) + close_cached_table(thd,table); VOID(quick_rm_table(old_db_type,db,old_name)); } else @@ -2000,7 +2028,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (close_data_tables(thd,db,table_name) || reopen_tables(thd,1,0)) { // This shouldn't happen - close_cached_table(thd,table); // Remove lock for table + if (table) + close_cached_table(thd,table); // Remove lock for table VOID(pthread_mutex_unlock(&LOCK_open)); goto err; } -- cgit v1.2.1 From 3f7dfc4df3a9bdfc01e5b84c3297fff61b791f9b Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Jun 2003 23:40:01 +0300 Subject: Small fixes (nothing nameworthy) mysql-test/r/errors.result: Rename: mysql-test/r/err000001.result -> mysql-test/r/errors.result include/my_global.h: typedef for future functions that needs string length as an argument innobase/os/os0file.c: Added operation to error messages mysql-test/t/errors.test: Cleaned up file to new error number standard mysys/thr_alarm.c: Made end_thr_alarm() work also with internal alarm thread. (Not critical for MySQL) sql/mysqld.cc: Added sigemptyset() (bug found by valgrind) Removed some wrong usage of thd when writing variable values --- sql/mysqld.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c2ee940af49..1492d6ddb68 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1520,7 +1520,6 @@ the problem, but since we have already crashed, something is definitely wrong\n\ and this may fail.\n\n"); fprintf(stderr, "key_buffer_size=%lu\n", (ulong) keybuff_size); fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size); - fprintf(stderr, "sort_buffer_size=%ld\n", thd->variables.sortbuff_size); fprintf(stderr, "max_used_connections=%ld\n", max_used_connections); fprintf(stderr, "max_connections=%ld\n", max_connections); fprintf(stderr, "threads_connected=%d\n", thread_count); @@ -1528,7 +1527,7 @@ and this may fail.\n\n"); key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\ bytes of memory\n", ((ulong) keybuff_size + (global_system_variables.read_buff_size + - thd->variables.sortbuff_size) * + global_system_variables.sortbuff_size) * max_connections)/ 1024); fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n"); @@ -1557,14 +1556,9 @@ the thread stack. Please read http://www.mysql.com/doc/L/i/Linux.html\n\n", Some pointers may be invalid and cause the dump to abort...\n"); safe_print_str("thd->query", thd->query, 1024); fprintf(stderr, "thd->thread_id=%ld\n", thd->thread_id); - fprintf(stderr, "\n\ -Successfully dumped variables, if you ran with --log, take a look at the\n\ -details of what thread %ld did to cause the crash. In some cases of really\n\ -bad corruption, the values shown above may be invalid.\n\n", - thd->thread_id); } fprintf(stderr, "\ -The manual page at http://www.mysql.com/doc/C/r/Crashing.html contains\n\ +The manual page at http://www.mysql.com/doc/en/Crashing.html contains\n\ information that should help you find out what is causing the crash.\n"); fflush(stderr); #endif /* HAVE_STACKTRACE */ @@ -1639,6 +1633,7 @@ static void init_signals(void) sigaddset(&set,SIGHUP); /* Fix signals if blocked by parents (can happen on Mac OS X) */ + sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = print_signal_warning; sigaction(SIGTERM, &sa, (struct sigaction*) 0); @@ -2279,7 +2274,7 @@ int main(int argc, char **argv) #endif /* init_slave() must be called after the thread keys are created */ init_slave(); - + DBUG_ASSERT(current_thd == 0); if (opt_bin_log && !server_id) { @@ -2307,7 +2302,6 @@ The server will not act as a slave."); using_update_log=1; } - if (opt_bootstrap) { int error=bootstrap(stdin); -- cgit v1.2.1 From a91d2fcbd9d927deb8808c10a32f1baa192a4e26 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Jun 2003 16:05:27 +0300 Subject: Added [mysqld-base-version] as a default group for the mysqld server Portability fix for Windows 64 include/config-win.h: Portability fix for Windows 64 include/my_global.h: Portability fix for Windows 64 include/mysql_version.h.in: Added [mysqld-base-version] as a default group for the mysqld server innobase/include/univ.i: Portability fix for Windows 64 sql/mysqld.cc: Added [mysqld-base-version] as a default group for the mysqld server --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1492d6ddb68..7289d0e72cf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1923,7 +1923,7 @@ extern "C" pthread_handler_decl(handle_shutdown,arg) #endif -const char *load_default_groups[]= { "mysqld","server",0 }; +const char *load_default_groups[]= { "mysqld","server",MYSQL_BASE_VERSION,0 }; bool open_log(MYSQL_LOG *log, const char *hostname, const char *opt_name, const char *extension, -- cgit v1.2.1