Below is the list of changes that have just been committed into a local
5.1 repository of lthalmann. When lthalmann does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1985 05/12/08 16:19:25 lars@stripped +5 -0
Merge mysql.com:/users/lthalmann/bkroot/mysql-5.1-wl1012-v3
into mysql.com:/users/lthalmann/bk/mysql-5.1-wl1012-v3-wl2321-max
sql/sql_class.h
1.274 05/12/08 16:19:15 lars@stripped +0 -0
SCCS merged
sql/sql_class.cc
1.226 05/12/08 15:36:49 lars@stripped +0 -0
Auto merged
sql/slave.cc
1.261 05/12/08 15:36:48 lars@stripped +0 -0
Auto merged
sql/log_event.h
1.144 05/12/08 15:36:47 lars@stripped +0 -0
Auto merged
sql/log_event.cc
1.198 05/12/08 15:36:46 lars@stripped +0 -0
Auto merged
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: lars
# Host: dl145h.mysql.com
# Root: /users/lthalmann/bk/mysql-5.1-wl1012-v3-wl2321-max/RESYNC
--- 1.197/sql/log_event.cc 2005-12-08 14:44:26 +01:00
+++ 1.198/sql/log_event.cc 2005-12-08 15:36:46 +01:00
@@ -26,6 +26,7 @@
#include "rpl_filter.h"
#include <my_dir.h>
#endif /* MYSQL_CLIENT */
+#include "base64.h"
#include <my_bitmap.h>
#include <my_vle.h>
@@ -971,6 +972,18 @@
}
+void Log_event::print_base64(FILE* file, PRINT_EVENT_INFO* print_event_info)
+{
+ uchar *ptr= (uchar*)temp_buf;
+ my_off_t size= uint4korr(ptr + EVENT_LEN_OFFSET);
+
+ char *tmp_str= (char *) malloc(base64_needed_encoded_length(size));
+ int res= base64_encode(ptr, size, tmp_str);
+ fprintf(file, "\nBINLOG '\n%s\n';\n", tmp_str);
+ free(tmp_str);
+}
+
+
/*
Log_event::print_timestamp()
*/
@@ -5170,14 +5183,15 @@
DBUG_ENTER("Rows_log_event::exec_event(st_relay_log_info*)");
DBUG_ASSERT(m_table_id != ULONG_MAX);
int error= 0;
- TABLE* table= rli->m_table_map.get_table(m_table_id);
char const *row_start= m_rows_buf;
+ TABLE* table= rli->m_table_map.get_table(m_table_id);
+ DBUG_ASSERT(table);
/*
'thd' has been set by exec_relay_log_event(), just before calling
exec_event(). We still check here to prevent future coding errors.
*/
- DBUG_ASSERT(rli->sql_thd == thd);
+ DBUG_ASSERT(rli->sql_thd == thd || rli->no_storage);
/*
lock_tables() reads the contents of thd->lex, so they must be
@@ -5688,7 +5702,7 @@
{
DBUG_ENTER("Table_map_log_event::exec_event(st_relay_log_info*)");
- DBUG_ASSERT(rli->sql_thd == thd);
+ DBUG_ASSERT(rli->sql_thd == thd || rli->no_storage);
/* Step the query id to mark what columns that are actually used. */
pthread_mutex_lock(&LOCK_thread_count);
@@ -5930,9 +5944,9 @@
if (!print_event_info->short_form)
{
print_header(file, print_event_info);
- fprintf(file, "\tTable_map\t"
- "`%s`.`%s` mapped to number %lu\n",
+ fprintf(file, "\tTable_map: `%s`.`%s` mapped to number %lu\n",
m_dbnam, m_tblnam, m_table_id);
+ print_base64(file, print_event_info);
}
}
#endif
@@ -6206,7 +6220,8 @@
if (!print_event_info->short_form)
{
print_header(file, print_event_info);
- fprintf(file, "\nWrite_rows: table id %lu\n", m_table_id); // TODO: WL#2321
+ fprintf(file, "\tWrite_rows: table id %lu", m_table_id);
+ print_base64(file, print_event_info);
}
}
#endif
@@ -6492,7 +6507,8 @@
if (!print_event_info->short_form)
{
print_header(file, print_event_info);
- fprintf(file, "\nDelete_rows: table id %lu\n", m_table_id); // TODO: WL#2321
+ fprintf(file, "\tDelete_rows: table id %lu", m_table_id);
+ print_base64(file, print_event_info);
}
}
#endif
@@ -6661,7 +6677,8 @@
if (!print_event_info->short_form)
{
print_header(file, print_event_info);
- fprintf(file, "\nUpdate_rows: table id %lu\n", m_table_id); // TODO: WL#2321
+ fprintf(file, "\tUpdate_rows: table id %lu", m_table_id);
+ print_base64(file, print_event_info);
}
}
#endif
--- 1.143/sql/log_event.h 2005-12-08 14:44:26 +01:00
+++ 1.144/sql/log_event.h 2005-12-08 15:36:47 +01:00
@@ -534,6 +534,7 @@
/* Settings on how to print the events */
bool short_form;
+ bool base64_output;
my_off_t hexdump_from;
uint8 common_header_len;
@@ -649,6 +650,7 @@
virtual void print(FILE* file, PRINT_EVENT_INFO* print_event_info) = 0;
void print_timestamp(FILE* file, time_t *ts = 0);
void print_header(FILE* file, PRINT_EVENT_INFO* print_event_info);
+ void print_base64(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
static void *operator new(size_t size)
--- 1.260/sql/slave.cc 2005-12-08 14:44:26 +01:00
+++ 1.261/sql/slave.cc 2005-12-08 15:36:48 +01:00
@@ -18,6 +18,7 @@
#include <mysql.h>
#include <myisam.h>
+#include "rpl_rli.h"
#include "slave.h"
#include "sql_repl.h"
#include "rpl_filter.h"
@@ -1424,6 +1425,7 @@
const char* msg = 0;
int error = 0;
DBUG_ENTER("init_relay_log_info");
+ DBUG_ASSERT(!rli->no_storage); // Don't init if there is no storage
if (rli->inited) // Set if this function called
DBUG_RETURN(0);
@@ -2286,7 +2288,7 @@
st_relay_log_info::st_relay_log_info()
- :info_fd(-1), cur_log_fd(-1), save_temporary_tables(0),
+ :no_storage(FALSE), info_fd(-1), cur_log_fd(-1), save_temporary_tables(0),
cur_log_old_open_count(0), group_master_log_pos(0), log_space_total(0),
ignore_log_space_limit(0), last_master_timestamp(0), slave_skip_counter(0),
abort_pos_wait(0), slave_run_id(0), sql_thd(0), last_slave_errno(0),
@@ -4339,22 +4341,25 @@
bool flush_relay_log_info(RELAY_LOG_INFO* rli)
{
bool error=0;
- IO_CACHE *file = &rli->info_file;
- char buff[FN_REFLEN*2+22*2+4], *pos;
+ if (!rli->no_storage)
+ {
+ IO_CACHE *file = &rli->info_file;
+ char buff[FN_REFLEN*2+22*2+4], *pos;
- my_b_seek(file, 0L);
- pos=strmov(buff, rli->group_relay_log_name);
- *pos++='\n';
- pos=longlong2str(rli->group_relay_log_pos, pos, 10);
- *pos++='\n';
- pos=strmov(pos, rli->group_master_log_name);
- *pos++='\n';
- pos=longlong2str(rli->group_master_log_pos, pos, 10);
- *pos='\n';
- if (my_b_write(file, (byte*) buff, (ulong) (pos-buff)+1))
- error=1;
- if (flush_io_cache(file))
- error=1;
+ my_b_seek(file, 0L);
+ pos=strmov(buff, rli->group_relay_log_name);
+ *pos++='\n';
+ pos=longlong2str(rli->group_relay_log_pos, pos, 10);
+ *pos++='\n';
+ pos=strmov(pos, rli->group_master_log_name);
+ *pos++='\n';
+ pos=longlong2str(rli->group_master_log_pos, pos, 10);
+ *pos='\n';
+ if (my_b_write(file, (byte*) buff, (ulong) (pos-buff)+1))
+ error=1;
+ if (flush_io_cache(file))
+ error=1;
+ }
/* Flushing the relay log is done by the slave I/O thread */
return error;
}
@@ -4369,6 +4374,9 @@
DBUG_ASSERT(rli->cur_log != &rli->cache_buf);
DBUG_ASSERT(rli->cur_log_fd == -1);
DBUG_ENTER("reopen_relay_log");
+
+ if (rli->no_storage)
+ DBUG_RETURN(0);
IO_CACHE *cur_log = rli->cur_log=&rli->cache_buf;
if ((rli->cur_log_fd=open_binlog(cur_log,rli->event_relay_log_name,
--- 1.225/sql/sql_class.cc 2005-12-08 14:44:26 +01:00
+++ 1.226/sql/sql_class.cc 2005-12-08 15:36:49 +01:00
@@ -182,7 +182,7 @@
rand_used(0), time_zone_used(0),
last_insert_id_used(0), insert_id_used(0), clear_next_insert_id(0),
in_lock_tables(0), bootstrap(0), derived_tables_processing(FALSE),
- spcont(NULL)
+ spcont(NULL), should_close_thread_tables(TRUE)
{
stmt_arena= this;
db= 0;
--- 1.273/sql/sql_class.h 2005-12-08 14:44:26 +01:00
+++ 1.274/sql/sql_class.h 2005-12-08 16:19:15 +01:00
@@ -21,14 +21,13 @@
#pragma interface /* gcc class implementation */
#endif
-// TODO: create log.h and move all the log header stuff there
-
+#include "log.h"
+#include "rpl_rli.h"
#include "rpl_tblmap.h"
class Query_log_event;
class Load_log_event;
class Slave_log_event;
-class Format_description_log_event;
class sp_rcontext;
class sp_cache;
class Rows_log_event;
@@ -36,7 +35,6 @@
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE };
-enum enum_log_type { LOG_CLOSED, LOG_TO_BE_OPENED, LOG_NORMAL, LOG_NEW, LOG_BIN};
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
DELAY_KEY_WRITE_ALL };
@@ -53,117 +51,6 @@
#define TC_HEURISTIC_RECOVER_ROLLBACK 2
extern uint tc_heuristic_recover;
-/*
- Transaction Coordinator log - a base abstract class
- for two different implementations
-*/
-class TC_LOG
-{
- public:
- int using_heuristic_recover();
- TC_LOG() {}
- virtual ~TC_LOG() {}
-
- virtual int open(const char *opt_name)=0;
- virtual void close()=0;
- virtual int log(THD *thd, my_xid xid)=0;
- virtual void unlog(ulong cookie, my_xid xid)=0;
-};
-
-class TC_LOG_DUMMY: public TC_LOG // use it to disable the logging
-{
- public:
- int open(const char *opt_name) { return 0; }
- void close() { }
- int log(THD *thd, my_xid xid) { return 1; }
- void unlog(ulong cookie, my_xid xid) { }
-};
-
-#ifdef HAVE_MMAP
-class TC_LOG_MMAP: public TC_LOG
-{
- public: // only to keep Sun Forte on sol9x86 happy
- typedef enum {
- POOL, // page is in pool
- ERROR, // last sync failed
- DIRTY // new xids added since last sync
- } PAGE_STATE;
-
- private:
- typedef struct st_page {
- struct st_page *next; // page a linked in a fifo queue
- my_xid *start, *end; // usable area of a page
- my_xid *ptr; // next xid will be written here
- int size, free; // max and current number of free xid slots on the page
- int waiters; // number of waiters on condition
- PAGE_STATE state; // see above
- pthread_mutex_t lock; // to access page data or control structure
- pthread_cond_t cond; // to wait for a sync
- } PAGE;
-
- char logname[FN_REFLEN];
- File fd;
- my_off_t file_length;
- uint npages, inited;
- uchar *data;
- struct st_page *pages, *syncing, *active, *pool, *pool_last;
- /*
- note that, e.g. LOCK_active is only used to protect
- 'active' pointer, to protect the content of the active page
- one has to use active->lock.
- Same for LOCK_pool and LOCK_sync
- */
- pthread_mutex_t LOCK_active, LOCK_pool, LOCK_sync;
- pthread_cond_t COND_pool, COND_active;
-
- public:
- TC_LOG_MMAP(): inited(0) {}
- int open(const char *opt_name);
- void close();
- int log(THD *thd, my_xid xid);
- void unlog(ulong cookie, my_xid xid);
- int recover();
-
- private:
- void get_active_from_pool();
- int sync();
- int overflow();
-};
-#else
-#define TC_LOG_MMAP TC_LOG_DUMMY
-#endif
-
-extern TC_LOG *tc_log;
-extern TC_LOG_MMAP tc_log_mmap;
-extern TC_LOG_DUMMY tc_log_dummy;
-
-/* log info errors */
-#define LOG_INFO_EOF -1
-#define LOG_INFO_IO -2
-#define LOG_INFO_INVALID -3
-#define LOG_INFO_SEEK -4
-#define LOG_INFO_MEM -6
-#define LOG_INFO_FATAL -7
-#define LOG_INFO_IN_USE -8
-
-/* bitmap to SQL_LOG::close() */
-#define LOG_CLOSE_INDEX 1
-#define LOG_CLOSE_TO_BE_OPENED 2
-#define LOG_CLOSE_STOP_EVENT 4
-
-struct st_relay_log_info;
-
-typedef struct st_log_info
-{
- char log_file_name[FN_REFLEN];
- my_off_t index_file_offset, index_file_start_offset;
- my_off_t pos;
- bool fatal; // if the purge happens to give us a negative offset
- pthread_mutex_t lock;
- st_log_info():fatal(0) { pthread_mutex_init(&lock, MY_MUTEX_INIT_FAST);}
- ~st_log_info() { pthread_mutex_destroy(&lock);}
-} LOG_INFO;
-
typedef struct st_user_var_events
{
user_var_entry *user_var_event;
@@ -176,201 +63,6 @@
#define RP_LOCK_LOG_IS_ALREADY_LOCKED 1
#define RP_FORCE_ROTATE 2
-class Log_event;
-
-/*
- TODO split MYSQL_LOG into base MYSQL_LOG and
- MYSQL_QUERY_LOG, MYSQL_SLOW_LOG, MYSQL_BIN_LOG
- most of the code from MYSQL_LOG should be in the MYSQL_BIN_LOG
- only (TC_LOG included)
-
- TODO use mmap instead of IO_CACHE for binlog
- (mmap+fsync is two times faster than write+fsync)
-*/
-
-class MYSQL_LOG: public TC_LOG
-{
- private:
- /* LOCK_log and LOCK_index are inited by init_pthread_objects() */
- pthread_mutex_t LOCK_log, LOCK_index;
- pthread_mutex_t LOCK_prep_xids;
- pthread_cond_t COND_prep_xids;
- pthread_cond_t update_cond;
- ulonglong bytes_written;
- time_t last_time,query_start;
- IO_CACHE log_file;
- IO_CACHE index_file;
- char *name;
- char time_buff[20],db[NAME_LEN+1];
- char log_file_name[FN_REFLEN],index_file_name[FN_REFLEN];
- /*
- The max size before rotation (usable only if log_type == LOG_BIN: binary
- logs and relay logs).
- For a binlog, max_size should be max_binlog_size.
- For a relay log, it should be max_relay_log_size if this is non-zero,
- max_binlog_size otherwise.
- max_size is set in init(), and dynamically changed (when one does SET
- GLOBAL MAX_BINLOG_SIZE|MAX_RELAY_LOG_SIZE) by fix_max_binlog_size and
- fix_max_relay_log_size).
- */
- ulong max_size;
- ulong prepared_xids; /* for tc log - number of xids to remember */
- volatile enum_log_type log_type;
- enum cache_type io_cache_type;
- // current file sequence number for load data infile binary logging
- uint file_id;
- uint open_count; // For replication
- int readers_count;
- bool reset_pending;
- bool write_error, inited;
- bool need_start_event;
- /*
- no_auto_events means we don't want any of these automatic events :
- Start/Rotate/Stop. That is, in 4.x when we rotate a relay log, we don't
- want a Rotate_log event to be written to the relay log. When we start a
- relay log etc. So in 4.x this is 1 for relay logs, 0 for binlogs.
- In 5.0 it's 0 for relay logs too!
- */
- bool no_auto_events;
- friend class Log_event;
-
-public:
- ulonglong m_table_map_version;
-
- /*
- These describe the log's format. This is used only for relay logs.
- _for_exec is used by the SQL thread, _for_queue by the I/O thread. It's
- necessary to have 2 distinct objects, because the I/O thread may be reading
- events in a different format from what the SQL thread is reading (consider
- the case of a master which has been upgraded from 5.0 to 5.1 without doing
- RESET MASTER, or from 4.x to 5.0).
- */
- Format_description_log_event *description_event_for_exec,
- *description_event_for_queue;
-
- MYSQL_LOG();
- /*
- note that there's no destructor ~MYSQL_LOG() !
- The reason is that we don't want it to be automatically called
- on exit() - but only during the correct shutdown process
- */
-
- int open(const char *opt_name);
- void close();
- int log(THD *thd, my_xid xid);
- void unlog(ulong cookie, my_xid xid);
- int recover(IO_CACHE *log, Format_description_log_event *fdle);
-
-#if !defined(MYSQL_CLIENT)
- bool is_table_mapped(TABLE *table) const
- {
- return table->s->table_map_version == m_table_map_version;
- }
-
-#endif /* !defined(MYSQL_CLIENT) */
- void reset_bytes_written()
- {
- bytes_written = 0;
- }
- void harvest_bytes_written(ulonglong* counter)
- {
-#ifndef DBUG_OFF
- char buf1[22],buf2[22];
-#endif
- DBUG_ENTER("harvest_bytes_written");
- (*counter)+=bytes_written;
- DBUG_PRINT("info",("counter: %s bytes_written: %s", llstr(*counter,buf1),
- llstr(bytes_written,buf2)));
- bytes_written=0;
- DBUG_VOID_RETURN;
- }
- void set_max_size(ulong max_size_arg);
- void signal_update();
- void wait_for_update(THD* thd, bool master_or_slave);
- void set_need_start_event() { need_start_event = 1; }
- void init(enum_log_type log_type_arg,
- enum cache_type io_cache_type_arg,
- bool no_auto_events_arg, ulong max_size);
- void init_pthread_objects();
- void cleanup();
- bool open(const char *log_name,
- enum_log_type log_type,
- const char *new_name,
- enum cache_type io_cache_type_arg,
- bool no_auto_events_arg, ulong max_size,
- bool null_created);
- const char *generate_name(const char *log_name, const char *suffix,
- bool strip_ext, char *buff);
- /* simplified open_xxx wrappers for the gigantic open above */
- bool open_query_log(const char *log_name)
- {
- char buf[FN_REFLEN];
- return open(generate_name(log_name, ".log", 0, buf),
- LOG_NORMAL, 0, WRITE_CACHE, 0, 0, 0);
- }
- bool open_slow_log(const char *log_name)
- {
- char buf[FN_REFLEN];
- return open(generate_name(log_name, "-slow.log", 0, buf),
- LOG_NORMAL, 0, WRITE_CACHE, 0, 0, 0);
- }
- bool open_index_file(const char *index_file_name_arg,
- const char *log_name);
- void new_file(bool need_lock);
- bool write(THD *thd, enum enum_server_command command,
- const char *format,...);
- bool write(THD *thd, const char *query, uint query_length,
- time_t query_start=0);
- bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
-
- bool write_table_map(THD *thd, IO_CACHE *cache, TABLE *table, bool is_trans);
-
- void start_union_events(THD *thd);
- void stop_union_events(THD *thd);
- bool is_query_in_union(THD *thd, query_id_t query_id_param);
-
- /*
- v stands for vector
- invoked as appendv(buf1,len1,buf2,len2,...,bufn,lenn,0)
- */
- bool appendv(const char* buf,uint len,...);
- bool append(Log_event* ev);
-
- int generate_new_name(char *new_name,const char *old_name);
- void make_log_name(char* buf, const char* log_ident);
- bool is_active(const char* log_file_name);
- int update_log_index(LOG_INFO* linfo, bool need_update_threads);
- void rotate_and_purge(uint flags);
- bool flush_and_sync();
- int purge_logs(const char *to_log, bool included,
- bool need_mutex, bool need_update_threads,
- ulonglong *decrease_log_space);
- int purge_logs_before_date(time_t purge_time);
- int purge_first_log(struct st_relay_log_info* rli, bool included);
- bool reset_logs(THD* thd);
- void close(uint exiting);
-
- // iterating through the log index file
- int find_log_pos(LOG_INFO* linfo, const char* log_name,
- bool need_mutex);
- int find_next_log(LOG_INFO* linfo, bool need_mutex);
- int get_current_log(LOG_INFO* linfo);
- uint next_file_id();
- inline bool is_open() { return log_type != LOG_CLOSED; }
- inline char* get_index_fname() { return index_file_name;}
- inline char* get_log_fname() { return log_file_name; }
- inline char* get_name() { return name; }
- inline pthread_mutex_t* get_log_lock() { return &LOCK_log; }
- inline IO_CACHE* get_log_file() { return &log_file; }
-
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
- inline IO_CACHE *get_index_file() { return &index_file;}
- inline uint32 get_open_count() { return open_count; }
-};
-
-
typedef struct st_copy_info {
ha_rows records;
ha_rows deleted;
@@ -477,28 +169,6 @@
#include "sql_lex.h" /* Must be here */
-/* Needed to be able to have an I_List of char* strings in mysqld.cc. */
-
-class i_string: public ilink
-{
-public:
- const char* ptr;
- i_string():ptr(0) { }
- i_string(const char* s) : ptr(s) {}
-};
-
-/* needed for linked list of two strings for replicate-rewrite-db */
-class i_string_pair: public ilink
-{
-public:
- const char* key;
- const char* val;
- i_string_pair():key(0),val(0) { }
- i_string_pair(const char* key_arg, const char* val_arg) :
- key(key_arg),val(val_arg) {}
-};
-
-
class delayed_insert;
class select_result;
@@ -1128,6 +798,12 @@
public Open_tables_state
{
public:
+
+#ifndef EMBEDDED_LIBRARY
+ RELAY_LOG_INFO rli_fake;
+#endif
+
+ bool should_close_thread_tables;
/*
Constant for THD::where initialization in the beginning of every query.
| Thread |
|---|
| • bk commit into 5.1 tree (lars:1.1985) | Lars Thalmann | 8 Dec |