diff options
author | unknown <serg@serg.mysql.com> | 2001-10-12 17:47:13 +0200 |
---|---|---|
committer | unknown <serg@serg.mysql.com> | 2001-10-12 17:47:13 +0200 |
commit | 6db2120514c3e7442f69c99be017b2baa03bb09a (patch) | |
tree | 224ae04fa4b6a74f056f956de4f2ebb6423c1838 /sql | |
parent | 239e8da92637685a4112c99cb198e02f4d10fdc8 (diff) | |
parent | be31ffa2e46cac314694452b51935ec841b8f06e (diff) | |
download | mariadb-git-6db2120514c3e7442f69c99be017b2baa03bb09a.tar.gz |
Merge work:/home/bk/mysql-4.0
into serg.mysql.com:/usr/home/serg/Abk/mysql-4.0
BitKeeper/etc/ignore:
auto-union
mysql-test/r/fulltext.result:
Auto merged
mysql-test/r/join.result:
Auto merged
mysql-test/r/fulltext_order_by.result:
Auto merged
mysql-test/r/fulltext_multi.result:
Auto merged
mysql-test/r/fulltext_cache.result:
Auto merged
mysql-test/t/fulltext.test:
Auto merged
mysql-test/t/join.test:
Auto merged
mysql-test/r/fulltext_left_join.result:
Auto merged
sql/handler.h:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/Makefile.am | 2 | ||||
-rw-r--r-- | sql/ha_innobase.cc | 236 | ||||
-rw-r--r-- | sql/ha_innobase.h | 2 | ||||
-rw-r--r-- | sql/handler.cc | 7 | ||||
-rw-r--r-- | sql/handler.h | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 23 | ||||
-rw-r--r-- | sql/repl_failsafe.cc | 43 | ||||
-rw-r--r-- | sql/repl_failsafe.h | 16 | ||||
-rw-r--r-- | sql/slave.cc | 11 | ||||
-rw-r--r-- | sql/sql_db.cc | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 22 | ||||
-rw-r--r-- | sql/sql_show.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 1 | ||||
-rw-r--r-- | sql/structs.h | 1 | ||||
-rw-r--r-- | sql/table.cc | 2 |
15 files changed, 312 insertions, 63 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am index cf762d9f6df..4621443f4d2 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -81,7 +81,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \ slave.cc sql_repl.cc sql_union.cc \ mini_client.cc mini_client_errors.c \ - stacktrace.c + stacktrace.c repl_failsafe.h repl_failsafe.cc gen_lex_hash_SOURCES = gen_lex_hash.cc gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS) diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index e7d98dbe406..7e11fbe46d1 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -161,7 +161,23 @@ convert_error_code_to_mysql( } else if (error == (int) DB_DEADLOCK) { - return(1000000); + return(HA_ERR_LOCK_DEADLOCK); + + } else if (error == (int) DB_LOCK_WAIT_TIMEOUT) { + + return(1000001); + + } else if (error == (int) DB_NO_REFERENCED_ROW) { + + return(1000010); + + } else if (error == (int) DB_ROW_IS_REFERENCED) { + + return(1000011); + + } else if (error == (int) DB_CANNOT_ADD_CONSTRAINT) { + + return(1000012); } else if (error == (int) DB_OUT_OF_FILE_SPACE) { @@ -178,7 +194,6 @@ convert_error_code_to_mysql( } else if (error == (int) DB_TOO_BIG_RECORD) { return(HA_ERR_TO_BIG_ROW); - } else { dbug_assert(0); @@ -220,7 +235,7 @@ innobase_mysql_print_thd( } if (thd->query) { - printf(" %-.100s", thd->query); + printf("\n%-.100s", thd->query); } printf("\n"); @@ -526,9 +541,24 @@ innobase_init(void) { int err; bool ret; + char current_lib[2], *default_path; DBUG_ENTER("innobase_init"); + /* + When using the embedded server, the datadirectory is not + in the current directory. + */ + if (!mysql_embedded) + default_path=mysql_real_data_home; + else + { + /* It's better to use current lib, to keep path's short */ + current_lib[0]=FN_CURLIB; + current_lib[1]=FN_LIBCHAR; + default_path=current_lib; + } + if (specialflag & SPECIAL_NO_PRIOR) { srv_set_thread_priorities = FALSE; } else { @@ -544,10 +574,10 @@ innobase_init(void) MYF(MY_WME)); srv_data_home = (innobase_data_home_dir ? innobase_data_home_dir : - mysql_real_data_home); + default_path); srv_logs_home = (char*) ""; srv_arch_dir = (innobase_log_arch_dir ? innobase_log_arch_dir : - mysql_real_data_home); + default_path); ret = innobase_parse_data_file_paths_and_sizes(); @@ -557,7 +587,7 @@ innobase_init(void) } if (!innobase_log_group_home_dir) - innobase_log_group_home_dir= mysql_real_data_home; + innobase_log_group_home_dir= default_path; ret = innobase_parse_log_group_home_dirs(); if (ret == FALSE) { @@ -586,6 +616,15 @@ innobase_init(void) srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout; srv_print_verbose_log = mysql_embedded ? 0 : 1; + if (strcmp(default_charset_info->name, "latin1") == 0) { + /* Store the character ordering table to InnoDB. + For non-latin1 charsets we use the MySQL comparison + functions, and consequently we do not need to know + the ordering internally in InnoDB. */ + + memcpy(srv_latin1_ordering, + default_charset_info->sort_order, 256); + } err = innobase_start_or_create_for_mysql(); @@ -636,7 +675,7 @@ innobase_flush_logs(void) DBUG_ENTER("innobase_flush_logs"); - log_make_checkpoint_at(ut_dulint_max, TRUE); + log_flush_up_to(ut_dulint_max, LOG_WAIT_ONE_GROUP); DBUG_RETURN(result); } @@ -869,10 +908,10 @@ ha_innobase::open( if (NULL == (ib_table = dict_table_get(norm_name, NULL))) { fprintf(stderr, -"Cannot find table %s from the internal data dictionary\n" -"of InnoDB though the .frm file for the table exists. Maybe you have deleted\n" -"and created again an InnoDB database but forgotten to delete the\n" -"corresponding .frm files of old InnoDB tables?\n", +"InnoDB: Cannot find table %s from the internal data dictionary\n" +"InnoDB: of InnoDB though the .frm file for the table exists. Maybe you\n" +"InnoDB: have deleted and recreated InnoDB data files but have forgotten\n" +"InnoDB: to delete the corresponding .frm files of InnoDB tables?\n", norm_name); free_share(share); @@ -1392,8 +1431,36 @@ ha_innobase::write_row( current value and the value supplied by the user, if the auto_inc counter is already initialized for the table */ + + /* We have to use the transactional lock mechanism + on the auto-inc counter of the table to ensure + that replication and roll-forward of the binlog + exactly imitates also the given auto-inc values. + The lock is released at each SQL statement's + end. */ + + error = row_lock_table_autoinc_for_mysql(prebuilt); + + if (error != DB_SUCCESS) { + + error = convert_error_code_to_mysql(error); + goto func_exit; + } + dict_table_autoinc_update(prebuilt->table, auto_inc); } else { + if (!prebuilt->trx->auto_inc_lock) { + + error = row_lock_table_autoinc_for_mysql( + prebuilt); + if (error != DB_SUCCESS) { + + error = convert_error_code_to_mysql( + error); + goto func_exit; + } + } + auto_inc = dict_table_autoinc_get(prebuilt->table); /* If auto_inc is now != 0 the autoinc counter @@ -1451,7 +1518,7 @@ ha_innobase::write_row( /* Tell InnoDB server that there might be work for utility threads: */ - +func_exit: innobase_active_small(); DBUG_RETURN(error); @@ -1728,7 +1795,7 @@ ha_innobase::index_init( } /********************************************************************** -?????????????????????????????????? */ +Currently does nothing. */ int ha_innobase::index_end(void) @@ -2290,6 +2357,15 @@ ha_innobase::external_lock( trx_search_latch_release_if_reserved(trx); } + if (trx->auto_inc_lock) { + + /* If we had reserved the auto-inc lock for + some table in this SQL statement, we release + it now */ + + row_unlock_table_autoinc_for_mysql(trx); + } + if (!(thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) { innobase_commit(thd, trx); @@ -2452,7 +2528,9 @@ ha_innobase::create( const char* name, /* in: table name */ TABLE* form, /* in: information on table columns and indexes */ - HA_CREATE_INFO* create_info) /* in: ??????? */ + HA_CREATE_INFO* create_info) /* in: more information of the + created table, contains also the + create statement string */ { int error; dict_table_t* innobase_table; @@ -2543,6 +2621,19 @@ ha_innobase::create( } } + error = row_table_add_foreign_constraints(trx, + create_info->create_statement, norm_name); + + error = convert_error_code_to_mysql(error); + + if (error) { + trx_commit_for_mysql(trx); + + trx_free_for_mysql(trx); + + DBUG_RETURN(error); + } + trx_commit_for_mysql(trx); innobase_table = dict_table_get(norm_name, NULL); @@ -2563,8 +2654,8 @@ ha_innobase::create( Drops a table from an InnoDB database. Before calling this function, MySQL calls innobase_commit to commit the transaction of the current user. Then the current user cannot have locks set on the table. Drop table -operation inside InnoDB will wait sleeping in a loop until no other -user has locks on the table. */ +operation inside InnoDB will remove all locks any user has on the table +inside InnoDB. */ int ha_innobase::delete_table( @@ -2606,6 +2697,53 @@ ha_innobase::delete_table( DBUG_RETURN(error); } +/********************************************************************* +Removes all tables in the named database inside InnoDB. */ + +int +innobase_drop_database( +/*===================*/ + /* out: error number */ + char* path) /* in: database path; inside InnoDB the name + of the last directory in the path is used as + the database name: for example, in 'mysql/data/test' + the database name is 'test' */ +{ + ulint len = 0; + trx_t* trx; + char* ptr; + int error; + char namebuf[10000]; + + ptr = strend(path) - 2; + + while (ptr >= path && *ptr != '\\' && *ptr != '/') { + ptr--; + len++; + } + + ptr++; + + memcpy(namebuf, ptr, len); + namebuf[len] = '/'; + namebuf[len + 1] = '\0'; + + trx = trx_allocate_for_mysql(); + + error = row_drop_database_for_mysql(namebuf, trx); + + /* Tell the InnoDB server that there might be work for + utility threads: */ + + srv_active_wake_master_thread(); + + trx_free_for_mysql(trx); + + error = convert_error_code_to_mysql(error); + + return(error); +} + /************************************************************************* Renames an InnoDB table. */ @@ -2742,12 +2880,13 @@ improve the algorithm of filesort.cc. */ ha_rows ha_innobase::estimate_number_of_rows(void) /*======================================*/ - /* out: upper bound of rows, currently 32-bit int - or uint */ + /* out: upper bound of rows */ { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; - dict_table_t* ib_table; - + dict_index_t* index; + ulonglong estimate; + ulonglong data_file_length; + if (prebuilt->trx) { prebuilt->trx->op_info = (char*) "estimating upper bound of table size"; @@ -2755,21 +2894,21 @@ ha_innobase::estimate_number_of_rows(void) DBUG_ENTER("info"); - ib_table = prebuilt->table; - - dict_update_statistics(ib_table); - - data_file_length = ((ulonglong) - ib_table->stat_clustered_index_size) - * UNIV_PAGE_SIZE; + dict_update_statistics(prebuilt->table); - /* The minimum clustered index record size is 20 bytes */ + index = dict_table_get_first_index_noninline(prebuilt->table); + + data_file_length = ((ulonglong) index->stat_n_leaf_pages) + * UNIV_PAGE_SIZE; + /* Calculate a minimum length for a clustered index record */ + estimate = data_file_length / dict_index_calc_min_rec_len(index); + if (prebuilt->trx) { prebuilt->trx->op_info = (char*) ""; } - - return((ha_rows) (1000 + data_file_length / 20)); + + return((ha_rows) estimate); } /************************************************************************* @@ -2784,10 +2923,10 @@ ha_innobase::scan_time() { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; - /* In the following formula we assume that scanning 5 pages + /* In the following formula we assume that scanning 10 pages takes the same time as a disk seek: */ - return((double) (1 + prebuilt->table->stat_clustered_index_size / 5)); + return((double) (prebuilt->table->stat_clustered_index_size / 10)); } /************************************************************************* @@ -2802,8 +2941,9 @@ ha_innobase::info( row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; dict_table_t* ib_table; dict_index_t* index; - uint rec_per_key; - uint i; + ulong rec_per_key; + ulong j; + ulong i; DBUG_ENTER("info"); @@ -2821,7 +2961,7 @@ ha_innobase::info( } if (flag & HA_STATUS_VARIABLE) { - records = ib_table->stat_n_rows; + records = (ha_rows)ib_table->stat_n_rows; deleted = 0; data_file_length = ((ulonglong) ib_table->stat_clustered_index_size) @@ -2847,16 +2987,24 @@ ha_innobase::info( } for (i = 0; i < table->keys; i++) { - if (index->stat_n_diff_key_vals == 0) { - rec_per_key = records; - } else { - rec_per_key = records / - index->stat_n_diff_key_vals; + for (j = 0; j < table->key_info[i].key_parts; j++) { + + if (index->stat_n_diff_key_vals[j + 1] == 0) { + + rec_per_key = records; + } else { + rec_per_key = (ulong)(records / + index->stat_n_diff_key_vals[j + 1]); + } + + if (rec_per_key == 0) { + rec_per_key = 1; + } + + table->key_info[i].rec_per_key[j] + = rec_per_key; } - - table->key_info[i].rec_per_key[ - table->key_info[i].key_parts - 1] - = rec_per_key; + index = dict_table_get_next_index_noninline(index); } } diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h index daa987dd757..3b0144a4fca 100644 --- a/sql/ha_innobase.h +++ b/sql/ha_innobase.h @@ -177,3 +177,5 @@ uint innobase_get_free_space(void); int innobase_commit(THD *thd, void* trx_handle); int innobase_rollback(THD *thd, void* trx_handle); int innobase_close_connection(THD *thd); +int innobase_drop_database(char *path); + diff --git a/sql/handler.cc b/sql/handler.cc index 4876a73d2a9..742bcd3aa0a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -181,6 +181,13 @@ int ha_panic(enum ha_panic_function flag) return error; } /* ha_panic */ +void ha_drop_database(char* path) +{ +#ifdef HAVE_INNOBASE_DB + if (!innodb_skip) + innobase_drop_database(path); +#endif +} void ha_close_connection(THD* thd) { diff --git a/sql/handler.h b/sql/handler.h index 2f54dafe82c..e36a81cf7c7 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -150,6 +150,7 @@ typedef struct st_ha_create_information ulonglong auto_increment_value; char *comment,*password; char *data_file_name, *index_file_name; + char *create_statement; uint options; /* OR of HA_CREATE_ options */ uint raid_type,raid_chunks; ulong raid_chunksize; @@ -347,6 +348,7 @@ enum db_type ha_checktype(enum db_type database_type); int ha_create_table(const char *name, HA_CREATE_INFO *create_info, bool update_create_info); int ha_delete_table(enum db_type db_type, const char *path); +void ha_drop_database(char* path); void ha_key_cache(void); int ha_start_stmt(THD *thd); int ha_commit_trans(THD *thd, THD_TRANS *trans); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1a84877df05..65b130bfd82 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -21,6 +21,7 @@ #include "sql_acl.h" #include "slave.h" #include "sql_repl.h" +#include "repl_failsafe.h" #include "stacktrace.h" #ifdef HAVE_BERKELEY_DB #include "ha_berkeley.h" @@ -76,9 +77,7 @@ extern "C" { // Because of SCO 3.2V4.2 #include <sys/select.h> #endif #include <sys/utsname.h> -#else -#include <windows.h> -#endif // __WIN__ +#endif /* __WIN__ */ #ifdef HAVE_LIBWRAP #include <tcpd.h> @@ -1684,6 +1683,7 @@ int main(int argc, char **argv) (void) pthread_mutex_init(&LOCK_slave, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_server_id, 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_cond_init(&COND_thread_count,NULL); (void) pthread_cond_init(&COND_refresh,NULL); (void) pthread_cond_init(&COND_thread_cache,NULL); @@ -1692,6 +1692,7 @@ int main(int argc, char **argv) (void) pthread_cond_init(&COND_binlog_update, NULL); (void) pthread_cond_init(&COND_slave_stopped, NULL); (void) pthread_cond_init(&COND_slave_start, NULL); + (void) pthread_cond_init(&COND_rpl_status, NULL); init_signals(); if (set_default_charset_by_name(default_charset, MYF(MY_WME))) @@ -2595,7 +2596,7 @@ enum options { OPT_REPORT_USER, OPT_REPORT_PASSWORD, OPT_REPORT_PORT, OPT_SHOW_SLAVE_AUTH_INFO, OPT_OLD_RPL_COMPAT, OPT_SLAVE_LOAD_TMPDIR, OPT_NO_MIX_TYPE, - OPT_RPL_RECOVERY_RANK + OPT_RPL_RECOVERY_RANK,OPT_INIT_RPL_ROLE }; static struct option long_options[] = { @@ -2631,6 +2632,7 @@ static struct option long_options[] = { {"enable-pstack", no_argument, 0, (int) OPT_DO_PSTACK}, {"exit-info", optional_argument, 0, 'T'}, {"flush", no_argument, 0, (int) OPT_FLUSH}, + {"init-rpl-role", required_argument, 0, (int) OPT_INIT_RPL_ROLE}, /* We must always support this option to make scripts like mysqltest easier to do */ {"innodb_data_file_path", required_argument, 0, @@ -3052,6 +3054,8 @@ struct show_var_st status_vars[]= { {"Open_streams", (char*) &my_stream_opened, SHOW_INT_CONST}, {"Opened_tables", (char*) &opened_tables, SHOW_LONG}, {"Questions", (char*) 0, SHOW_QUESTION}, + {"Rpl_status", (char*) 0, + SHOW_RPL_STATUS}, {"Select_full_join", (char*) &select_full_join_count, SHOW_LONG}, {"Select_full_range_join", (char*) &select_full_range_join_count, SHOW_LONG}, {"Select_range", (char*) &select_range_count, SHOW_LONG}, @@ -3489,6 +3493,17 @@ static void get_options(int argc,char **argv) opt_log_slave_updates = 1; break; + case (int) OPT_INIT_RPL_ROLE: + { + int role; + if ((role=find_type(optarg, &rpl_role_typelib, 2)) <= 0) + { + fprintf(stderr, "Unknown replication role: %s\n", optarg); + exit(1); + } + rpl_status = (role == 1) ? RPL_AUTH_MASTER : RPL_IDLE_SLAVE; + break; + } case (int)OPT_REPLICATE_IGNORE_DB: { i_string *db = new i_string(optarg); diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc new file mode 100644 index 00000000000..40eb3b8bb7c --- /dev/null +++ b/sql/repl_failsafe.cc @@ -0,0 +1,43 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB & Sasha + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +// Sasha Pachev <sasha@mysql.com> is currently in charge of this file + +#include "mysql_priv.h" +#include "repl_failsafe.h" + +RPL_STATUS rpl_status=RPL_NULL; +pthread_mutex_t LOCK_rpl_status; +pthread_cond_t COND_rpl_status; + +const char *rpl_role_type[] = {"MASTER","SLAVE",NullS}; +TYPELIB rpl_role_typelib = {array_elements(rpl_role_type)-1,"", + rpl_role_type}; + +const char* rpl_status_type[] = {"AUTH_MASTER","ACTIVE_SLAVE","IDLE_SLAVE", + "LOST_SOLDIER","TROOP_SOLDIER", + "RECOVERY_CAPTAIN","NULL",NullS}; +TYPELIB rpl_status_typelib= {array_elements(rpl_status_type)-1,"", + rpl_status_type}; + +void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status) +{ + pthread_mutex_lock(&LOCK_rpl_status); + if (rpl_status == from_status || rpl_status == RPL_ANY) + rpl_status = to_status; + pthread_mutex_unlock(&LOCK_rpl_status); +} + diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h new file mode 100644 index 00000000000..42b386e6255 --- /dev/null +++ b/sql/repl_failsafe.h @@ -0,0 +1,16 @@ +#ifndef REPL_FAILSAFE_H +#define REPL_FAILSAFE_H + +typedef enum {RPL_AUTH_MASTER=0,RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE, + RPL_LOST_SOLDIER,RPL_TROOP_SOLDIER, + RPL_RECOVERY_CAPTAIN,RPL_NULL /* inactive */, + RPL_ANY /* wild card used by change_rpl_status */ } RPL_STATUS; +extern RPL_STATUS rpl_status; + +extern pthread_mutex_t LOCK_rpl_status; +extern pthread_cond_t COND_rpl_status; +extern TYPELIB rpl_role_typelib, rpl_status_typelib; +extern const char* rpl_role_type[], *rpl_status_type[]; + +void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status); +#endif diff --git a/sql/slave.cc b/sql/slave.cc index d2e038bef88..7c065a89c9d 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -21,6 +21,7 @@ #include "mini_client.h" #include "slave.h" #include "sql_repl.h" +#include "repl_failsafe.h" #include <thr_alarm.h> #include <my_dir.h> @@ -1220,6 +1221,7 @@ position %s", thd->proc_info = "Waiting for slave mutex on exit"; pthread_mutex_lock(&LOCK_slave); slave_running = 0; + change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE); abort_slave = 0; save_temporary_tables = thd->temporary_tables; thd->temporary_tables = 0; // remove tempation from destructor to close them @@ -1257,6 +1259,7 @@ static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi) if(!slave_was_killed) { + change_rpl_status(RPL_IDLE_SLAVE,RPL_ACTIVE_SLAVE); mysql_log.write(thd, COM_CONNECT_OUT, "%s@%s:%d", mi->user, mi->host, mi->port); #ifdef SIGNAL_WITH_VIO_CLOSE @@ -1298,9 +1301,15 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi) mi->connect_retry); safe_sleep(thd, mi->connect_retry); } - if (err_count++ == master_retry_count) + /* by default we try forever. The reason is that failure will trigger + master election, so if the user did not set master_retry_count we + do not want to have electioin triggered on the first failure to + connect + */ + if (master_retry_count && err_count++ == master_retry_count) { slave_was_killed=1; + change_rpl_status(RPL_ACTIVE_SLAVE,RPL_LOST_SOLDIER); break; } } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 05b380ebd77..64ad205803e 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -158,6 +158,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) error = -1; if ((deleted=mysql_rm_known_files(thd, dirp, db, path,0)) >= 0 && thd) { + ha_drop_database(path); if (!silent) { if (!thd->query) @@ -333,7 +334,7 @@ bool mysql_change_db(THD *thd,const char *name) x_free(dbname); DBUG_RETURN(1); } - DBUG_PRINT("general",("Use database: %s", dbname)); + DBUG_PRINT("info",("Use database: %s", dbname)); if (test_all_bits(thd->master_access,DB_ACLS)) db_access=DB_ACLS; else diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7104e41fc46..b83a50aec16 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -120,7 +120,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, protocol_version == 9 || !(thd->client_capabilities & CLIENT_LONG_PASSWORD)); - DBUG_PRINT("general", + DBUG_PRINT("info", ("Capabilities: %d packet_length: %d Host: '%s' User: '%s' Using password: %s Access: %u db: '%s'", thd->client_capabilities, thd->max_packet_length, thd->host_or_ip, thd->priv_user, @@ -323,7 +323,7 @@ check_connections(THD *thd) */ DBUG_PRINT("info", (("check_connections called by thread %d"), thd->thread_id)); - DBUG_PRINT("general",("New connection received on %s", + DBUG_PRINT("info",("New connection received on %s", vio_description(net->vio))); if (!thd->host) // If TCP/IP connection { @@ -347,15 +347,15 @@ check_connections(THD *thd) if (connect_errors > max_connect_errors) return(ER_HOST_IS_BLOCKED); } - DBUG_PRINT("general",("Host: %s ip: %s", - thd->host ? thd->host : "unknown host", - thd->ip ? thd->ip : "unknown ip")); + DBUG_PRINT("info",("Host: %s ip: %s", + thd->host ? thd->host : "unknown host", + thd->ip ? thd->ip : "unknown ip")); if (acl_check_host(thd->host,thd->ip)) return(ER_HOST_NOT_PRIVILEGED); } else /* Hostname given means that the connection was on a socket */ { - DBUG_PRINT("general",("Host: %s",thd->host)); + DBUG_PRINT("info",("Host: %s",thd->host)); thd->host_or_ip=thd->host; thd->ip=0; bzero((char*) &thd->remote,sizeof(struct sockaddr)); @@ -731,17 +731,17 @@ bool do_command(THD *thd) net_new_transaction(net); if ((packet_length=my_net_read(net)) == packet_error) { - DBUG_PRINT("general",("Got error reading command from socket %s", - vio_description(net->vio) )); + DBUG_PRINT("info",("Got error reading command from socket %s", + vio_description(net->vio) )); return TRUE; } else { packet=(char*) net->read_pos; command = (enum enum_server_command) (uchar) packet[0]; - DBUG_PRINT("general",("Command on %s = %d (%s)", - vio_description(net->vio), command, - command_name[command])); + DBUG_PRINT("info",("Command on %s = %d (%s)", + vio_description(net->vio), command, + command_name[command])); } net->timeout=old_timeout; // Timeout for writing DBUG_RETURN(dispatch_command(command,thd, packet+1, packet_length)); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 5a9777e24a4..19c3d89caaf 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -20,6 +20,7 @@ #include "mysql_priv.h" #include "sql_select.h" // For select_describe #include "sql_acl.h" +#include "repl_failsafe.h" #include <my_dir.h> #ifdef HAVE_BERKELEY_DB @@ -1164,6 +1165,9 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables) case SHOW_QUESTION: net_store_data(&packet2,(uint32) thd->query_id); break; + case SHOW_RPL_STATUS: + net_store_data(&packet2, rpl_status_type[(int)rpl_status]); + break; case SHOW_OPENTABLES: net_store_data(&packet2,(uint32) cached_tables()); break; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9306a6d4d9a..d76c6bbd627 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -598,6 +598,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, thd->proc_info="creating table"; + create_info->create_statement = thd->query; create_info->table_options=db_options; if (rea_create_table(path, create_info, fields, key_count, key_info_buffer)) diff --git a/sql/structs.h b/sql/structs.h index 2f6f850bc9e..439384c7191 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -140,6 +140,7 @@ enum SHOW_TYPE { SHOW_LONG,SHOW_CHAR,SHOW_INT,SHOW_CHAR_PTR,SHOW_BOOL, ,SHOW_SSL_CTX_SESS_TIMEOUTS, SHOW_SSL_CTX_SESS_CACHE_FULL ,SHOW_SSL_GET_CIPHER_LIST #endif /* HAVE_OPENSSL */ + ,SHOW_RPL_STATUS }; enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED}; diff --git a/sql/table.cc b/sql/table.cc index 1ed856f7854..927119f45de 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -261,7 +261,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, outparam->comment=strdup_root(&outparam->mem_root, (char*) head+47); - DBUG_PRINT("form",("i_count: %d i_parts: %d index: %d n_length: %d int_length: %d", interval_count,interval_parts, outparam->keys,n_length,int_length)); + DBUG_PRINT("info",("i_count: %d i_parts: %d index: %d n_length: %d int_length: %d", interval_count,interval_parts, outparam->keys,n_length,int_length)); if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root, |