diff options
author | unknown <nick@mysql.com> | 2002-10-22 15:17:17 -0600 |
---|---|---|
committer | unknown <nick@mysql.com> | 2002-10-22 15:17:17 -0600 |
commit | d326428c41429ea501d4b9098ab3d6084733bb32 (patch) | |
tree | 599b4e1aaa80541b807a59a9d9a5538337e4d2f3 /sql/log_event.cc | |
parent | d2e52820f6b8f4d345af2a5e5c6a5fa792171757 (diff) | |
download | mariadb-git-d326428c41429ea501d4b9098ab3d6084733bb32.tar.gz |
Added Rand_log_event
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r-- | sql/log_event.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc index 060a9a3b73f..871f72acbae 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -348,6 +348,18 @@ void Intvar_log_event::pack_info(String* packet) net_store_data(packet, tmp.ptr(), tmp.length()); } +void Rand_log_event::pack_info(String* packet) +{ + char buf1[256], buf[22]; + String tmp(buf1, sizeof(buf1)); + tmp.length(0); + tmp.append("randseed1="); + tmp.append(llstr(seed1, buf)); + tmp.append(",randseed2="); + tmp.append(llstr(seed2, buf)); + net_store_data(packet, tmp.ptr(), tmp.length()); +} + void Slave_log_event::pack_info(String* packet) { char buf1[256], buf[22], *end; @@ -376,6 +388,9 @@ void Log_event::init_show_field_list(List<Item>* field_list) field_list->push_back(new Item_empty_string("Info", 20)); } +/* + * only called by SHOW BINLOG EVENTS + */ int Log_event::net_send(THD* thd, const char* log_name, my_off_t pos) { String* packet = &thd->packet; @@ -610,6 +625,9 @@ Log_event* Log_event::read_log_event(const char* buf, int event_len, case INTVAR_EVENT: ev = new Intvar_log_event(buf, old_format); break; + case RAND_EVENT: + ev = new Rand_log_event(buf, old_format); + break; default: break; } @@ -915,6 +933,41 @@ void Intvar_log_event::print(FILE* file, bool short_form, char* last_db) } #endif +/***************************************************************************** + * + * Rand log event + * + ****************************************************************************/ +Rand_log_event::Rand_log_event(const char* buf, bool old_format) + :Log_event(buf, old_format) +{ + buf += (old_format) ? OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN; + seed1 = uint8korr(buf+RAND_SEED1_OFFSET); + seed2 = uint8korr(buf+RAND_SEED2_OFFSET); +} + +int Rand_log_event::write_data(IO_CACHE* file) +{ + char buf[16]; + int8store(buf + RAND_SEED1_OFFSET, seed1); + int8store(buf + RAND_SEED2_OFFSET, seed2); + return my_b_safe_write(file, (byte*) buf, sizeof(buf)); +} + +#ifdef MYSQL_CLIENT +void Rand_log_event::print(FILE* file, bool short_form, char* last_db) +{ + char llbuff[22]; + if (!short_form) + { + print_header(file); + fprintf(file, "\tRand\n"); + } + fprintf(file, "SET RAND SEED1=%s;\n", llstr(seed1, llbuff)); + fprintf(file, "SET RAND SEED2=%s;\n", llstr(seed2, llbuff)); + fflush(file); +} +#endif int Load_log_event::write_data_header(IO_CACHE* file) { @@ -1910,6 +1963,14 @@ int Intvar_log_event::exec_event(struct st_relay_log_info* rli) return 0; } +int Rand_log_event::exec_event(struct st_relay_log_info* rli) +{ + thd->rand.seed1 = seed1; + thd->rand.seed2 = seed2; + rli->inc_pending(get_event_len()); + return 0; +} + int Slave_log_event::exec_event(struct st_relay_log_info* rli) { if (mysql_bin_log.is_open()) |