Commit d15f2426 authored by monty@mysql.com's avatar monty@mysql.com

Fixed bug in replacation for not x86 platforms

Portability fixes
parent 2e77049d
......@@ -18,5 +18,5 @@ max(a)
8000
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root 9306 1 master-bin.000001 687207 # # master-bin.000001 Yes Yes 0 0 687207 # None 0 No #
# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 687207 # # master-bin.000001 Yes Yes 0 0 687207 # None 0 No #
drop table t1;
......@@ -58,6 +58,7 @@ start slave;
select master_pos_wait('master-bin.001',3000)>=0;
select max(a) from t1;
--replace_column 1 # 8 # 9 # 23 # 33 #
--replace_result $MASTER_MYPORT MASTER_MYPORT
show slave status;
# The following DROP is a very important cleaning task:
......
......@@ -1138,20 +1138,19 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
/* variable-part: the status vars; only in MySQL 5.0 */
const char* start= buf+post_header_len;
const char* end= start+status_vars_len;
const uchar *start= (uchar*) (buf+post_header_len);
const uchar *end= (uchar*) (start+status_vars_len);
/*
The place from which we will start string duplication.
*/
const char* start_dup= end;
const uchar *start_dup= end;
for (const char* pos=start;pos<end;)
{
switch (*pos)
for (const uchar* pos=start;pos<end;)
{
switch (*pos++) {
case Q_FLAGS2_CODE:
flags2_inited= 1;
flags2= uint4korr(++pos);
flags2= uint4korr(pos);
DBUG_PRINT("info",("In Query_log_event, read flags2: %lu", flags2));
pos+= 4;
break;
......@@ -1161,14 +1160,14 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
char buff[22];
#endif
sql_mode_inited= 1;
sql_mode= (ulong) uint8korr(++pos); // QQ: Fix when sql_mode is ulonglong
sql_mode= (ulong) uint8korr(pos); // QQ: Fix when sql_mode is ulonglong
DBUG_PRINT("info",("In Query_log_event, read sql_mode: %s",
llstr(sql_mode, buff)));
pos+= 8;
break;
}
case Q_CATALOG_CODE:
catalog_len= *(++pos);
catalog_len= *pos;
/*
Now 'pos' points to beginning of catalog - 1.
The catalog must be included in the string which we will duplicate
......@@ -1184,14 +1183,14 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
default:
/* That's why you must write status vars in growing order of code */
DBUG_PRINT("info",("Query_log_event has unknown status vars (first has\
code=%d), skipping the rest of them", *pos));
code: %u), skipping the rest of them", (uint) *(pos-1)));
pos= end;
}
}
/* A 2nd variable part; this is common to all versions */
data_len-= start_dup-start; /* cut not-to-be-duplicated head */
data_len-= (uint) (start_dup-start); /* cut not-to-be-duplicated head */
if (!(data_buf = (char*) my_strdup_with_length((byte*) start_dup,
data_len,
MYF(MY_WME))))
......@@ -1202,17 +1201,18 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
if (catalog_len)
{
catalog= tmp_buf;
tmp_buf+= end-start_dup; /* "seek" to db */
tmp_buf+= (uint) (end-start_dup); /* "seek" to db */
}
db= tmp_buf;
query= tmp_buf + db_len + 1;
q_len = data_buf + data_len - query;
/* This is used to detect wrong parsing. Could be removed in the future. */
DBUG_PRINT("info", ("catalog_len=%d catalog='%s' db='%s' q_len=%d",
DBUG_PRINT("info", ("catalog_len:%d catalog: '%s' db: '%s' q_len: %d",
catalog_len, catalog, db, q_len));
DBUG_VOID_RETURN;
}
/*
Query_log_event::print()
*/
......
......@@ -101,7 +101,6 @@ inline double log2_n_fact(double x)
get_merge_buffers_cost()
buff_elems Array of #s of elements in buffers
elem_size Size of element stored in buffer
output_buff Pointer to storage for result buffer size
first Pointer to first merged element size
last Pointer to last merged element size
......@@ -125,8 +124,7 @@ inline double log2_n_fact(double x)
*/
static double get_merge_buffers_cost(uint *buff_elems, uint elem_size,
uint *output_buff, uint *first,
uint *last)
uint *first, uint *last)
{
uint total_buf_elems= 0;
for (uint *pbuf= first; pbuf <= last; pbuf++)
......@@ -137,7 +135,7 @@ static double get_merge_buffers_cost(uint *buff_elems, uint elem_size,
/* Using log2(n)=log(n)/log(2) formula */
return 2*((double)total_buf_elems*elem_size) / IO_SIZE +
total_buf_elems*log(n_buffers) / (TIME_FOR_COMPARE_ROWID * M_LN2);
total_buf_elems*log((double) n_buffers) / (TIME_FOR_COMPARE_ROWID * M_LN2);
}
......@@ -175,7 +173,6 @@ static double get_merge_many_buffs_cost(uint *buffer,
register int i;
double total_cost= 0.0;
uint *buff_elems= buffer; /* #s of elements in each of merged sequences */
uint *lastbuff;
/*
Set initial state: first maxbuffer sequences contain max_n_elems elements
......@@ -193,21 +190,23 @@ static double get_merge_many_buffs_cost(uint *buffer,
{
while (maxbuffer >= MERGEBUFF2)
{
lastbuff=0;
uint lastbuff= 0;
for (i = 0; i <= (int) maxbuffer - MERGEBUFF*3/2; i += MERGEBUFF)
total_cost+=get_merge_buffers_cost(buff_elems, elem_size, lastbuff++,
{
total_cost+=get_merge_buffers_cost(buff_elems, elem_size,
buff_elems + i,
buff_elems + i + MERGEBUFF-1);
total_cost+=get_merge_buffers_cost(buff_elems, elem_size, lastbuff++,
lastbuff++;
}
total_cost+=get_merge_buffers_cost(buff_elems, elem_size,
buff_elems + i,
buff_elems + maxbuffer);
maxbuffer= (uint)lastbuff-1;
maxbuffer= lastbuff;
}
}
/* Simulate final merge_buff call. */
total_cost += get_merge_buffers_cost(buff_elems, elem_size, buff_elems,
total_cost += get_merge_buffers_cost(buff_elems, elem_size,
buff_elems, buff_elems + maxbuffer);
return total_cost;
}
......@@ -293,8 +292,8 @@ double Unique::get_use_cost(uint *buffer, uint nkeys, uint key_size,
writes are sequential.
*/
result += DISK_SEEK_BASE_COST * n_full_trees *
ceil(key_size*max_elements_in_tree / IO_SIZE);
result += DISK_SEEK_BASE_COST * ceil(key_size*last_tree_elems / IO_SIZE);
ceil(((double) key_size)*max_elements_in_tree / IO_SIZE);
result += DISK_SEEK_BASE_COST * ceil(((double) key_size)*last_tree_elems / IO_SIZE);
/* Cost of merge */
double merge_cost= get_merge_many_buffs_cost(buffer, n_full_trees,
......
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