From 3a4d315fa1fba3dbd06f9ff7ba7f2d65da7d3d2a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 May 2004 13:07:36 +0300 Subject: [PATCH 1/4] fixed db name and layout (can cause very rare race condition bug) --- sql/sql_acl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 56884ad9dd1..4d85741cdaa 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2141,9 +2141,9 @@ bool check_grant_column(THD *thd,TABLE *table, const char *name, if (table->grant.version != grant_version) { table->grant.grant_table= - table_hash_search(thd->host,thd->ip,thd->db, + table_hash_search(thd->host, thd->ip, table->table_cache_key, thd->priv_user, - table->real_name,0); /* purecov: inspected */ + table->real_name, 0); /* purecov: inspected */ table->grant.version=grant_version; /* purecov: inspected */ } if (!(grant_table=table->grant.grant_table)) From 48260e9d92111b40d95854e15233205a87d95da6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 May 2004 15:54:28 +0300 Subject: [PATCH 2/4] InnoDB portability fix: new function os_file_set_eof() innobase/include/os0file.h: Add os_file_set_eof() innobase/os/os0file.c: Add os_file_set_eof() innobase/srv/srv0srv.c: Replace chsize() or ftruncate() with os_file_set_eof() sql/ha_innodb.cc: Replace my_chsize() with os_file_set_eof() --- innobase/include/os0file.h | 8 ++++++++ innobase/os/os0file.c | 17 +++++++++++++++++ innobase/srv/srv0srv.c | 6 +----- sql/ha_innodb.cc | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 108cf5520f1..de17e2302ae 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -227,6 +227,14 @@ os_file_set_size( size */ ulint size_high);/* in: most significant 32 bits of size */ /*************************************************************************** +Truncates a file at its current position. */ + +ibool +os_file_set_eof( +/*============*/ + /* out: TRUE if success */ + FILE* file); /* in: file to be truncated */ +/*************************************************************************** Flushes the write buffers of a given file to the disk. */ ibool diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 904ddf13c8f..833703e38dd 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -1031,6 +1031,23 @@ error_handling: return(FALSE); } +/*************************************************************************** +Truncates a file at its current position. */ + +ibool +os_file_set_eof( +/*============*/ + /* out: TRUE if success */ + FILE* file) /* in: file to be truncated */ +{ +#ifdef __WIN__ + HANDLE h = (HANDLE) _get_osfhandle(fileno(file)); + return(SetEndOfFile(h)); +#else /* __WIN__ */ + return(!ftruncate(fileno(file), ftell(file))); +#endif /* __WIN__ */ +} + /*************************************************************************** Flushes the write buffers of a given file to the disk. */ diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 76197fd8fe0..ba1f72d0a58 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -1609,11 +1609,7 @@ loop: mutex_enter(&srv_monitor_file_mutex); rewind(srv_monitor_file); srv_printf_innodb_monitor(srv_monitor_file); -#ifdef __WIN__ - chsize(fileno(srv_monitor_file), ftell(srv_monitor_file)); -#else /* __WIN__ */ - ftruncate(fileno(srv_monitor_file), ftell(srv_monitor_file)); -#endif /* __WIN__ */ + os_file_set_eof(srv_monitor_file); mutex_exit(&srv_monitor_file_mutex); if (srv_print_innodb_tablespace_monitor diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 690e83b2a4b..ac7ccf5c11a 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4648,7 +4648,7 @@ innodb_show_status( rewind(srv_monitor_file); srv_printf_innodb_monitor(srv_monitor_file); flen = ftell(srv_monitor_file); - my_chsize(fileno(srv_monitor_file), flen, 0, MYF(0)); + os_file_set_eof(srv_monitor_file); if(flen > 64000 - 1) { flen = 64000 - 1; } From 601bdde5ed46117cd65c9cf5f660de29623637a3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 May 2004 21:50:51 +0200 Subject: [PATCH 3/4] very minor changes: a STOP SLAVE in a replication test to get rid of a non critical message in slave.err, and a comment update mysql-test/r/rpl_server_id2.result: result update mysql-test/t/rpl_server_id2.test: We stop the slave before cleaning up otherwise we'll get 'drop table t1' executed twice, so an error in the slave.err (not critical). sql/slave.cc: update comment about 4.1 now that 4.1 is fixed (in a few minutes, exactly) --- mysql-test/r/rpl_server_id2.result | 1 + mysql-test/t/rpl_server_id2.test | 4 ++++ sql/slave.cc | 6 +++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/rpl_server_id2.result b/mysql-test/r/rpl_server_id2.result index 5f4ec9df4c4..d665bb25dbb 100644 --- a/mysql-test/r/rpl_server_id2.result +++ b/mysql-test/r/rpl_server_id2.result @@ -18,4 +18,5 @@ select * from t1; n 1 1 +stop slave; drop table t1; diff --git a/mysql-test/t/rpl_server_id2.test b/mysql-test/t/rpl_server_id2.test index f022ab13188..dc8f733b7ed 100644 --- a/mysql-test/t/rpl_server_id2.test +++ b/mysql-test/t/rpl_server_id2.test @@ -18,4 +18,8 @@ insert into t1 values (1); save_master_pos; sync_with_master; select * from t1; # check that indeed 2 were inserted +# We stop the slave before cleaning up otherwise we'll get +# 'drop table t1' executed twice, so an error in the slave.err +# (not critical). +stop slave; drop table t1; diff --git a/sql/slave.cc b/sql/slave.cc index c3cbcbab7b2..d6d0a5b5425 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2366,9 +2366,9 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) */ /* - TODO: when this is merged into 4.1, one needs to update queue_event() to - add a similar test for replicate_same_server_id, because in 4.1 the I/O - thread is also filtering events based on the server id. + In 4.1, we updated queue_event() to add a similar test for + replicate_same_server_id, because in 4.1 the I/O thread is also filtering + events based on the server id. */ if ((ev->server_id == (uint32) ::server_id && !replicate_same_server_id) || (rli->slave_skip_counter && type_code != ROTATE_EVENT)) From 33359d0b66b19e1fef71ead79f8319ef00148181 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 May 2004 11:42:23 +0300 Subject: [PATCH 4/4] Remove not used variable --- sql/sql_acl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 9385c4aa7f5..3b006d5d99f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3035,7 +3035,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) /* Add database access */ for (counter=0 ; counter < acl_dbs.elements ; counter++) { - const char *user,*host; + const char *user, *host; acl_db=dynamic_element(&acl_dbs,counter,ACL_DB*); if (!(user=acl_db->user)) @@ -3096,7 +3096,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) /* Add table & column access */ for (index=0 ; index < hash_tables.records ; index++) { - const char *user,*host; + const char *user; GRANT_TABLE *grant_table= (GRANT_TABLE*) hash_element(&hash_tables,index); if (!(user=grant_table->user))