diff options
author | bell@sanja.is.com.ua <> | 2003-04-05 09:06:45 +0300 |
---|---|---|
committer | bell@sanja.is.com.ua <> | 2003-04-05 09:06:45 +0300 |
commit | e793f17691e7be552fcee6fb66de99b1c82a9db0 (patch) | |
tree | 4b3c8eb8e969b94b64f913a450cc3328ebb00e8a /sql | |
parent | 63cb5658955478e24546fe2316241de55e114941 (diff) | |
parent | 9b0266a037ea926307765cbda39d2af4b2504b49 (diff) | |
download | mariadb-git-e793f17691e7be552fcee6fb66de99b1c82a9db0.tar.gz |
Merge abelkin@bk-internal.mysql.com:/home/bk/mysql-4.0
into sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.0
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_myisam.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 17 | ||||
-rw-r--r-- | sql/log_event.cc | 44 | ||||
-rw-r--r-- | sql/mysqld.cc | 38 | ||||
-rw-r--r-- | sql/sql_acl.cc | 22 |
5 files changed, 87 insertions, 36 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index fd1a115ddff..a1fb09d049b 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1037,7 +1037,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, &keydef, table_arg->keys*sizeof(MI_KEYDEF), &keyseg, ((table_arg->key_parts + table_arg->keys) * sizeof(MI_KEYSEG)), - 0))) + NullS))) DBUG_RETURN(1); pos=table_arg->key_info; diff --git a/sql/log.cc b/sql/log.cc index 9befcaefb01..8a5aba5cd34 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -310,7 +310,10 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, DBUG_RETURN(0); err: - sql_print_error("Could not use %s for logging (error %d)", log_name, errno); + sql_print_error("Could not use %s for logging (error %d). \ +Turning logging off for the whole duration of the MySQL server process. \ +To turn it on again: fix the cause, \ +shutdown the MySQL server and restart it.", log_name, errno); if (file >= 0) my_close(file,MYF(0)); if (index_file_nr >= 0) @@ -1120,9 +1123,17 @@ bool MYSQL_LOG::write(Log_event* event_info) the table handler commit here, protected by the LOCK_log mutex, because otherwise the transactions may end up in a different order in the table handler log! + + Note that we will NOT call ha_report_binlog_offset_and_commit() if + there are binlog events cached in the transaction cache. That is + because then the log event which we write to the binlog here is + not a transactional event. In versions < 4.0.13 before this fix this + caused an InnoDB transaction to be committed if in the middle there + was a MyISAM event! */ - if (file == &log_file) + if (file == &log_file && opt_using_transactions + && !my_b_tell(&thd->transaction.trans_log)) { /* LOAD DATA INFILE in AUTOCOMMIT=1 mode writes to the binlog @@ -1560,6 +1571,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 78470a2b198..2040cebf17e 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -282,9 +282,9 @@ void Load_log_event::pack_info(String* packet) tmp.append("LOAD DATA INFILE '"); tmp.append(fname, fname_len); tmp.append("' ", 2); - if (sql_ex.opt_flags && REPLACE_FLAG ) + if (sql_ex.opt_flags & REPLACE_FLAG) tmp.append(" REPLACE "); - else if (sql_ex.opt_flags && IGNORE_FLAG ) + else if (sql_ex.opt_flags & IGNORE_FLAG) tmp.append(" IGNORE "); tmp.append("INTO TABLE "); @@ -297,7 +297,7 @@ void Load_log_event::pack_info(String* packet) if (sql_ex.enclosed_len) { - if (sql_ex.opt_flags && OPT_ENCLOSED_FLAG ) + if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG ) tmp.append(" OPTIONALLY "); tmp.append( " ENCLOSED BY "); pretty_print_str(&tmp, sql_ex.enclosed, sql_ex.enclosed_len); @@ -1146,28 +1146,28 @@ 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; switch (handle_dup) { - case DUP_IGNORE: sql_ex.opt_flags |= IGNORE_FLAG; break; - case DUP_REPLACE: sql_ex.opt_flags |= REPLACE_FLAG; break; + case DUP_IGNORE: sql_ex.opt_flags|= IGNORE_FLAG; break; + case DUP_REPLACE: sql_ex.opt_flags|= REPLACE_FLAG; break; case DUP_ERROR: break; } if (!ex->field_term->length()) - sql_ex.empty_flags |= FIELD_TERM_EMPTY; + sql_ex.empty_flags|= FIELD_TERM_EMPTY; if (!ex->enclosed->length()) - sql_ex.empty_flags |= ENCLOSED_EMPTY; + sql_ex.empty_flags|= ENCLOSED_EMPTY; if (!ex->line_term->length()) - sql_ex.empty_flags |= LINE_TERM_EMPTY; + sql_ex.empty_flags|= LINE_TERM_EMPTY; if (!ex->line_start->length()) - sql_ex.empty_flags |= LINE_START_EMPTY; + sql_ex.empty_flags|= LINE_START_EMPTY; if (!ex->escaped->length()) - sql_ex.empty_flags |= ESCAPED_EMPTY; + sql_ex.empty_flags|= ESCAPED_EMPTY; skip_lines = ex->skip_lines; @@ -1273,9 +1273,9 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) fprintf(file, "LOAD 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); @@ -1287,7 +1287,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); @@ -1859,15 +1859,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); String enclosed(sql_ex.enclosed,sql_ex.enclosed_len); String line_term(sql_ex.line_term,sql_ex.line_term_len); String line_start(sql_ex.line_start,sql_ex.line_start_len); String escaped(sql_ex.escaped,sql_ex.escaped_len); + 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) @@ -1876,7 +1880,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->slave_proxy_id = thd->thread_id; + thd->slave_proxy_id = thread_id; if (net) { // mysql_load will use thd->net to read the file diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c407fccf00b..4ae248acb67 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2105,7 +2105,7 @@ int main(int argc, char **argv) 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", @@ -3321,7 +3321,7 @@ struct my_option my_long_options[] = (gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"log-bin", OPT_BIN_LOG, - "Log queries in new binary format (for replication)", + "Log update queries in binary format", (gptr*) &opt_bin_logname, (gptr*) &opt_bin_logname, 0, GET_STR_ALLOC, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-bin-index", OPT_BIN_LOG_INDEX, @@ -3375,27 +3375,32 @@ struct my_option my_long_options[] = (gptr*) &master_retry_count, (gptr*) &master_retry_count, 0, GET_ULONG, REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0}, {"master-info-file", OPT_MASTER_INFO_FILE, - "The location of the file that remembers where we left off on the master during the replication process. The default is `master.info' in the data directory. You should not need to change this.", + "The location and name of the file that remembers the master and where the I/O replication \ +thread is in the master's binlogs.", (gptr*) &master_info_file, (gptr*) &master_info_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl", OPT_MASTER_SSL, - "Turn SSL on for replication. Be warned that is this is a relatively new feature.", + "Planned to enable the slave to connect to the master using SSL. Does nothing yet.", (gptr*) &master_ssl, (gptr*) &master_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-key", OPT_MASTER_SSL_KEY, - "Master SSL keyfile name. Only applies if you have enabled master-ssl.", + "Master SSL keyfile name. Only applies if you have enabled master-ssl. Does \ +nothing yet.", (gptr*) &master_ssl_key, (gptr*) &master_ssl_key, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-cert", OPT_MASTER_SSL_CERT, - "Master SSL certificate file name. Only applies if you have enabled master-ssl.", + "Master SSL certificate file name. Only applies if you have enabled \ +master-ssl. Does nothing yet.", (gptr*) &master_ssl_cert, (gptr*) &master_ssl_cert, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-capath", OPT_MASTER_SSL_CAPATH, - "Master SSL CA path. Only applies if you have enabled master-ssl.", + "Master SSL CA path. Only applies if you have enabled master-ssl. \ +Does nothing yet.", (gptr*) &master_ssl_capath, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-cipher", OPT_MASTER_SSL_CIPHER, - "Master SSL cipher. Only applies if you have enabled master-ssl.", + "Master SSL cipher. Only applies if you have enabled master-ssl. \ +Does nothing yet.", (gptr*) &master_ssl_cipher, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"myisam-recover", OPT_MYISAM_RECOVER, @@ -3494,10 +3499,13 @@ struct my_option my_long_options[] = {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented", (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"relay-log", OPT_RELAY_LOG, "Undocumented", + {"relay-log", OPT_RELAY_LOG, + "The location and name to use for relay logs", (gptr*) &opt_relay_logname, (gptr*) &opt_relay_logname, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"relay-log-index", OPT_RELAY_LOG_INDEX, "Undocumented", + {"relay-log-index", OPT_RELAY_LOG_INDEX, + "The location and name to use for the file that keeps a list of the last \ +relay logs", (gptr*) &opt_relaylog_index_name, (gptr*) &opt_relaylog_index_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).", @@ -3559,10 +3567,14 @@ struct my_option my_long_options[] = {"skip-thread-priority", OPT_SKIP_PRIOR, "Don't give threads different priorities.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE, "Undocumented", + {"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE, + "The location and name of the file that remembers where the SQL replication \ +thread is in the relay logs", (gptr*) &relay_log_info_file, (gptr*) &relay_log_info_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR, "Undocumented", + {"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR, + "The location where the slave should put its temporary files when \ +replicating a LOAD DATA INFILE command", (gptr*) &slave_load_tmpdir, (gptr*) &slave_load_tmpdir, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"slave-skip-errors", OPT_SLAVE_SKIP_ERRORS, @@ -3888,7 +3900,7 @@ struct my_option my_long_options[] = (gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0}, {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT, - "Max space to use for all relay logs", + "Maximum space to use for all relay logs", (gptr*) &relay_log_space_limit, (gptr*) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L, (longlong) ULONG_MAX, 0, 1, 0}, diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index ee9d3f1c1ea..e8cbba8aefa 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 <assert.h> #include <stdarg.h> @@ -2052,6 +2055,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 */ @@ -2214,6 +2226,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 */ |