Commit d2a5fab2 authored by unknown's avatar unknown

--do-test option in mysql-test-run - will do only tests that match the pattern

updated rotate event to set new position along with the new log


mysql-test/mysql-test-run.sh:
  added --do-test
mysql-test/r/rpl_log.result:
  update for new rotate event format
sql/log_event.cc:
  rotate event now supports forcing a new position, not just the log
sql/log_event.h:
  clean-up of rotate event, support for position force with rotate event
sql/slave.cc:
  accept position setting from rotate event
sql/sql_repl.cc:
  updates to fake_rotate_event() for the new format
parent f246b619
...@@ -145,6 +145,7 @@ while test $# -gt 0; do ...@@ -145,6 +145,7 @@ while test $# -gt 0; do
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-bdb" ;; EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-bdb" ;;
--skip-rpl) NO_SLAVE=1 ;; --skip-rpl) NO_SLAVE=1 ;;
--skip-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-test=;;"`;; --skip-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-test=;;"`;;
--do-test=*) DO_TEST=`$ECHO "$1" | $SED -e "s;--do-test=;;"`;;
--record) --record)
RECORD=1; RECORD=1;
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;; EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;;
...@@ -336,7 +337,7 @@ show_failed_diff () ...@@ -336,7 +337,7 @@ show_failed_diff ()
then then
echo "Below are the diffs between actual and expected results:" echo "Below are the diffs between actual and expected results:"
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
$DIFF -c $result_file $reject_file $DIFF -c -a $result_file $reject_file
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
echo "Please follow the instructions outlined at" echo "Please follow the instructions outlined at"
echo "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html" echo "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html"
...@@ -667,7 +668,7 @@ run_testcase () ...@@ -667,7 +668,7 @@ run_testcase ()
slave_init_script=$TESTDIR/$tname-slave.sh slave_init_script=$TESTDIR/$tname-slave.sh
slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0` SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ -n $SKIP_TEST ] ; then if [ -n "$SKIP_TEST" ] ; then
SKIP_THIS_TEST=`$EXPR \( $tname : "$SKIP_TEST" \) != 0` SKIP_THIS_TEST=`$EXPR \( $tname : "$SKIP_TEST" \) != 0`
if [ x$SKIP_THIS_TEST = x1 ] ; if [ x$SKIP_THIS_TEST = x1 ] ;
then then
...@@ -675,6 +676,15 @@ run_testcase () ...@@ -675,6 +676,15 @@ run_testcase ()
fi fi
fi fi
if [ -n "$DO_TEST" ] ; then
DO_THIS_TEST=`$EXPR \( $tname : "$DO_TEST" \) != 0`
if [ x$DO_THIS_TEST = x0 ] ;
then
return;
fi
fi
if [ x${NO_SLAVE}x$SKIP_SLAVE = x1x0 ] ; if [ x${NO_SLAVE}x$SKIP_SLAVE = x1x0 ] ;
then then
USERT=" ...." USERT=" ...."
......
...@@ -23,8 +23,8 @@ master-bin.001 263 Query 1 5 use test; drop table t1 ...@@ -23,8 +23,8 @@ master-bin.001 263 Query 1 5 use test; drop table t1
master-bin.001 311 Query 1 6 use test; create table t1 (word char(20) not null) master-bin.001 311 Query 1 6 use test; create table t1 (word char(20) not null)
master-bin.001 386 Load 1 7 use test; LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 FIELDS TERMINATED BY '\t' ESCAPED BY '\\' LINES TERMINATED BY '\n' (word) master-bin.001 386 Load 1 7 use test; LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 FIELDS TERMINATED BY '\t' ESCAPED BY '\\' LINES TERMINATED BY '\n' (word)
master-bin.001 468 Query 1 8 use test; drop table t1 master-bin.001 468 Query 1 8 use test; drop table t1
master-bin.001 516 Rotate 1 9 master-bin.002 master-bin.001 516 Rotate 1 9 master-bin.002;pos=4
master-bin.001 549 Stop 1 10 master-bin.001 557 Stop 1 10
Log_name Pos Event_type Server_id Log_seq Info Log_name Pos Event_type Server_id Log_seq Info
master-bin.002 4 Start 1 1 Server ver: 4.0.0-debug-log, Binlog ver: 2 master-bin.002 4 Start 1 1 Server ver: 4.0.0-debug-log, Binlog ver: 2
master-bin.002 79 Query 1 2 use test; create table t1 (n int) master-bin.002 79 Query 1 2 use test; create table t1 (n int)
...@@ -45,8 +45,8 @@ slave-bin.001 253 Query 1 4 use test; insert into t1 values (NULL) ...@@ -45,8 +45,8 @@ slave-bin.001 253 Query 1 4 use test; insert into t1 values (NULL)
slave-bin.001 316 Query 1 5 use test; drop table t1 slave-bin.001 316 Query 1 5 use test; drop table t1
slave-bin.001 364 Query 1 6 use test; create table t1 (word char(20) not null) slave-bin.001 364 Query 1 6 use test; create table t1 (word char(20) not null)
slave-bin.001 439 Query 1 8 use test; drop table t1 slave-bin.001 439 Query 1 8 use test; drop table t1
slave-bin.001 487 Rotate 2 3 slave-bin.002; forced by master slave-bin.001 487 Rotate 2 3 slave-bin.002;pos=4; forced by master
slave-bin.001 519 Stop 2 4 slave-bin.001 527 Stop 2 4
Log_name Pos Event_type Server_id Log_seq Info Log_name Pos Event_type Server_id Log_seq Info
slave-bin.002 4 Start 2 1 Server ver: 4.0.0-debug-log, Binlog ver: 2 slave-bin.002 4 Start 2 1 Server ver: 4.0.0-debug-log, Binlog ver: 2
slave-bin.002 79 Slave 2 2 host=127.0.0.1,port=9306,log=master-bin.002,pos=4 slave-bin.002 79 Slave 2 2 host=127.0.0.1,port=9306,log=master-bin.002,pos=4
......
...@@ -190,7 +190,10 @@ void Load_log_event::pack_info(String* packet) ...@@ -190,7 +190,10 @@ void Load_log_event::pack_info(String* packet)
void Rotate_log_event::pack_info(String* packet) void Rotate_log_event::pack_info(String* packet)
{ {
String tmp; String tmp;
char buf[22];
tmp.append(new_log_ident, ident_len); tmp.append(new_log_ident, ident_len);
tmp.append(";pos=");
tmp.append(llstr(pos,buf));
if(flags & LOG_EVENT_FORCED_ROTATE_F) if(flags & LOG_EVENT_FORCED_ROTATE_F)
tmp.append("; forced by master"); tmp.append("; forced by master");
net_store_data(packet, tmp.ptr(), tmp.length()); net_store_data(packet, tmp.ptr(), tmp.length());
...@@ -492,6 +495,7 @@ void Stop_log_event::print(FILE* file, bool short_form, char* last_db) ...@@ -492,6 +495,7 @@ void Stop_log_event::print(FILE* file, bool short_form, char* last_db)
void Rotate_log_event::print(FILE* file, bool short_form, char* last_db) void Rotate_log_event::print(FILE* file, bool short_form, char* last_db)
{ {
char buf[22];
if (short_form) if (short_form)
return; return;
...@@ -500,7 +504,7 @@ void Rotate_log_event::print(FILE* file, bool short_form, char* last_db) ...@@ -500,7 +504,7 @@ void Rotate_log_event::print(FILE* file, bool short_form, char* last_db)
if (new_log_ident) if (new_log_ident)
my_fwrite(file, (byte*) new_log_ident, (uint)ident_len, my_fwrite(file, (byte*) new_log_ident, (uint)ident_len,
MYF(MY_NABP | MY_WME)); MYF(MY_NABP | MY_WME));
fprintf(file, "\n"); fprintf(file, "pos=%s\n", llstr(pos, buf));
fflush(file); fflush(file);
} }
...@@ -530,8 +534,10 @@ Rotate_log_event::Rotate_log_event(const char* buf, int event_len): ...@@ -530,8 +534,10 @@ Rotate_log_event::Rotate_log_event(const char* buf, int event_len):
if(event_len < ROTATE_EVENT_OVERHEAD) if(event_len < ROTATE_EVENT_OVERHEAD)
return; return;
pos = uint8korr(buf + R_POS_OFFSET + LOG_EVENT_HEADER_LEN);
ident_len = (uchar)(event_len - ROTATE_EVENT_OVERHEAD); ident_len = (uchar)(event_len - ROTATE_EVENT_OVERHEAD);
if (!(new_log_ident = (char*) my_memdup((byte*) buf + LOG_EVENT_HEADER_LEN, if (!(new_log_ident = (char*) my_memdup((byte*) buf + R_IDENT_OFFSET
+ LOG_EVENT_HEADER_LEN,
(uint) ident_len, MYF(MY_WME)))) (uint) ident_len, MYF(MY_WME))))
return; return;
...@@ -540,7 +546,10 @@ Rotate_log_event::Rotate_log_event(const char* buf, int event_len): ...@@ -540,7 +546,10 @@ Rotate_log_event::Rotate_log_event(const char* buf, int event_len):
int Rotate_log_event::write_data(IO_CACHE* file) int Rotate_log_event::write_data(IO_CACHE* file)
{ {
return my_b_write(file, (byte*) new_log_ident, (uint) ident_len) ? -1 :0; char buf[ROTATE_HEADER_LEN];
int8store(buf, pos + R_POS_OFFSET);
return my_b_write(file, (byte*)buf, ROTATE_HEADER_LEN) ||
my_b_write(file, (byte*)new_log_ident, (uint) ident_len);
} }
Query_log_event::Query_log_event(const char* buf, int event_len): Query_log_event::Query_log_event(const char* buf, int event_len):
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#define QUERY_HEADER_LEN (4 + 4 + 1 + 2) #define QUERY_HEADER_LEN (4 + 4 + 1 + 2)
#define LOAD_HEADER_LEN (4 + 4 + 4 + 1 +1 + 4) #define LOAD_HEADER_LEN (4 + 4 + 4 + 1 +1 + 4)
#define START_HEADER_LEN (2 + ST_SERVER_VER_LEN + 4) #define START_HEADER_LEN (2 + ST_SERVER_VER_LEN + 4)
#define ROTATE_HEADER_LEN 8
/* event header offsets */ /* event header offsets */
...@@ -98,10 +99,14 @@ ...@@ -98,10 +99,14 @@
#define L_NUM_FIELDS_OFFSET 14 #define L_NUM_FIELDS_OFFSET 14
#define L_DATA_OFFSET LOAD_HEADER_LEN #define L_DATA_OFFSET LOAD_HEADER_LEN
/* Rotate event post-header */
#define R_POS_OFFSET 0
#define R_IDENT_OFFSET 8
#define QUERY_EVENT_OVERHEAD (LOG_EVENT_HEADER_LEN+QUERY_HEADER_LEN) #define QUERY_EVENT_OVERHEAD (LOG_EVENT_HEADER_LEN+QUERY_HEADER_LEN)
#define QUERY_DATA_OFFSET (LOG_EVENT_HEADER_LEN+QUERY_HEADER_LEN) #define QUERY_DATA_OFFSET (LOG_EVENT_HEADER_LEN+QUERY_HEADER_LEN)
#define ROTATE_EVENT_OVERHEAD LOG_EVENT_HEADER_LEN #define ROTATE_EVENT_OVERHEAD (LOG_EVENT_HEADER_LEN+ROTATE_HEADER_LEN)
#define LOAD_EVENT_OVERHEAD (LOG_EVENT_HEADER_LEN+LOAD_HEADER_LEN+sizeof(sql_ex_info)) #define LOAD_EVENT_OVERHEAD (LOG_EVENT_HEADER_LEN+LOAD_HEADER_LEN+sizeof(sql_ex_info))
#define BINLOG_MAGIC "\xfe\x62\x69\x6e" #define BINLOG_MAGIC "\xfe\x62\x69\x6e"
...@@ -111,7 +116,7 @@ ...@@ -111,7 +116,7 @@
enum Log_event_type { START_EVENT = 1, QUERY_EVENT =2, enum Log_event_type { START_EVENT = 1, QUERY_EVENT =2,
STOP_EVENT=3, ROTATE_EVENT = 4, INTVAR_EVENT=5, STOP_EVENT=3, ROTATE_EVENT = 4, INTVAR_EVENT=5,
LOAD_EVENT=6, SLAVE_EVENT=7}; LOAD_EVENT=6, SLAVE_EVENT=7, FILE_EVENT=8};
enum Int_event_type { INVALID_INT_EVENT = 0, LAST_INSERT_ID_EVENT = 1, INSERT_ID_EVENT = 2 enum Int_event_type { INVALID_INT_EVENT = 0, LAST_INSERT_ID_EVENT = 1, INSERT_ID_EVENT = 2
}; };
...@@ -487,12 +492,15 @@ class Rotate_log_event: public Log_event ...@@ -487,12 +492,15 @@ class Rotate_log_event: public Log_event
public: public:
const char* new_log_ident; const char* new_log_ident;
uchar ident_len; uchar ident_len;
ulonglong pos;
bool alloced; bool alloced;
Rotate_log_event(const char* new_log_ident_arg, uint ident_len_arg = 0) : Rotate_log_event(const char* new_log_ident_arg, uint ident_len_arg = 0,
ulonglong pos_arg = 4) :
Log_event(time(NULL)), Log_event(time(NULL)),
new_log_ident(new_log_ident_arg), new_log_ident(new_log_ident_arg),
ident_len(ident_len_arg ? ident_len_arg : (uint) strlen(new_log_ident_arg)), ident_len(ident_len_arg ? ident_len_arg :
(uint) strlen(new_log_ident_arg)), pos(pos_arg),
alloced(0) alloced(0)
{} {}
...@@ -503,7 +511,7 @@ public: ...@@ -503,7 +511,7 @@ public:
my_free((gptr) new_log_ident, MYF(0)); my_free((gptr) new_log_ident, MYF(0));
} }
Log_event_type get_type_code() { return ROTATE_EVENT;} Log_event_type get_type_code() { return ROTATE_EVENT;}
int get_data_size() { return ident_len;} int get_data_size() { return ident_len + ROTATE_HEADER_LEN;}
int write_data(IO_CACHE* file); int write_data(IO_CACHE* file);
void print(FILE* file, bool short_form = 0, char* last_db = 0); void print(FILE* file, bool short_form = 0, char* last_db = 0);
......
...@@ -1205,7 +1205,7 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) ...@@ -1205,7 +1205,7 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
memcpy(log_name, rev->new_log_ident,ident_len ); memcpy(log_name, rev->new_log_ident,ident_len );
log_name[ident_len] = 0; log_name[ident_len] = 0;
} }
mi->pos = 4; // skip magic number mi->pos = rev->pos;
mi->last_log_seq = ev->log_seq; mi->last_log_seq = ev->log_seq;
pthread_cond_broadcast(&mi->cond); pthread_cond_broadcast(&mi->cond);
pthread_mutex_unlock(&mi->lock); pthread_mutex_unlock(&mi->lock);
......
...@@ -62,7 +62,7 @@ void end_slave_list() ...@@ -62,7 +62,7 @@ void end_slave_list()
static int fake_rotate_event(NET* net, String* packet, char* log_file_name, static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
const char**errmsg) const char**errmsg)
{ {
char header[LOG_EVENT_HEADER_LEN]; char header[LOG_EVENT_HEADER_LEN], buf[ROTATE_HEADER_LEN];
memset(header, 0, 4); // when does not matter memset(header, 0, 4); // when does not matter
header[EVENT_TYPE_OFFSET] = ROTATE_EVENT; header[EVENT_TYPE_OFFSET] = ROTATE_EVENT;
char* p = strrchr(log_file_name, FN_LIBCHAR); char* p = strrchr(log_file_name, FN_LIBCHAR);
...@@ -73,12 +73,14 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, ...@@ -73,12 +73,14 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
p = log_file_name; p = log_file_name;
uint ident_len = (uint) strlen(p); uint ident_len = (uint) strlen(p);
ulong event_len = ident_len + sizeof(header); ulong event_len = ident_len + ROTATE_EVENT_OVERHEAD;
int4store(header + SERVER_ID_OFFSET, server_id); int4store(header + SERVER_ID_OFFSET, server_id);
int4store(header + EVENT_LEN_OFFSET, event_len); int4store(header + EVENT_LEN_OFFSET, event_len);
int2store(header + FLAGS_OFFSET, 0); int2store(header + FLAGS_OFFSET, 0);
int4store(header + LOG_SEQ_OFFSET, 0); int4store(header + LOG_SEQ_OFFSET, 0);
packet->append(header, sizeof(header)); packet->append(header, sizeof(header));
int8store(buf, 4); // tell slave to skip magic number
packet->append(buf, ROTATE_HEADER_LEN);
packet->append(p,ident_len); packet->append(p,ident_len);
if(my_net_write(net, (char*)packet->ptr(), packet->length())) if(my_net_write(net, (char*)packet->ptr(), packet->length()))
{ {
......
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