Commit 360bd365 authored by unknown's avatar unknown

Merge riska.(none):/home/sven/bktip/5.1-new-rpl

into  riska.(none):/home/sven/bk/b32434-version_replication/5.1-new-rpl


sql/log_event.cc:
  Auto merged
parents 37513aa5 b0283afb
......@@ -270,7 +270,7 @@ class Load_log_processor
File prepare_new_file_for_old_format(Load_log_event *le, char *filename);
int load_old_format_file(NET* net, const char *server_fname,
uint server_fname_len, File file);
int process_first_event(const char *bname, uint blen, const char *block,
int process_first_event(const char *bname, uint blen, const uchar *block,
uint block_len, uint file_id,
Create_file_log_event *ce);
};
......@@ -375,7 +375,7 @@ int Load_log_processor::load_old_format_file(NET* net, const char*server_fname,
*/
int Load_log_processor::process_first_event(const char *bname, uint blen,
const char *block, uint block_len,
const uchar *block, uint block_len,
uint file_id,
Create_file_log_event *ce)
{
......
......@@ -521,6 +521,11 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *);
#define my_b_tell(info) ((info)->pos_in_file + \
(size_t) (*(info)->current_pos - (info)->request_pos))
#define my_b_get_buffer_start(info) (info)->request_pos
#define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \
(char*) my_b_get_buffer_start(info)
#define my_b_get_pos_in_file(info) (info)->pos_in_file
/* tell write offset in the SEQ_APPEND cache */
int my_b_copy_to_file(IO_CACHE *cache, FILE *file);
my_off_t my_b_append_tell(IO_CACHE* info);
......
#
# Differs slightly from show_binlog events in showing server_id
# which is important for some tests
#
--let $binlog_start=106
--let $binlog_start=98
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
......
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t2 (id int not null primary key auto_increment);
select @@session.read_buffer_size - @@session.max_allowed_packet > 0 ;
@@session.read_buffer_size - @@session.max_allowed_packet > 0
1
load data infile 'MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' into table t2;
select count(*) from t2 /* 5 000 */;
count(*)
5000
show binlog events in 'master-bin.000002' from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 98 Query 1 # use `test`; create table t2 (id int not null primary key auto_increment)
master-bin.000002 221 Begin_load_query 1 # ;file_id=1;block_len=7168
master-bin.000002 7412 Append_block 1 # ;file_id=1;block_len=7168
master-bin.000002 14603 Append_block 1 # ;file_id=1;block_len=2048
master-bin.000002 16674 Append_block 1 # ;file_id=1;block_len=7168
master-bin.000002 23865 Append_block 1 # ;file_id=1;block_len=341
master-bin.000002 24229 Execute_load_query 1 # use `test`; load data infile 'MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' into table t2 ;file_id=1
select count(*) from t2 /* 5 000 */;
count(*)
5000
drop table t1, t2;
end of the tests
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
reset master;
delete from mysql.user where Host='fakehost';
create user 'foo'@'fakehost';
create user 'foo'@'fakehost', 'bar'@'fakehost';
ERROR HY000: Operation CREATE USER failed for 'foo'@'fakehost'
create user 'foo'@'fakehost', 'bar'@'fakehost';
ERROR HY000: Operation CREATE USER failed for 'foo'@'fakehost','bar'@'fakehost'
select Host,User from mysql.user where Host='fakehost';
Host User
fakehost bar
fakehost foo
rename user 'foo'@'fakehost' to 'foofoo'@'fakehost';
rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost';
ERROR HY000: Operation RENAME USER failed for 'not_exist_user1'@'fakehost'
rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'not_exist_user2'@'fakehost' to 'barfoo'@'fakehost';
ERROR HY000: Operation RENAME USER failed for 'not_exist_user1'@'fakehost','not_exist_user2'@'fakehost'
select Host,User from mysql.user where Host='fakehost';
Host User
fakehost barbar
fakehost foofoo
drop user 'foofoo'@'fakehost';
drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost';
ERROR HY000: Operation DROP USER failed for 'not_exist_user1'@'fakehost'
drop user 'not_exist_user1'@'fakehost', 'not_exist_user2'@'fakehost';
ERROR HY000: Operation DROP USER failed for 'not_exist_user1'@'fakehost','not_exist_user2'@'fakehost'
select Host,User from mysql.user where Host='fakehost';
Host User
show binlog events from 98;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 98 Query 1 # use `test`; delete from mysql.user where Host='fakehost'
master-bin.000001 205 Query 1 # use `test`; create user 'foo'@'fakehost'
master-bin.000001 296 Query 1 # use `test`; create user 'foo'@'fakehost', 'bar'@'fakehost'
master-bin.000001 405 Query 1 # use `test`; rename user 'foo'@'fakehost' to 'foofoo'@'fakehost'
master-bin.000001 519 Query 1 # use `test`; rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost'
master-bin.000001 686 Query 1 # use `test`; drop user 'foofoo'@'fakehost'
master-bin.000001 778 Query 1 # use `test`; drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost'
This diff is collapsed.
This diff is collapsed.
--read_buffer_size=9K --max_allowed_packet=8K
#
# check replication of load data with the server parameters subjected to
# read_buffer_size > max_allowed_packet
#
# BUG#30435 loading large LOAD DATA INFILE breaks slave with
# read_buffer_size set on master
# BUG#33413 show binlog events fails if binlog has event size of close
# to max_allowed_packet
source include/master-slave.inc;
source include/have_innodb.inc;
--disable_query_log
let $rows= 5000;
create table t1 (id int not null primary key auto_increment);
while($rows)
{
eval insert into t1 values (null);
dec $rows;
}
eval select * into outfile '$MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' from t1;
flush logs;
--enable_query_log
connection master;
create table t2 (id int not null primary key auto_increment);
select @@session.read_buffer_size - @@session.max_allowed_packet > 0 ;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval load data infile '$MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' into table t2;
select count(*) from t2 /* 5 000 */;
# the binglog will show fragmented Append_block events
--let $binlog_start=98
--replace_column 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval show binlog events in 'master-bin.000002' from $binlog_start
sync_slave_with_master;
#connection slave;
select count(*) from t2 /* 5 000 */;
connection master;
drop table t1, t2;
sync_slave_with_master;
remove_file $MYSQLTEST_VARDIR/tmp/bug30435_5k.txt;
--echo end of the tests
# BUG#33862 completely failed DROP USER statement gets replicated
--source include/master-slave.inc
reset master;
#
# remove all users will be used in the test
#
delete from mysql.user where Host='fakehost';
sync_slave_with_master;
#
# Test create user
#
connection master;
create user 'foo'@'fakehost';
--error ER_CANNOT_USER
create user 'foo'@'fakehost', 'bar'@'fakehost';
--error ER_CANNOT_USER
create user 'foo'@'fakehost', 'bar'@'fakehost';
sync_slave_with_master;
select Host,User from mysql.user where Host='fakehost';
#
# Test rename user
#
connection master;
rename user 'foo'@'fakehost' to 'foofoo'@'fakehost';
--error ER_CANNOT_USER
rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost';
--error ER_CANNOT_USER
rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'not_exist_user2'@'fakehost' to 'barfoo'@'fakehost';
sync_slave_with_master;
select Host,User from mysql.user where Host='fakehost';
#
# Test drop user
#
connection master;
drop user 'foofoo'@'fakehost';
--error ER_CANNOT_USER
drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost';
--error ER_CANNOT_USER
drop user 'not_exist_user1'@'fakehost', 'not_exist_user2'@'fakehost';
sync_slave_with_master;
select Host,User from mysql.user where Host='fakehost';
#
# show the binlog events on the master
#
connection master;
source include/show_binlog_events.inc;
......@@ -2095,7 +2095,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
/* Check if version of protocol matches current one */
mysql->protocol_version= net->read_pos[0];
DBUG_DUMP("packet",(char*) net->read_pos,10);
DBUG_DUMP("packet",(uchar*) net->read_pos,10);
DBUG_PRINT("info",("mysql protocol version %d, server=%d",
PROTOCOL_VERSION, mysql->protocol_version));
if (mysql->protocol_version != PROTOCOL_VERSION)
......@@ -2221,7 +2221,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
Send client_flag, max_packet_size - unencrypted otherwise
the server does not know we want to do SSL
*/
if (my_net_write(net,buff,(uint) (end-buff)) || net_flush(net))
if (my_net_write(net, (uchar*) buff, (uint) (end-buff)) || net_flush(net))
{
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
ER(CR_SERVER_LOST_EXTENDED),
......
......@@ -947,7 +947,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
*is_null= item->null_value;
}
if (*is_null)
return -1;
return ~(ulonglong) 0;
/*
Convert strings to the integer DATE/DATETIME representation.
Even if both dates provided in strings we can't compare them directly as
......
......@@ -5109,7 +5109,7 @@ Create_file_log_event(THD* thd_arg, sql_exchange* ex,
const char* db_arg, const char* table_name_arg,
List<Item>& fields_arg, enum enum_duplicates handle_dup,
bool ignore,
char* block_arg, uint block_len_arg, bool using_trans)
uchar* block_arg, uint block_len_arg, bool using_trans)
:Load_log_event(thd_arg,ex,db_arg,table_name_arg,fields_arg,handle_dup, ignore,
using_trans),
fake_base(0), block(block_arg), event_buf(0), block_len(block_len_arg),
......@@ -5208,7 +5208,7 @@ Create_file_log_event::Create_file_log_event(const char* buf, uint len,
create_file_header_len + 1);
if (len < block_offset)
DBUG_VOID_RETURN;
block = (char*)buf + block_offset;
block = (uchar*)buf + block_offset;
block_len = len - block_offset;
}
else
......@@ -5366,7 +5366,7 @@ int Create_file_log_event::do_apply_event(Relay_log_info const *rli)
#ifndef MYSQL_CLIENT
Append_block_log_event::Append_block_log_event(THD *thd_arg,
const char *db_arg,
char *block_arg,
uchar *block_arg,
uint block_len_arg,
bool using_trans)
:Log_event(thd_arg,0, using_trans), block(block_arg),
......@@ -5392,7 +5392,7 @@ Append_block_log_event::Append_block_log_event(const char* buf, uint len,
if (len < total_header_len)
DBUG_VOID_RETURN;
file_id= uint4korr(buf + common_header_len + AB_FILE_ID_OFFSET);
block= (char*)buf + total_header_len;
block= (uchar*)buf + total_header_len;
block_len= len - total_header_len;
DBUG_VOID_RETURN;
}
......@@ -5784,7 +5784,7 @@ int Execute_load_log_event::do_apply_event(Relay_log_info const *rli)
#ifndef MYSQL_CLIENT
Begin_load_query_log_event::
Begin_load_query_log_event(THD* thd_arg, const char* db_arg, char* block_arg,
Begin_load_query_log_event(THD* thd_arg, const char* db_arg, uchar* block_arg,
uint block_len_arg, bool using_trans)
:Append_block_log_event(thd_arg, db_arg, block_arg, block_len_arg,
using_trans)
......
......@@ -2519,7 +2519,7 @@ class Create_file_log_event: public Load_log_event
*/
bool fake_base;
public:
char* block;
uchar* block;
const char *event_buf;
uint block_len;
uint file_id;
......@@ -2530,7 +2530,7 @@ class Create_file_log_event: public Load_log_event
const char* table_name_arg,
List<Item>& fields_arg,
enum enum_duplicates handle_dup, bool ignore,
char* block_arg, uint block_len_arg,
uchar* block_arg, uint block_len_arg,
bool using_trans);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
......@@ -2585,7 +2585,7 @@ class Create_file_log_event: public Load_log_event
class Append_block_log_event: public Log_event
{
public:
char* block;
uchar* block;
uint block_len;
uint file_id;
/*
......@@ -2602,7 +2602,7 @@ class Append_block_log_event: public Log_event
const char* db;
#ifndef MYSQL_CLIENT
Append_block_log_event(THD* thd, const char* db_arg, char* block_arg,
Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
uint block_len_arg, bool using_trans);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
......@@ -2726,7 +2726,7 @@ class Begin_load_query_log_event: public Append_block_log_event
public:
#ifndef MYSQL_CLIENT
Begin_load_query_log_event(THD* thd_arg, const char *db_arg,
char* block_arg, uint block_len_arg,
uchar* block_arg, uint block_len_arg,
bool using_trans);
#ifdef HAVE_REPLICATION
Begin_load_query_log_event(THD* thd);
......
......@@ -164,7 +164,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
break;
}
default:
length= -1;
length= ~(uint32) 0;
}
return length;
}
......
......@@ -2823,7 +2823,7 @@ static int process_io_create_file(Master_info* mi, Create_file_log_event* cev)
}
if (unlikely(cev_not_written))
{
cev->block = (char*)net->read_pos;
cev->block = net->read_pos;
cev->block_len = num_bytes;
if (unlikely(mi->rli.relay_log.append(cev)))
{
......@@ -2837,7 +2837,7 @@ static int process_io_create_file(Master_info* mi, Create_file_log_event* cev)
}
else
{
aev.block = (char*)net->read_pos;
aev.block = net->read_pos;
aev.block_len = num_bytes;
aev.log_pos = cev->log_pos;
if (unlikely(mi->rli.relay_log.append(&aev)))
......
......@@ -5489,6 +5489,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
LEX_USER *user_name, *tmp_user_name;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
bool some_users_created= FALSE;
DBUG_ENTER("mysql_create_user");
/*
......@@ -5524,6 +5525,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
continue;
}
some_users_created= TRUE;
sql_mode= thd->variables.sql_mode;
if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0))
{
......@@ -5534,12 +5536,14 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
write_bin_log(thd, FALSE, thd->query, thd->query_length);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
if (some_users_created)
write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
DBUG_RETURN(result);
}
......@@ -5564,6 +5568,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
LEX_USER *user_name, *tmp_user_name;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
bool some_users_deleted= FALSE;
DBUG_ENTER("mysql_drop_user");
/*
......@@ -5592,7 +5597,9 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
{
append_user(&wrong_users, user_name);
result= TRUE;
continue;
}
some_users_deleted= TRUE;
}
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
......@@ -5606,7 +5613,8 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
DBUG_PRINT("info", ("thd->net.last_errno: %d", thd->net.last_errno));
DBUG_PRINT("info", ("thd->net.last_error: %s", thd->net.last_error));
write_bin_log(thd, FALSE, thd->query, thd->query_length);
if (some_users_deleted)
write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
......@@ -5635,6 +5643,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
LEX_USER *user_to, *tmp_user_to;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
bool some_users_renamed= FALSE;
DBUG_ENTER("mysql_rename_user");
/*
......@@ -5675,7 +5684,9 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
{
append_user(&wrong_users, user_from);
result= TRUE;
continue;
}
some_users_renamed= TRUE;
}
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
......@@ -5683,12 +5694,14 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
write_bin_log(thd, FALSE, thd->query, thd->query_length);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
if (some_users_renamed && mysql_bin_log.is_open())
write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
if (result)
my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
DBUG_RETURN(result);
}
......
......@@ -1166,7 +1166,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
unregister_slave(thd,1,1);
/* fake COM_QUIT -- if we get here, the thread needs to terminate */
error = TRUE;
net->error = 0;
break;
}
#endif
......
......@@ -1243,9 +1243,6 @@ bool change_master(THD* thd, Master_info* mi)
DBUG_RETURN(TRUE);
}
}
mi->rli.group_master_log_pos = mi->master_log_pos;
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
/*
Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block,
so restore them to good values. If we left them to ''/0, that would work;
......@@ -1257,6 +1254,7 @@ bool change_master(THD* thd, Master_info* mi)
That's why we always save good coords in rli.
*/
mi->rli.group_master_log_pos= mi->master_log_pos;
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
strmake(mi->rli.group_master_log_name,mi->master_log_name,
sizeof(mi->rli.group_master_log_name)-1);
......@@ -1376,6 +1374,11 @@ bool mysql_show_binlog_events(THD* thd)
if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0)
goto err;
/*
to account binlog event header size
*/
thd->variables.max_allowed_packet += MAX_LOG_EVENT_HEADER;
pthread_mutex_lock(log_lock);
/*
......@@ -1386,7 +1389,6 @@ bool mysql_show_binlog_events(THD* thd)
This code will fail on a mixed relay log (one which has Format_desc then
Rotate then Format_desc).
*/
ev = Log_event::read_log_event(&log,(pthread_mutex_t*)0,description_event);
if (ev)
{
......@@ -1578,39 +1580,54 @@ bool show_binlogs(THD* thd)
DBUG_RETURN(TRUE);
}
/**
Load data's io cache specific hook to be executed
before a chunk of data is being read into the cache's buffer
The fuction instantianates and writes into the binlog
replication events along LOAD DATA processing.
@param file pointer to io-cache
@return 0
*/
int log_loaded_block(IO_CACHE* file)
{
DBUG_ENTER("log_loaded_block");
LOAD_FILE_INFO *lf_info;
uint block_len ;
/* file->request_pos contains position where we started last read */
char* buffer = (char*) file->request_pos;
if (!(block_len = (char*) file->read_end - (char*) buffer))
return 0;
lf_info = (LOAD_FILE_INFO*) file->arg;
uint block_len;
/* buffer contains position where we started last read */
uchar* buffer= my_b_get_buffer_start(file);
uint max_event_size= current_thd->variables.max_allowed_packet;
lf_info= (LOAD_FILE_INFO*) file->arg;
if (lf_info->thd->current_stmt_binlog_row_based)
return 0;
if (lf_info->last_pos_in_file != HA_POS_ERROR &&
lf_info->last_pos_in_file >= file->pos_in_file)
return 0;
lf_info->last_pos_in_file = file->pos_in_file;
if (lf_info->wrote_create_file)
{
Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
block_len, lf_info->log_delayed);
mysql_bin_log.write(&a);
}
else
lf_info->last_pos_in_file >= my_b_get_pos_in_file(file))
DBUG_RETURN(0);
for (block_len= my_b_get_bytes_in_buffer(file); block_len > 0;
buffer += min(block_len, max_event_size),
block_len -= min(block_len, max_event_size))
{
Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
buffer, block_len,
lf_info->log_delayed);
mysql_bin_log.write(&b);
lf_info->wrote_create_file = 1;
DBUG_SYNC_POINT("debug_lock.created_file_event",10);
lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
if (lf_info->wrote_create_file)
{
Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
min(block_len, max_event_size),
lf_info->log_delayed);
mysql_bin_log.write(&a);
}
else
{
Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
buffer,
min(block_len, max_event_size),
lf_info->log_delayed);
mysql_bin_log.write(&b);
lf_info->wrote_create_file= 1;
DBUG_SYNC_POINT("debug_lock.created_file_event",10);
}
}
return 0;
DBUG_RETURN(0);
}
/*
......
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