diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_myisam.cc | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 2 | ||||
-rw-r--r-- | sql/log_event.cc | 41 | ||||
-rw-r--r-- | sql/mysqld.cc | 4 | ||||
-rw-r--r-- | sql/sql_acl.cc | 22 | ||||
-rw-r--r-- | sql/sql_parse.cc | 13 | ||||
-rw-r--r-- | sql/sql_show.cc | 2 |
8 files changed, 64 insertions, 24 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 7e8dab5daed..213f5baf388 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1051,7 +1051,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, &keyseg, ((table_arg->key_parts + table_arg->keys) * sizeof(HA_KEYSEG)), - 0))) + NullS))) DBUG_RETURN(1); pos=table_arg->key_info; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5b2706e3eef..0bb3561cf76 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -814,7 +814,7 @@ void Item_func_replace::fix_length_and_dec() if (diff > 0 && args[1]->max_length) { // Calculate of maxreplaces uint max_substrs= max_length/args[1]->max_length; - max_length+= max_substrs*(uint) diff; + max_length+= max_substrs * (uint) diff; } if (max_length > MAX_BLOB_WIDTH) { diff --git a/sql/log.cc b/sql/log.cc index cd4c2a38ac8..51b1c572601 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1670,6 +1670,8 @@ void sql_print_error(const char *format,...) char buff[1024]; my_vsnprintf(buff,sizeof(buff)-1,format,args); DBUG_PRINT("error",("%s",buff)); + va_end(args); + va_start(args,format); } #endif skr=time(NULL); diff --git a/sql/log_event.cc b/sql/log_event.cc index 5e3340b4cf7..d4efb65bf42 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1136,9 +1136,9 @@ void Load_log_event::pack_info(Protocol *protocol) pos+= fname_len; pos= strmov(pos, "' "); - if (sql_ex.opt_flags && REPLACE_FLAG ) + if (sql_ex.opt_flags & REPLACE_FLAG) pos= strmov(pos, " REPLACE "); - else if (sql_ex.opt_flags && IGNORE_FLAG ) + else if (sql_ex.opt_flags & IGNORE_FLAG) pos= strmov(pos, " IGNORE "); pos= strmov(pos ,"INTO TABLE "); @@ -1153,7 +1153,7 @@ void Load_log_event::pack_info(Protocol *protocol) if (sql_ex.enclosed_len) { - if (sql_ex.opt_flags && OPT_ENCLOSED_FLAG ) + if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG) pos= strmov(pos, " OPTIONALLY "); pos= strmov(pos, " ENCLOSED BY "); pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len); @@ -1279,18 +1279,18 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex, sql_ex.cached_new_format = -1; if (ex->dumpfile) - sql_ex.opt_flags |= DUMPFILE_FLAG; + sql_ex.opt_flags|= DUMPFILE_FLAG; if (ex->opt_enclosed) - sql_ex.opt_flags |= OPT_ENCLOSED_FLAG; + sql_ex.opt_flags|= OPT_ENCLOSED_FLAG; - sql_ex.empty_flags = 0; + sql_ex.empty_flags= 0; switch (handle_dup) { case DUP_IGNORE: - sql_ex.opt_flags |= IGNORE_FLAG; + sql_ex.opt_flags|= IGNORE_FLAG; break; case DUP_REPLACE: - sql_ex.opt_flags |= REPLACE_FLAG; + sql_ex.opt_flags|= REPLACE_FLAG; break; case DUP_UPDATE: // Impossible here case DUP_ERROR: @@ -1426,9 +1426,9 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) fprintf(file, "LOCAL "); fprintf(file, "DATA INFILE '%-*s' ", fname_len, 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); @@ -1440,7 +1440,7 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) if (sql_ex.enclosed) { - 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_str(file, sql_ex.enclosed, sql_ex.enclosed_len); @@ -1565,15 +1565,19 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, { char llbuff[22]; enum enum_duplicates handle_dup = DUP_IGNORE; - if (sql_ex.opt_flags && REPLACE_FLAG) - handle_dup = DUP_REPLACE; - sql_exchange ex((char*)fname, sql_ex.opt_flags && - DUMPFILE_FLAG ); + if (sql_ex.opt_flags & REPLACE_FLAG) + handle_dup= DUP_REPLACE; + sql_exchange ex((char*)fname, sql_ex.opt_flags & DUMPFILE_FLAG); String field_term(sql_ex.field_term,sql_ex.field_term_len,log_cs); String enclosed(sql_ex.enclosed,sql_ex.enclosed_len,log_cs); String line_term(sql_ex.line_term,sql_ex.line_term_len,log_cs); String line_start(sql_ex.line_start,sql_ex.line_start_len,log_cs); String escaped(sql_ex.escaped,sql_ex.escaped_len, log_cs); + ex.field_term= &field_term; + ex.enclosed= &enclosed; + ex.line_term= &line_term; + ex.line_start= &line_start; + ex.escaped= &escaped; ex.opt_enclosed = (sql_ex.opt_flags & OPT_ENCLOSED_FLAG); if (sql_ex.empty_flags & FIELD_TERM_EMPTY) @@ -1582,7 +1586,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, ex.skip_lines = skip_lines; List<Item> field_list; set_fields(field_list); - thd->variables.pseudo_thread_id= thd->thread_id; + thd->variables.pseudo_thread_id= thread_id; if (net) { // mysql_load will use thd->net to read the file @@ -1597,9 +1601,8 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, thd->query_error = 1; if (thd->cuted_fields) { - /* - log_pos is the position of the LOAD - event in the master log + /* + log_pos is the position of the LOAD event in the master log */ sql_print_error("Slave: load data infile at position %s in log \ '%s' produced %d warning(s)", llstr(log_pos,llbuff), RPL_LOG_NAME, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8af89bd58f6..5f6983753d1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2047,7 +2047,7 @@ static int init_common_variables(const char *conf_file_name, int argc, size_t stack_size= 0; pthread_attr_getstacksize(&connection_attrib, &stack_size); /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */ - if (stack_size && stack_size != thread_stack) + if (stack_size && stack_size < thread_stack) { if (global_system_variables.log_warnings) sql_print_error("Warning: Asked for %ld thread stack, but got %ld", @@ -3626,7 +3626,7 @@ struct my_option my_long_options[] = "Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2 (write at commit, flush once per second)", (gptr*) &innobase_flush_log_at_trx_commit, (gptr*) &innobase_flush_log_at_trx_commit, - 0, GET_UINT, OPT_ARG, 0, 0, 2, 0, 0, 0}, + 0, GET_UINT, OPT_ARG, 1, 0, 2, 0, 0, 0}, {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD, "With which method to flush data", (gptr*) &innobase_unix_file_flush_method, (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1be22404dbb..4bed99489de 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -28,6 +28,9 @@ #include "mysql_priv.h" #include "sql_acl.h" #include "hash_filo.h" +#ifdef HAVE_REPLICATION +#include "sql_repl.h" //for tables_ok() +#endif #include <m_ctype.h> #include <stdarg.h> @@ -2128,6 +2131,15 @@ int mysql_table_grant (THD *thd, TABLE_LIST *table_list, tables[0].lock_type=tables[1].lock_type=tables[2].lock_type=TL_WRITE; tables[0].db=tables[1].db=tables[2].db=(char*) "mysql"; +#ifdef HAVE_REPLICATION + /* + GRANT and REVOKE are applied the slave in/exclusion rules as they are + some kind of updates to the mysql.% tables. + */ + if (thd->slave_thread && table_rules_on && !tables_ok(0, tables)) + DBUG_RETURN(0); +#endif + if (open_and_lock_tables(thd,tables)) { // Should never happen close_thread_tables(thd); /* purecov: deadcode */ @@ -2289,6 +2301,16 @@ int mysql_grant (THD *thd, const char *db, List <LEX_USER> &list, tables[0].lock_type=tables[1].lock_type=TL_WRITE; tables[0].db=tables[1].db=(char*) "mysql"; tables[0].table=tables[1].table=0; + +#ifdef HAVE_REPLICATION + /* + GRANT and REVOKE are applied the slave in/exclusion rules as they are + some kind of updates to the mysql.% tables. + */ + if (thd->slave_thread && table_rules_on && !tables_ok(0, tables)) + DBUG_RETURN(0); +#endif + if (open_and_lock_tables(thd,tables)) { // This should never happen close_thread_tables(thd); /* purecov: deadcode */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9c3b52f5635..2f4915c74f1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2468,6 +2468,19 @@ mysql_execute_command(THD *thd) break; } } + else + { + /* + If this is a slave thread, we may sometimes execute some + DROP / * 40005 TEMPORARY * / TABLE + that come from parts of binlogs (likely if we use RESET SLAVE or CHANGE + MASTER TO), while the temporary table has already been dropped. + To not generate such irrelevant "table does not exist errors", we + silently add IF EXISTS if TEMPORARY was used. + */ + if (thd->slave_thread) + lex->drop_if_exists= 1; + } res= mysql_rm_table(thd,tables,lex->drop_if_exists, lex->drop_temporary); } break; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index fe4f1a0576d..8d6eccae87a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1330,7 +1330,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) thd_info->user=thd->strdup(tmp->user ? tmp->user : (tmp->system_thread ? "system user" : "unauthenticated user")); - if (tmp->peer_port && (tmp->host || tmp->ip)) + if (tmp->peer_port && (tmp->host || tmp->ip) && thd->host_or_ip[0]) { if ((thd_info->host= thd->alloc(LIST_PROCESS_HOST_LEN+1))) my_snprintf((char *) thd_info->host, LIST_PROCESS_HOST_LEN, |