Commit ee49ffd5 authored by unknown's avatar unknown

Merge sgluhov@work.mysql.com:/home/bk/mysql-4.1

into gluh.mysql.r18.ru:/home/gluh/mysql-4.1.upd


sql/log_event.cc:
  Auto merged
parents ee0f0a81 b66cf851
...@@ -17,6 +17,7 @@ bell@sanja.is.com.ua ...@@ -17,6 +17,7 @@ bell@sanja.is.com.ua
bk@admin.bk bk@admin.bk
davida@isil.mysql.com davida@isil.mysql.com
gluh@gluh.(none) gluh@gluh.(none)
gluh@gluh.mysql.r18.ru
heikki@donna.mysql.fi heikki@donna.mysql.fi
heikki@hundin.mysql.fi heikki@hundin.mysql.fi
heikki@rescue. heikki@rescue.
......
...@@ -22,7 +22,7 @@ f ...@@ -22,7 +22,7 @@ f
7 7
show binlog events; show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 4 Start 1 4 Server ver: 4.1.0-alpha-debug-log, Binlog ver: 3 master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
master-bin.000001 79 Query 1 79 use `test`; create table t1(f int) master-bin.000001 79 Query 1 79 use `test`; create table t1(f int)
master-bin.000001 136 Query 1 136 use `test`; create table t2(f int) master-bin.000001 136 Query 1 136 use `test`; create table t2(f int)
master-bin.000001 193 Query 1 193 use `test`; insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10) master-bin.000001 193 Query 1 193 use `test`; insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)
......
...@@ -3,6 +3,8 @@ source include/master-slave.inc; ...@@ -3,6 +3,8 @@ source include/master-slave.inc;
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
connect (con2,localhost,root,,); connect (con2,localhost,root,,);
let $VERSION=`select version()`;
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2;
--enable_warnings --enable_warnings
...@@ -38,6 +40,7 @@ drop temporary table t3; ...@@ -38,6 +40,7 @@ drop temporary table t3;
select * from t2; select * from t2;
--replace_result $VERSION VERSION
show binlog events; show binlog events;
drop table t1, t2; drop table t1, t2;
......
...@@ -95,27 +95,29 @@ inline int ignored_error_code(int err_code) ...@@ -95,27 +95,29 @@ inline int ignored_error_code(int err_code)
****************************************************************************/ ****************************************************************************/
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
static void pretty_print_str(String* packet, char* str, int len) static char* pretty_print_str(char* packet, char* str, int len)
{ {
char* end = str + len; char* end = str + len;
packet->append('\''); char* pos= packet;
*pos++= '\'';
while (str < end) while (str < end)
{ {
char c; char c;
switch ((c=*str++)) { switch ((c=*str++)) {
case '\n': packet->append( "\\n"); break; case '\n': pos= strmov(pos, "\\n"); break;
case '\r': packet->append( "\\r"); break; case '\r': pos= strmov(pos, "\\r"); break;
case '\\': packet->append( "\\\\"); break; case '\\': pos= strmov(pos, "\\\\"); break;
case '\b': packet->append( "\\b"); break; case '\b': pos= strmov(pos, "\\b"); break;
case '\t': packet->append( "\\t"); break; case '\t': pos= strmov(pos, "\\t"); break;
case '\'': packet->append( "\\'"); break; case '\'': pos= strmov(pos, "\\'"); break;
case 0 : packet->append( "\\0"); break; case 0 : pos= strmov(pos, "\\0"); break;
default: default:
packet->append((char)c); *pos++= (char)c;
break; break;
} }
} }
packet->append('\''); *pos++= '\'';
return pos;
} }
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
...@@ -570,7 +572,7 @@ Log_event* Log_event::read_log_event(const char* buf, int event_len, ...@@ -570,7 +572,7 @@ Log_event* Log_event::read_log_event(const char* buf, int event_len,
ev = new Query_log_event(buf, event_len, old_format); ev = new Query_log_event(buf, event_len, old_format);
break; break;
case LOAD_EVENT: case LOAD_EVENT:
ev = new Create_file_log_event(buf, event_len, old_format); ev = new Load_log_event(buf, event_len, old_format);
break; break;
case NEW_LOAD_EVENT: case NEW_LOAD_EVENT:
ev = new Load_log_event(buf, event_len, old_format); ev = new Load_log_event(buf, event_len, old_format);
...@@ -693,19 +695,24 @@ void Log_event::set_log_pos(MYSQL_LOG* log) ...@@ -693,19 +695,24 @@ void Log_event::set_log_pos(MYSQL_LOG* log)
****************************************************************************/ ****************************************************************************/
void Query_log_event::pack_info(Protocol *protocol) void Query_log_event::pack_info(Protocol *protocol)
{ {
char buf[256]; char *buf, *pos;
String tmp(buf, sizeof(buf), log_cs); if (!(buf= my_malloc(9 + db_len + q_len, MYF(MY_WME))))
tmp.length(0); return;
pos= buf;
if (db && db_len) if (db && db_len)
{ {
tmp.append("use `", 5); pos= strmov(buf, "use `");
tmp.append(db, db_len); memcpy(pos, db, db_len);
tmp.append("`; ", 3); pos+= db_len;
pos= strmov(pos, "`; ");
} }
if (query && q_len) if (query && q_len)
tmp.append(query, q_len); {
protocol->store((char*) tmp.ptr(), tmp.length()); memcpy(pos, query, q_len);
pos+= q_len;
}
protocol->store(buf, pos-buf);
my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
} }
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
...@@ -964,16 +971,12 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -964,16 +971,12 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
void Start_log_event::pack_info(Protocol *protocol) void Start_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256]; char buf[12 + ST_SERVER_VER_LEN + 14 + 22], *pos;
String tmp(buf1, sizeof(buf1), log_cs); pos= strmov(buf, "Server ver: ");
tmp.length(0); pos= strmov(pos, server_version);
char buf[22]; pos= strmov(pos, ", Binlog ver: ");
pos=int10_to_str(binlog_version, pos, 10);
tmp.append("Server ver: "); protocol->store(buf, pos-buf);
tmp.append(server_version);
tmp.append(", Binlog ver: ");
tmp.append(llstr(binlog_version, buf));
protocol->store(tmp.ptr(), tmp.length());
} }
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
...@@ -1075,78 +1078,105 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -1075,78 +1078,105 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli)
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
void Load_log_event::pack_info(Protocol *protocol) void Load_log_event::pack_info(Protocol *protocol)
{ {
char buf[256]; char *buf, *pos;
String tmp(buf, sizeof(buf), log_cs); uint buf_len;
tmp.length(0);
buf_len=
5 + db_len + 3 + // "use DB; "
18 + fname_len + 2 + // "LOAD DATA INFILE 'file''"
9 + // " REPLACE or IGNORE "
11 + table_name_len + // "INTO TABLE table"
21 + sql_ex.field_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'"
23 + sql_ex.enclosed_len*4 + 2 + // " OPTIONALLY ENCLOSED BY 'str'"
12 + sql_ex.escaped_len*4 + 2 + // " ESCAPED BY 'str'"
21 + sql_ex.line_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'"
19 + sql_ex.line_start_len*4 + 2 + // " LINES STARTING BY 'str'"
15 + 22 + // " IGNORE xxx LINES"
3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)"
buf= my_malloc(buf_len, MYF(MY_WME));
if (!buf)
return;
pos= buf;
if (db && db_len) if (db && db_len)
{ {
tmp.append("use "); pos= strmov(pos, "use `");
tmp.append(db, db_len); memcpy(pos, db, db_len);
tmp.append("; ", 2); pos+= db_len;
pos= strmov(pos, "`; ");
} }
tmp.append("LOAD DATA INFILE '"); pos= strmov(pos, "LOAD DATA INFILE '");
tmp.append(fname, fname_len); memcpy(pos, fname, fname_len);
tmp.append("' ", 2); pos+= fname_len;
pos= strmov(pos, "' ");
if (sql_ex.opt_flags && REPLACE_FLAG ) if (sql_ex.opt_flags && REPLACE_FLAG )
tmp.append(" REPLACE "); pos= strmov(pos, " REPLACE ");
else if (sql_ex.opt_flags && IGNORE_FLAG ) else if (sql_ex.opt_flags && IGNORE_FLAG )
tmp.append(" IGNORE "); pos= strmov(pos, " IGNORE ");
tmp.append("INTO TABLE "); pos= strmov(pos ,"INTO TABLE ");
tmp.append(table_name); memcpy(pos, table_name, table_name_len);
pos+= table_name_len;
if (sql_ex.field_term_len) if (sql_ex.field_term_len)
{ {
tmp.append(" FIELDS TERMINATED BY "); pos= strmov(pos, " FIELDS TERMINATED BY ");
pretty_print_str(&tmp, sql_ex.field_term, sql_ex.field_term_len); pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len);
} }
if (sql_ex.enclosed_len) if (sql_ex.enclosed_len)
{ {
if (sql_ex.opt_flags && OPT_ENCLOSED_FLAG ) if (sql_ex.opt_flags && OPT_ENCLOSED_FLAG )
tmp.append(" OPTIONALLY "); pos= strmov(pos, " OPTIONALLY ");
tmp.append( " ENCLOSED BY "); pos= strmov(pos, " ENCLOSED BY ");
pretty_print_str(&tmp, sql_ex.enclosed, sql_ex.enclosed_len); pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len);
} }
if (sql_ex.escaped_len) if (sql_ex.escaped_len)
{ {
tmp.append( " ESCAPED BY "); pos= strmov(pos, " ESCAPED BY ");
pretty_print_str(&tmp, sql_ex.escaped, sql_ex.escaped_len); pos= pretty_print_str(pos, sql_ex.escaped, sql_ex.escaped_len);
} }
if (sql_ex.line_term_len) if (sql_ex.line_term_len)
{ {
tmp.append(" LINES TERMINATED BY "); pos= strmov(pos, " LINES TERMINATED BY ");
pretty_print_str(&tmp, sql_ex.line_term, sql_ex.line_term_len); pos= pretty_print_str(pos, sql_ex.line_term, sql_ex.line_term_len);
} }
if (sql_ex.line_start_len) if (sql_ex.line_start_len)
{ {
tmp.append(" LINES STARTING BY "); pos= strmov(pos, " LINES STARTING BY ");
pretty_print_str(&tmp, sql_ex.line_start, sql_ex.line_start_len); pos= pretty_print_str(pos, sql_ex.line_start, sql_ex.line_start_len);
} }
if ((int)skip_lines > 0) if ((int)skip_lines > 0)
tmp.append( " IGNORE %ld LINES ", (long) skip_lines); {
pos= strmov(pos, " IGNORE ");
pos= longlong10_to_str((long) skip_lines, pos, 10);
pos= strmov(pos," LINES ");
}
if (num_fields) if (num_fields)
{ {
uint i; uint i;
const char* field = fields; const char* field = fields;
tmp.append(" ("); pos= strmov(pos, " (");
for (i = 0; i < num_fields; i++) for (i = 0; i < num_fields; i++)
{ {
if (i) if (i)
tmp.append(" ,"); pos= strmov(pos, " ,");
tmp.append( field); memcpy(pos, field, field_lens[i]);
pos+= field_lens[i];
field += field_lens[i] + 1; field += field_lens[i] + 1;
} }
tmp.append(')'); *pos++= ')';
} }
protocol->store(tmp.ptr(), tmp.length()); protocol->store(buf, pos-buf);
my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
} }
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
...@@ -1301,9 +1331,9 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, ...@@ -1301,9 +1331,9 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len,
bool old_format) bool old_format)
{ {
uint data_len; uint data_len;
uint header_len= old_format ? OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN;
char* buf_end = (char*)buf + event_len; char* buf_end = (char*)buf + event_len;
const char* data_head = buf + ((old_format) ? const char* data_head = buf + header_len;
OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN);
thread_id = uint4korr(data_head + L_THREAD_ID_OFFSET); thread_id = uint4korr(data_head + L_THREAD_ID_OFFSET);
exec_time = uint4korr(data_head + L_EXEC_TIME_OFFSET); exec_time = uint4korr(data_head + L_EXEC_TIME_OFFSET);
skip_lines = uint4korr(data_head + L_SKIP_LINES_OFFSET); skip_lines = uint4korr(data_head + L_SKIP_LINES_OFFSET);
...@@ -1312,7 +1342,7 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, ...@@ -1312,7 +1342,7 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len,
num_fields = uint4korr(data_head + L_NUM_FIELDS_OFFSET); num_fields = uint4korr(data_head + L_NUM_FIELDS_OFFSET);
int body_offset = ((buf[EVENT_TYPE_OFFSET] == LOAD_EVENT) ? int body_offset = ((buf[EVENT_TYPE_OFFSET] == LOAD_EVENT) ?
LOAD_HEADER_LEN + OLD_HEADER_LEN : LOAD_HEADER_LEN + header_len :
get_data_body_offset()); get_data_body_offset());
if ((int) event_len < body_offset) if ((int) event_len < body_offset)
...@@ -1606,15 +1636,18 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, ...@@ -1606,15 +1636,18 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
void Rotate_log_event::pack_info(Protocol *protocol) void Rotate_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256], buf[22]; char *buf, *b_pos;
String tmp(buf1, sizeof(buf1), log_cs); if (!(buf= my_malloc(ident_len + 45, MYF(MY_WME))))
tmp.length(0); return;
tmp.append(new_log_ident, ident_len); b_pos= buf;
tmp.append(";pos="); memcpy(buf, new_log_ident, ident_len);
tmp.append(llstr(pos,buf)); b_pos+= ident_len;
b_pos= strmov(b_pos, ";pos=");
b_pos=int10_to_str(pos, b_pos, 10);
if (flags & LOG_EVENT_FORCED_ROTATE_F) if (flags & LOG_EVENT_FORCED_ROTATE_F)
tmp.append("; forced by master"); b_pos= strmov(b_pos ,"; forced by master");
protocol->store(tmp.ptr(), tmp.length()); protocol->store(buf, b_pos-buf);
my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
} }
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
...@@ -1744,13 +1777,11 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -1744,13 +1777,11 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
void Intvar_log_event::pack_info(Protocol *protocol) void Intvar_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256], buf[22]; char buf[64], *pos;
String tmp(buf1, sizeof(buf1), log_cs); pos= strmov(buf, get_var_type_name());
tmp.length(0); *(pos++)='=';
tmp.append(get_var_type_name()); pos=int10_to_str(val, pos, -10);
tmp.append('='); protocol->store(buf, pos-buf);
tmp.append(llstr(val, buf));
protocol->store(tmp.ptr(), tmp.length());
} }
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
...@@ -1952,19 +1983,16 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -1952,19 +1983,16 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli)
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
void Slave_log_event::pack_info(Protocol *protocol) void Slave_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256], buf[22], *end; char buf[256], *pos;
String tmp(buf1, sizeof(buf1), log_cs); pos= strmov(buf, "host=");
tmp.length(0); pos= strnmov(pos, master_host, HOSTNAME_LENGTH);
tmp.append("host="); pos= strmov(pos, ",port=");
tmp.append(master_host); pos= int10_to_str((long) master_port, pos, 10);
tmp.append(",port="); pos= strmov(pos, ",log=");
end= int10_to_str((long) master_port, buf, 10); pos= strmov(pos, master_log);
tmp.append(buf, (uint32) (end-buf)); pos= strmov(pos, ",pos=");
tmp.append(",log="); pos= int10_to_str(master_pos, pos, 10);
tmp.append(master_log); protocol->store(buf, pos-buf);
tmp.append(",pos=");
tmp.append(llstr(master_pos,buf));
protocol->store(tmp.ptr(), tmp.length());
} }
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
...@@ -2300,20 +2328,18 @@ void Create_file_log_event::print(FILE* file, bool short_form, ...@@ -2300,20 +2328,18 @@ void Create_file_log_event::print(FILE* file, bool short_form,
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
void Create_file_log_event::pack_info(Protocol *protocol) void Create_file_log_event::pack_info(Protocol *protocol)
{ {
char buf1[256],buf[22], *end; char buf[NAME_LEN*2 + 30 + 21*2], *pos;
String tmp(buf1, sizeof(buf1), log_cs); pos= strmov(buf, "db=");
tmp.length(0); memcpy(pos, db, db_len);
tmp.append("db="); pos+= db_len;
tmp.append(db, db_len); pos= strmov(pos, ";table=");
tmp.append(";table="); memcpy(pos, table_name, table_name_len);
tmp.append(table_name, table_name_len); pos+= table_name_len;
tmp.append(";file_id="); pos= strmov(pos, ";file_id=");
end= int10_to_str((long) file_id, buf, 10); pos= int10_to_str((long) file_id, pos, 10);
tmp.append(buf, (uint32) (end-buf)); pos= strmov(pos, ";block_len=");
tmp.append(";block_len="); pos= int10_to_str((long) block_len, pos, 10);
end= int10_to_str((long) block_len, buf, 10); protocol->store(buf, pos-buf);
tmp.append(buf, (uint32) (end-buf));
protocol->store((char*) tmp.ptr(), tmp.length());
} }
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment