Loading sql/handler.cc +24 −2 Original line number Diff line number Diff line Loading @@ -1499,16 +1499,38 @@ uint handler::get_dup_key(int error) } /* Delete all files with extension from bas_ext() SYNOPSIS delete_table() name Base name of table NOTES We assume that the handler may return more extensions than was actually used for the file. RETURN 0 If we successfully deleted at least one file from base_ext and didn't get any other errors than ENOENT # Error from delete_file() */ int handler::delete_table(const char *name) { int error= 0; int enoent_or_zero= ENOENT; // Error if no file was deleted for (const char **ext=bas_ext(); *ext ; ext++) { if (delete_file(name,*ext,2)) { if ((error=errno) != ENOENT) if ((error= my_errno) != ENOENT) break; } else enoent_or_zero= 0; error= enoent_or_zero; } return error; } Loading sql/handler.h +8 −4 Original line number Diff line number Diff line Loading @@ -217,11 +217,13 @@ struct xid_t { bool eq(long g, long b, const char *d) { return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); } void set(LEX_STRING *l) { set(l->length, 0, l->str); } void set(ulonglong l) void set(ulonglong xid) { my_xid tmp; set(MYSQL_XID_PREFIX_LEN, 0, MYSQL_XID_PREFIX); *(ulong*)(data+MYSQL_XID_PREFIX_LEN)=server_id; *(my_xid*)(data+MYSQL_XID_OFFSET)=l; memcpy(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id)); tmp= xid; memcpy(data+MYSQL_XID_OFFSET, &tmp, sizeof(tmp)); gtrid_length=MYSQL_XID_GTRID_LEN; } void set(long g, long b, const char *d) Loading @@ -235,7 +237,9 @@ struct xid_t { void null() { formatID= -1; } my_xid quick_get_my_xid() { return *(my_xid*)(data+MYSQL_XID_OFFSET); my_xid tmp; memcpy(&tmp, data+MYSQL_XID_OFFSET, sizeof(tmp)); return tmp; } my_xid get_my_xid() { Loading sql/log.cc +41 −31 Original line number Diff line number Diff line Loading @@ -920,6 +920,13 @@ bool MYSQL_LOG::reset_logs(THD* thd) */ pthread_mutex_lock(&LOCK_log); pthread_mutex_lock(&LOCK_index); /* The following mutex is needed to ensure that no threads call 'delete thd' as we would then risk missing a 'rollback' from this thread. If the transaction involved MyISAM tables, it should go into binlog even on rollback. */ (void) pthread_mutex_lock(&LOCK_thread_count); /* Save variables so that we can reopen the log */ save_name=name; Loading Loading @@ -953,6 +960,7 @@ bool MYSQL_LOG::reset_logs(THD* thd) my_free((gptr) save_name, MYF(0)); err: (void) pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_index); pthread_mutex_unlock(&LOCK_log); DBUG_RETURN(error); Loading Loading @@ -1601,7 +1609,8 @@ bool MYSQL_LOG::write(Log_event* event_info) { thd->ha_data[binlog_hton.slot]= trans_log= (IO_CACHE *) my_malloc(sizeof(IO_CACHE), MYF(MY_ZEROFILL)); if (!trans_log || open_cached_file(trans_log, mysql_tmpdir, LOG_PREFIX, if (!trans_log || open_cached_file(trans_log, mysql_tmpdir, LOG_PREFIX, binlog_cache_size, MYF(MY_WME))) { my_free((gptr)trans_log, MYF(MY_ALLOW_ZERO_PTR)); Loading @@ -1610,12 +1619,14 @@ bool MYSQL_LOG::write(Log_event* event_info) } trans_log->end_of_file= max_binlog_cache_size; trans_register_ha(thd, thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), &binlog_hton); } else if (!my_b_tell(trans_log)) trans_register_ha(thd, thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), &binlog_hton); file= trans_log; } Loading Loading @@ -1804,9 +1815,9 @@ uint MYSQL_LOG::next_file_id() IMPLEMENTATION - To support transaction over replication, we wrap the transaction with BEGIN/COMMIT or BEGIN/ROLLBACK in the binary log. We want to write a BEGIN/ROLLBACK block when a non-transactional table was updated in a transaction which was rolled back. This is to ensure that the same updates are run on the slave. We want to write a BEGIN/ROLLBACK block when a non-transactional table was updated in a transaction which was rolled back. This is to ensure that the same updates are run on the slave. */ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache) Loading Loading @@ -2475,15 +2486,13 @@ int TC_LOG_MMAP::open(const char *opt_name) DBUG_ASSERT(TC_LOG_PAGE_SIZE % tc_log_page_size == 0); fn_format(logname,opt_name,mysql_data_home,"",MY_UNPACK_FILENAME); fd= my_open(logname, O_RDWR, MYF(0)); if (fd == -1) if ((fd= my_open(logname, O_RDWR, MYF(0))) < 0) { if (my_errno != ENOENT) goto err; if (using_heuristic_recover()) return 1; fd= my_create(logname, O_RDWR, 0, MYF(MY_WME)); if (fd == -1) if ((fd= my_create(logname, O_RDWR, 0, MYF(MY_WME))) < 0) goto err; inited=1; file_length= opt_tc_log_size; Loading Loading @@ -2821,7 +2830,7 @@ int TC_LOG_MMAP::recover() */ if (data[sizeof(tc_log_magic)] != total_ha_2pc) { sql_print_error("Recovery failed! You must have enabled " sql_print_error("Recovery failed! You must enable " "exactly %d storage engines that support " "two-phase commit protocol", data[sizeof(tc_log_magic)]); Loading Loading @@ -2930,15 +2939,16 @@ int TC_LOG_BINLOG::open(const char *opt_name) if (! fdle.is_valid()) goto err; for (error= 0; !error ;) do { strnmov(log_name, log_info.log_file_name, sizeof(log_name)); if ((error= find_next_log(&log_info, 1)) != LOG_INFO_EOF) strmake(log_name, log_info.log_file_name, sizeof(log_name)-1); } while (!(error= find_next_log(&log_info, 1))); if (error != LOG_INFO_EOF) { sql_print_error("find_log_pos() failed (error: %d)", error); goto err; } } if ((file= open_binlog(&log, log_name, &errmsg)) < 0) { Loading sql/log_event.cc +5 −3 Original line number Diff line number Diff line Loading @@ -3099,12 +3099,14 @@ void Xid_log_event::pack_info(Protocol *protocol) we don't care about actual values of xids as long as identical numbers compare identically */ Xid_log_event::Xid_log_event(const char* buf, Xid_log_event:: Xid_log_event(const char* buf, const Format_description_log_event *description_event) :Log_event(buf, description_event) { buf+= description_event->common_header_len; xid=*((my_xid *)buf); memcpy((char*) &xid, buf, sizeof(xid)); } Loading sql/sql_acl.cc +7 −13 Original line number Diff line number Diff line Loading @@ -204,20 +204,16 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) if (lower_case_table_names) { /* We make a temporary copy of the database, force it to lower case, and then copy it back over the original name. We can't just update the host.db pointer, because tmp_name is allocated on the stack. convert db to lower case and give a warning if the db wasn't already in lower case */ (void) strmov(tmp_name, host.db); my_casedn_str(files_charset_info, tmp_name); my_casedn_str(files_charset_info, host.db); if (strcmp(host.db, tmp_name) != 0) { sql_print_warning("'host' entry '%s|%s' had database in mixed " "case that has been forced to lowercase because " "lower_case_table_names is set.", host.host.hostname, host.db); (void)strmov(host.db, tmp_name); } } host.access= get_access(table,2); host.access= fix_rights_for_db(host.access); Loading Loading @@ -432,19 +428,17 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) if (lower_case_table_names) { /* We make a temporary copy of the database, force it to lower case, and then copy it back over the original name. We can't just update the db.db pointer, because tmp_name is allocated on the stack. convert db to lower case and give a warning if the db wasn't already in lower case */ (void)strmov(tmp_name, db.db); my_casedn_str(files_charset_info, tmp_name); my_casedn_str(files_charset_info, db.db); if (strcmp(db.db, tmp_name) != 0) { sql_print_warning("'db' entry '%s %s@%s' had database in mixed " "case that has been forced to lowercase because " "lower_case_table_names is set.", db.db, db.user, db.host.hostname, db.host.hostname); (void)strmov(db.db, tmp_name); } } db.sort=get_sort(3,db.host.hostname,db.db,db.user); Loading Loading
sql/handler.cc +24 −2 Original line number Diff line number Diff line Loading @@ -1499,16 +1499,38 @@ uint handler::get_dup_key(int error) } /* Delete all files with extension from bas_ext() SYNOPSIS delete_table() name Base name of table NOTES We assume that the handler may return more extensions than was actually used for the file. RETURN 0 If we successfully deleted at least one file from base_ext and didn't get any other errors than ENOENT # Error from delete_file() */ int handler::delete_table(const char *name) { int error= 0; int enoent_or_zero= ENOENT; // Error if no file was deleted for (const char **ext=bas_ext(); *ext ; ext++) { if (delete_file(name,*ext,2)) { if ((error=errno) != ENOENT) if ((error= my_errno) != ENOENT) break; } else enoent_or_zero= 0; error= enoent_or_zero; } return error; } Loading
sql/handler.h +8 −4 Original line number Diff line number Diff line Loading @@ -217,11 +217,13 @@ struct xid_t { bool eq(long g, long b, const char *d) { return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); } void set(LEX_STRING *l) { set(l->length, 0, l->str); } void set(ulonglong l) void set(ulonglong xid) { my_xid tmp; set(MYSQL_XID_PREFIX_LEN, 0, MYSQL_XID_PREFIX); *(ulong*)(data+MYSQL_XID_PREFIX_LEN)=server_id; *(my_xid*)(data+MYSQL_XID_OFFSET)=l; memcpy(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id)); tmp= xid; memcpy(data+MYSQL_XID_OFFSET, &tmp, sizeof(tmp)); gtrid_length=MYSQL_XID_GTRID_LEN; } void set(long g, long b, const char *d) Loading @@ -235,7 +237,9 @@ struct xid_t { void null() { formatID= -1; } my_xid quick_get_my_xid() { return *(my_xid*)(data+MYSQL_XID_OFFSET); my_xid tmp; memcpy(&tmp, data+MYSQL_XID_OFFSET, sizeof(tmp)); return tmp; } my_xid get_my_xid() { Loading
sql/log.cc +41 −31 Original line number Diff line number Diff line Loading @@ -920,6 +920,13 @@ bool MYSQL_LOG::reset_logs(THD* thd) */ pthread_mutex_lock(&LOCK_log); pthread_mutex_lock(&LOCK_index); /* The following mutex is needed to ensure that no threads call 'delete thd' as we would then risk missing a 'rollback' from this thread. If the transaction involved MyISAM tables, it should go into binlog even on rollback. */ (void) pthread_mutex_lock(&LOCK_thread_count); /* Save variables so that we can reopen the log */ save_name=name; Loading Loading @@ -953,6 +960,7 @@ bool MYSQL_LOG::reset_logs(THD* thd) my_free((gptr) save_name, MYF(0)); err: (void) pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_index); pthread_mutex_unlock(&LOCK_log); DBUG_RETURN(error); Loading Loading @@ -1601,7 +1609,8 @@ bool MYSQL_LOG::write(Log_event* event_info) { thd->ha_data[binlog_hton.slot]= trans_log= (IO_CACHE *) my_malloc(sizeof(IO_CACHE), MYF(MY_ZEROFILL)); if (!trans_log || open_cached_file(trans_log, mysql_tmpdir, LOG_PREFIX, if (!trans_log || open_cached_file(trans_log, mysql_tmpdir, LOG_PREFIX, binlog_cache_size, MYF(MY_WME))) { my_free((gptr)trans_log, MYF(MY_ALLOW_ZERO_PTR)); Loading @@ -1610,12 +1619,14 @@ bool MYSQL_LOG::write(Log_event* event_info) } trans_log->end_of_file= max_binlog_cache_size; trans_register_ha(thd, thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), &binlog_hton); } else if (!my_b_tell(trans_log)) trans_register_ha(thd, thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), &binlog_hton); file= trans_log; } Loading Loading @@ -1804,9 +1815,9 @@ uint MYSQL_LOG::next_file_id() IMPLEMENTATION - To support transaction over replication, we wrap the transaction with BEGIN/COMMIT or BEGIN/ROLLBACK in the binary log. We want to write a BEGIN/ROLLBACK block when a non-transactional table was updated in a transaction which was rolled back. This is to ensure that the same updates are run on the slave. We want to write a BEGIN/ROLLBACK block when a non-transactional table was updated in a transaction which was rolled back. This is to ensure that the same updates are run on the slave. */ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache) Loading Loading @@ -2475,15 +2486,13 @@ int TC_LOG_MMAP::open(const char *opt_name) DBUG_ASSERT(TC_LOG_PAGE_SIZE % tc_log_page_size == 0); fn_format(logname,opt_name,mysql_data_home,"",MY_UNPACK_FILENAME); fd= my_open(logname, O_RDWR, MYF(0)); if (fd == -1) if ((fd= my_open(logname, O_RDWR, MYF(0))) < 0) { if (my_errno != ENOENT) goto err; if (using_heuristic_recover()) return 1; fd= my_create(logname, O_RDWR, 0, MYF(MY_WME)); if (fd == -1) if ((fd= my_create(logname, O_RDWR, 0, MYF(MY_WME))) < 0) goto err; inited=1; file_length= opt_tc_log_size; Loading Loading @@ -2821,7 +2830,7 @@ int TC_LOG_MMAP::recover() */ if (data[sizeof(tc_log_magic)] != total_ha_2pc) { sql_print_error("Recovery failed! You must have enabled " sql_print_error("Recovery failed! You must enable " "exactly %d storage engines that support " "two-phase commit protocol", data[sizeof(tc_log_magic)]); Loading Loading @@ -2930,15 +2939,16 @@ int TC_LOG_BINLOG::open(const char *opt_name) if (! fdle.is_valid()) goto err; for (error= 0; !error ;) do { strnmov(log_name, log_info.log_file_name, sizeof(log_name)); if ((error= find_next_log(&log_info, 1)) != LOG_INFO_EOF) strmake(log_name, log_info.log_file_name, sizeof(log_name)-1); } while (!(error= find_next_log(&log_info, 1))); if (error != LOG_INFO_EOF) { sql_print_error("find_log_pos() failed (error: %d)", error); goto err; } } if ((file= open_binlog(&log, log_name, &errmsg)) < 0) { Loading
sql/log_event.cc +5 −3 Original line number Diff line number Diff line Loading @@ -3099,12 +3099,14 @@ void Xid_log_event::pack_info(Protocol *protocol) we don't care about actual values of xids as long as identical numbers compare identically */ Xid_log_event::Xid_log_event(const char* buf, Xid_log_event:: Xid_log_event(const char* buf, const Format_description_log_event *description_event) :Log_event(buf, description_event) { buf+= description_event->common_header_len; xid=*((my_xid *)buf); memcpy((char*) &xid, buf, sizeof(xid)); } Loading
sql/sql_acl.cc +7 −13 Original line number Diff line number Diff line Loading @@ -204,20 +204,16 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) if (lower_case_table_names) { /* We make a temporary copy of the database, force it to lower case, and then copy it back over the original name. We can't just update the host.db pointer, because tmp_name is allocated on the stack. convert db to lower case and give a warning if the db wasn't already in lower case */ (void) strmov(tmp_name, host.db); my_casedn_str(files_charset_info, tmp_name); my_casedn_str(files_charset_info, host.db); if (strcmp(host.db, tmp_name) != 0) { sql_print_warning("'host' entry '%s|%s' had database in mixed " "case that has been forced to lowercase because " "lower_case_table_names is set.", host.host.hostname, host.db); (void)strmov(host.db, tmp_name); } } host.access= get_access(table,2); host.access= fix_rights_for_db(host.access); Loading Loading @@ -432,19 +428,17 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) if (lower_case_table_names) { /* We make a temporary copy of the database, force it to lower case, and then copy it back over the original name. We can't just update the db.db pointer, because tmp_name is allocated on the stack. convert db to lower case and give a warning if the db wasn't already in lower case */ (void)strmov(tmp_name, db.db); my_casedn_str(files_charset_info, tmp_name); my_casedn_str(files_charset_info, db.db); if (strcmp(db.db, tmp_name) != 0) { sql_print_warning("'db' entry '%s %s@%s' had database in mixed " "case that has been forced to lowercase because " "lower_case_table_names is set.", db.db, db.user, db.host.hostname, db.host.hostname); (void)strmov(db.db, tmp_name); } } db.sort=get_sort(3,db.host.hostname,db.db,db.user); Loading