Commit ff9c3500 authored by unknown's avatar unknown

Merge cbell@bk-internal.mysql.com:/home/bk/mysql-5.1-new-rpl

into  suse.vabb.com:/home/Chuck/development/mysql-5.1-new-rpl

parents e1b0f07c 5ee39cb6
...@@ -1516,18 +1516,27 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, ...@@ -1516,18 +1516,27 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
/* 2 utility functions for the next method */ /* 2 utility functions for the next method */
static void get_str_len_and_pointer(const char **dst, const char **src, uint *len)
/*
Get the pointer for a string (src) that contains the length in
the first byte. Set the output string (dst) to the string value
and place the length of the string in the byte after the string.
*/
static void get_str_len_and_pointer(const Log_event::Byte **src,
const char **dst,
uint *len)
{ {
if ((*len= **src)) if ((*len= **src))
*dst= *src + 1; // Will be copied later *dst= (char *)*src + 1; // Will be copied later
(*src)+= *len+1; (*src)+= *len + 1;
} }
static void copy_str_and_move(const char **src,
static void copy_str_and_move(char **dst, const char **src, uint len) Log_event::Byte **dst,
uint len)
{ {
memcpy(*dst, *src, len); memcpy(*dst, *src, len);
*src= *dst; *src= (const char *)*dst;
(*dst)+= len; (*dst)+= len;
*(*dst)++= 0; *(*dst)++= 0;
} }
...@@ -1550,8 +1559,8 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, ...@@ -1550,8 +1559,8 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
ulong data_len; ulong data_len;
uint32 tmp; uint32 tmp;
uint8 common_header_len, post_header_len; uint8 common_header_len, post_header_len;
char *start; Log_event::Byte *start;
const char *end; const Log_event::Byte *end;
bool catalog_nz= 1; bool catalog_nz= 1;
DBUG_ENTER("Query_log_event::Query_log_event(char*,...)"); DBUG_ENTER("Query_log_event::Query_log_event(char*,...)");
...@@ -1597,9 +1606,9 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, ...@@ -1597,9 +1606,9 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
/* variable-part: the status vars; only in MySQL 5.0 */ /* variable-part: the status vars; only in MySQL 5.0 */
start= (char*) (buf+post_header_len); start= (Log_event::Byte*) (buf+post_header_len);
end= (const char*) (start+status_vars_len); end= (const Log_event::Byte*) (start+status_vars_len);
for (const uchar* pos= (const uchar*) start; pos < (const uchar*) end;) for (const Log_event::Byte* pos= start; pos < end;)
{ {
switch (*pos++) { switch (*pos++) {
case Q_FLAGS2_CODE: case Q_FLAGS2_CODE:
...@@ -1621,7 +1630,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, ...@@ -1621,7 +1630,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
break; break;
} }
case Q_CATALOG_NZ_CODE: case Q_CATALOG_NZ_CODE:
get_str_len_and_pointer(&catalog, (const char **)(&pos), &catalog_len); get_str_len_and_pointer(&pos, &catalog, &catalog_len);
break; break;
case Q_AUTO_INCREMENT: case Q_AUTO_INCREMENT:
auto_increment_increment= uint2korr(pos); auto_increment_increment= uint2korr(pos);
...@@ -1637,7 +1646,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, ...@@ -1637,7 +1646,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
} }
case Q_TIME_ZONE_CODE: case Q_TIME_ZONE_CODE:
{ {
get_str_len_and_pointer(&time_zone_str, (const char **)(&pos), &time_zone_len); get_str_len_and_pointer(&pos, &time_zone_str, &time_zone_len);
break; break;
} }
case Q_CATALOG_CODE: /* for 5.0.x where 0<=x<=3 masters */ case Q_CATALOG_CODE: /* for 5.0.x where 0<=x<=3 masters */
...@@ -1659,38 +1668,38 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, ...@@ -1659,38 +1668,38 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
} }
#if !defined(MYSQL_CLIENT) && defined(HAVE_QUERY_CACHE) #if !defined(MYSQL_CLIENT) && defined(HAVE_QUERY_CACHE)
if (!(start= data_buf = (char*) my_malloc(catalog_len + 1 + if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1 +
time_zone_len + 1 + time_zone_len + 1 +
data_len + 1 + data_len + 1 +
QUERY_CACHE_FLAGS_SIZE + QUERY_CACHE_FLAGS_SIZE +
db_len + 1, db_len + 1,
MYF(MY_WME)))) MYF(MY_WME))))
#else #else
if (!(start= data_buf = (char*) my_malloc(catalog_len + 1 + if (!(start= data_buf = (Log_event::Byte*) my_malloc(catalog_len + 1 +
time_zone_len + 1 + time_zone_len + 1 +
data_len + 1, data_len + 1,
MYF(MY_WME)))) MYF(MY_WME))))
#endif #endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
if (catalog_len) // If catalog is given if (catalog_len) // If catalog is given
{ {
if (likely(catalog_nz)) // true except if event comes from 5.0.0|1|2|3. if (likely(catalog_nz)) // true except if event comes from 5.0.0|1|2|3.
copy_str_and_move(&start, &catalog, catalog_len); copy_str_and_move(&catalog, &start, catalog_len);
else else
{ {
memcpy(start, catalog, catalog_len+1); // copy end 0 memcpy(start, catalog, catalog_len+1); // copy end 0
catalog= start; catalog= (const char *)start;
start+= catalog_len+1; start+= catalog_len+1;
} }
} }
if (time_zone_len) if (time_zone_len)
copy_str_and_move(&start, &time_zone_str, time_zone_len); copy_str_and_move(&time_zone_str, &start, time_zone_len);
/* A 2nd variable part; this is common to all versions */ /* A 2nd variable part; this is common to all versions */
memcpy((char*) start, end, data_len); // Copy db and query memcpy((char*) start, end, data_len); // Copy db and query
start[data_len]= '\0'; // End query with \0 (For safetly) start[data_len]= '\0'; // End query with \0 (For safetly)
db= start; db= (char *)start;
query= start + db_len + 1; query= (char *)(start + db_len + 1);
q_len= data_len - db_len -1; q_len= data_len - db_len -1;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -587,6 +587,13 @@ typedef struct st_print_event_info ...@@ -587,6 +587,13 @@ typedef struct st_print_event_info
class Log_event class Log_event
{ {
public: public:
/*
The following type definition is to be used whenever data is placed
and manipulated in a common buffer. Use this typedef for buffers
that contain data containing binary and character data.
*/
typedef unsigned char Byte;
/* /*
The offset in the log where this event originally appeared (it is The offset in the log where this event originally appeared (it is
preserved in relay logs, making SHOW SLAVE STATUS able to print preserved in relay logs, making SHOW SLAVE STATUS able to print
...@@ -768,7 +775,7 @@ class Log_event ...@@ -768,7 +775,7 @@ class Log_event
class Query_log_event: public Log_event class Query_log_event: public Log_event
{ {
protected: protected:
char* data_buf; Log_event::Byte* data_buf;
public: public:
const char* query; const char* query;
const char* catalog; const char* catalog;
......
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