summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore28
-rw-r--r--client/mysqltest.c7
-rwxr-xr-xmysql-test/mysql-test-run233
-rw-r--r--mysql-test/r/3.23/rpl000007.result2
-rw-r--r--mysql-test/r/3.23/rpl000008.result2
-rw-r--r--mysql-test/r/3.23/rpl000009.result2
-rw-r--r--mysql-test/t/3.23/rpl000007-slave.opt1
-rw-r--r--mysql-test/t/3.23/rpl000007.test19
-rw-r--r--mysql-test/t/3.23/rpl000008-slave.opt1
-rw-r--r--mysql-test/t/3.23/rpl000008.test22
-rw-r--r--mysql-test/t/3.23/rpl000009-slave.opt1
-rw-r--r--mysql-test/t/3.23/rpl000009.test23
-rw-r--r--sql/mysql_priv.h5
-rw-r--r--sql/mysqld.cc32
-rw-r--r--sql/slave.cc58
-rw-r--r--sql/slave.h3
-rw-r--r--sql/sql_class.cc8
-rw-r--r--sql/sql_string.cc4
18 files changed, 379 insertions, 72 deletions
diff --git a/.bzrignore b/.bzrignore
index aaab084f751..17a5b8b1554 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -246,3 +246,31 @@ mysql-test/var/slave-data/test/x.frm
mysql-test/var/slave-data/test/x.MYD
mysql-test/var/slave-data/test/x.MYI
PENDING/2000-11-17.01
+BitKeeper/tmp/gone
+mysql-test/r/3.23/rpl
+mysql-test/r/3.23/rpl.reject
+mysql-test/var/lib/bar/bar.frm
+mysql-test/var/lib/bar/bar.MYD
+mysql-test/var/lib/bar/bar.MYI
+mysql-test/var/lib/foo/foo.frm
+mysql-test/var/lib/foo/foo.MYD
+mysql-test/var/lib/foo/foo.MYI
+mysql-test/var/lib/test/bar.frm
+mysql-test/var/lib/test/bar.MYD
+mysql-test/var/lib/test/bar.MYI
+mysql-test/var/lib/test/choo.frm
+mysql-test/var/lib/test/choo.MYD
+mysql-test/var/lib/test/choo.MYI
+mysql-test/var/slave-data/bar/bar.frm
+mysql-test/var/slave-data/bar/bar.MYD
+mysql-test/var/slave-data/bar/bar.MYI
+mysql-test/var/slave-data/foo/foo.frm
+mysql-test/var/slave-data/foo/foo.MYD
+mysql-test/var/slave-data/foo/foo.MYI
+mysql-test/var/slave-data/test/bar.frm
+mysql-test/var/slave-data/test/bar.MYD
+mysql-test/var/slave-data/test/bar.MYI
+mysql-test/var/slave-data/test/choo.frm
+mysql-test/var/slave-data/test/choo.MYD
+mysql-test/var/slave-data/test/choo.MYI
+mysql-test/var/tmp/README
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 47201c35ae9..90080f12e56 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -95,7 +95,7 @@ int open_file(const char* name)
if(*cur_file && ++cur_file == file_stack_end)
die("Source directives are nesting too deep");
if(!(*cur_file = fopen(name, "r")))
- die("Could not read '%s'\n", name);
+ die("Could not read '%s': errno %d\n", name, errno);
return 0;
}
@@ -593,8 +593,9 @@ void reject_dump(char* record_file, char* buf, int size)
FILE* freject;
p = reject_file;
- p = safe_str_append(p, record_file, size);
- p = safe_str_append(p, (char*)".reject", reject_file + size - p);
+ p = safe_str_append(p, record_file, sizeof(reject_file));
+ p = safe_str_append(p, (char*)".reject", reject_file - p +
+ sizeof(reject_file));
if(!(freject = fopen(reject_file, "w")))
die("Could not open reject file %s, error %d", reject_file, errno);
diff --git a/mysql-test/mysql-test-run b/mysql-test/mysql-test-run
index 7915cdee4c3..4354cd23fd9 100755
--- a/mysql-test/mysql-test-run
+++ b/mysql-test/mysql-test-run
@@ -86,8 +86,21 @@ MYSQL_TEST="$BASEDIR/client/mysqltest"
MYSQLADMIN="$BASEDIR/client/mysqladmin"
MYSQL_TEST="$MYSQL_TEST --socket=$MASTER_MYSOCK --database=$DB --user=$DBUSER --password=$DBPASSWD --silent"
INSTALL_DB="$MYBIN/mysql-test_install_db"
+GDB_MASTER_INIT=/tmp/gdbinit.master
+GDB_SLAVE_INIT=/tmp/gdbinit.slave
+
+if [ "$1" = "-gcov" ];
+then
+ DO_GCOV=1
+ shift 1
+fi
+
+if [ "$1" = "-gdb" ];
+then
+ DO_GDB=1
+ shift 1
+fi
-[ "$1" = "-gcov" ] && DO_GCOV=1
#++
# Terminal Modifications
@@ -131,6 +144,12 @@ echo_pass () {
return 0
}
+prompt_user ()
+{
+ echo $1
+ read
+}
+
echo_fail () {
$MOVE_TO_COL && $SETCOLOR_NORMAL
$ECHO -n "[ "
@@ -167,12 +186,12 @@ report_stats () {
else
$ECHO -n "Failed ${TOT_FAIL}/${TOT_TEST} tests, "
- xten=`$EXPR $TOT_PASS \* 10000` #
- raw=`$EXPR $xten / $TOT_TEST` # My God
- raw=`$PRINTF %.4d $raw` # This is such a ...
- whole=`$PRINTF %.2s $raw` # Narttu!!
- xwhole=`$EXPR $whole \* 100` # Hynda!!!
- deci=`$EXPR $raw - $xwhole` #
+ xten=`$EXPR $TOT_PASS \* 10000`
+ raw=`$EXPR $xten / $TOT_TEST`
+ raw=`$PRINTF %.4d $raw`
+ whole=`$PRINTF %.2s $raw`
+ xwhole=`$EXPR $whole \* 100`
+ deci=`$EXPR $raw - $xwhole`
$ECHO "${whole}.${deci}% successful."
fi
@@ -232,11 +251,11 @@ gcov_collect () {
$ECHO "gcov slave info in $GCOV_SLAVE_MSG, errors in $GCOV_SLAVE_ERR"
}
-mysql_start () {
-
+start_master()
+{
cd $BASEDIR # for gcov
#start master
- $MYSQLD --no-defaults --log-bin \
+ master_args="--no-defaults --log-bin \
--server-id=1 \
--basedir=$CWD \
--port=$MASTER_MYPORT \
@@ -245,13 +264,24 @@ mysql_start () {
--pid-file=$MASTER_MYPID \
--socket=$MASTER_MYSOCK \
--log=$MASTER_MYLOG \
- --language=english >> $MASTER_MYERR 2>&1 &
- #allow master to get setteled so slave can connect right away without error
- sleep 1
- #start slave
- $MYSQLD --no-defaults --server-id=2 \
+ --language=english $EXTRA_MASTER_OPT"
+ if [ x$DO_GDB = x1 ]
+ then
+ echo "set args $master_args" > $GDB_MASTER_INIT
+ xterm -title "Master" -e gdb -x $GDB_MASTER_INIT $MYSQLD &
+ prompt_user "Hit enter to continue after you've started the master"
+ else
+ $MYSQLD $master_args >> $MASTER_MYERR 2>&1 &
+ fi
+ MASTER_RUNNING=1
+}
+
+start_slave()
+{
+ [ -d $GCOV_SLAVE_SRC ] && cd $GCOV_SLAVE_SRC
+ slave_args="--no-defaults --server-id=2 \
--master-user=root \
- --master-connect-retry=5 \
+ --master-connect-retry=1 \
--master-host=127.0.0.1 \
--master-port=$MASTER_MYPORT \
--core-file \
@@ -261,21 +291,53 @@ mysql_start () {
--port=$SLAVE_MYPORT \
--socket=$SLAVE_MYSOCK \
--log=$SLAVE_MYLOG \
- --language=english >> $SLAVE_MYERR 2>&1 &
+ --language=english $EXTRA_SLAVE_OPT"
+ if [ x$DO_GDB = x1 ]
+ then
+ echo "set args $slave_args" > $GDB_SLAVE_INIT
+ xterm -title "Slave" -e gdb -x $GDB_SLAVE_INIT $MYSQLD &
+ prompt_user "Hit enter to continue after you've started the slave"
+ else
+ $MYSQLD $slave_args >> $SLAVE_MYERR 2>&1 &
+ fi
+ SLAVE_RUNNING=1
+}
+
+mysql_start () {
+ start_master
+ start_slave
cd $CWD
return 1
}
-mysql_stop () {
+stop_slave ()
+{
+ if [ x$SLAVE_RUNNING = x1 ]
+ then
+ $MYSQLADMIN --socket=$SLAVE_MYSOCK -u root shutdown
+ SLAVE_RUNNING=0
+ fi
+}
+stop_master ()
+{
+ if [ x$MASTER_RUNNING = x1 ]
+ then
$MYSQLADMIN --socket=$MASTER_MYSOCK -u root shutdown
- $MYSQLADMIN --socket=$SLAVE_MYSOCK -u root shutdown
+ MASTER_RUNNING=0
+ fi
+}
- return 1
+mysql_stop ()
+{
+ stop_master
+ stop_slave
+ return 1
}
mysql_restart () {
+ return 1
mysql_stop
res=$?
[ $res != 1 ] && echo_notok && error "Stopping mysqld"
@@ -293,35 +355,46 @@ mysql_loadstd () {
return 1
}
-[ "$DO_GCOV" -a ! -x "$GCOV" ] && error "No gcov found"
-
-[ "$DO_GCOV" ] && gcov_prepare
-
-
-mysql_install_db
-
-$SETCOLOR_NORMAL && $ECHO -n "Starting mysqld for Testing"
-mysql_start
-res=$?
-res=1
-[ $res != 1 ] && echo_notok && error "Starting mysqld"
-[ $res = 1 ] && echo_ok
-
-$SETCOLOR_NORMAL && $ECHO -n "Loading Standard Test Database"
-mysql_loadstd
-res=$?
-[ $res != 1 ] && echo_notok && error "Loading STD"
-[ $res = 1 ] && echo_ok
-
-$SETCOLOR_NORMAL && $ECHO -n "Starting Tests for MySQL $TESTVER Series"
-$SETCOLOR_SUCCESS && echo_ok
-
-$ECHO
-$ECHO " TEST USER SYSTEM ELAPSED RESULT"
-$ECHO $DASH72
+run_testcase ()
+{
+ tf=$1
+ tname=`$BASENAME $tf`
+ tname=`$ECHO $tname | $CUT -d . -f 1`
+ master_opt_file=$TESTDIR/$tname-master.opt
+ slave_opt_file=$TESTDIR/$tname-slave.opt
+
+
+ if [ -f $master_opt_file ] ;
+ then
+ EXTRA_MASTER_OPT=`cat $master_opt_file`
+ stop_master
+ start_master
+ else
+ if [ ! -z EXTRA_MASTER_OPT ] || [ x$MASTER_RUNNING != x1 ] ;
+ then
+ EXTRA_MASTER_OPT=""
+ stop_master
+ start_master
+ fi
+ fi
+
+ if [ -f $slave_opt_file ] ;
+ then
+ EXTRA_SLAVE_OPT=`cat $slave_opt_file`
+ stop_slave
+ start_slave
+ else
+ if [ ! -z EXTRA_SLAVE_OPT ] || [ x$SLAVE_RUNNING != x1 ] ;
+ then
+ EXTRA_SLAVE_OPT=""
+ stop_slave
+ start_slave
+
+ fi
+ fi
-for tf in $TESTDIR/*.$TESTSUFFIX
-do
+ cd $CWD
+
if [ -f $tf ] ; then
mytime=`$TIME -p $MYSQL_TEST < $tf 2> $TIMEFILE`
res=$?
@@ -339,9 +412,7 @@ do
fi
timestr="$USERT $SYST $REALT"
- tf=`$BASENAME $tf`
- tf=`$ECHO $tf | $CUT -d . -f 1`
- $SETCOLOR_NORMAL && $ECHO -n "$tf $timestr"
+ $SETCOLOR_NORMAL && $ECHO -n "$tname $timestr"
[ $res != 1 ] && pass_inc && echo_pass
[ $res = 1 ] && fail_inc && echo_fail
@@ -361,7 +432,50 @@ do
$ECHO
fi
fi
-done
+
+}
+
+
+[ "$DO_GCOV" -a ! -x "$GCOV" ] && error "No gcov found"
+
+[ "$DO_GCOV" ] && gcov_prepare
+
+
+mysql_install_db
+
+if [ -z $DO_GDB ]
+then
+ $SETCOLOR_NORMAL && $ECHO -n "Starting mysqld for Testing"
+ mysql_start
+ res=$?
+ res=1
+ [ $res != 1 ] && echo_notok && error "Starting mysqld"
+ [ $res = 1 ] && echo_ok
+fi
+
+#$SETCOLOR_NORMAL && $ECHO -n "Loading Standard Test Database"
+#mysql_loadstd
+#res=$?
+#[ $res != 1 ] && echo_notok && error "Loading STD"
+#[ $res = 1 ] && echo_ok
+
+$SETCOLOR_NORMAL && $ECHO -n "Starting Tests for MySQL $TESTVER Series"
+$SETCOLOR_SUCCESS && echo_ok
+
+$ECHO
+$ECHO " TEST USER SYSTEM ELAPSED RESULT"
+$ECHO $DASH72
+
+if [ -z $1 ] ;
+then
+ for tf in $TESTDIR/*.$TESTSUFFIX
+ do
+ run_testcase $tf
+ done
+else
+ tf=$TESTDIR/$1.$TESTSUFFIX
+ run_testcase $tf
+fi
$ECHO $DASH72
$ECHO
@@ -369,12 +483,15 @@ $SETCOLOR_NORMAL && $ECHO -n "Ending Tests for MySQL $TESTVER Series"
$SETCOLOR_SUCCESS && echo_ok
$RM $TIMEFILE
-$SETCOLOR_NORMAL && $ECHO -n "Shutdown mysqld"
-mysql_stop
-res=$?
-res=1
-[ $res != 1 ] && echo_notok && error "Shutdown mysqld"
-[ $res = 1 ] && echo_ok
+if [ -z $DO_GDB ] ;
+then
+ $SETCOLOR_NORMAL && $ECHO -n "Shutdown mysqld"
+ mysql_stop
+ res=$?
+ res=1
+ [ $res != 1 ] && echo_notok && error "Shutdown mysqld"
+ [ $res = 1 ] && echo_ok
+fi
$SETCOLOR_NORMAL
diff --git a/mysql-test/r/3.23/rpl000007.result b/mysql-test/r/3.23/rpl000007.result
new file mode 100644
index 00000000000..08f13272f2a
--- /dev/null
+++ b/mysql-test/r/3.23/rpl000007.result
@@ -0,0 +1,2 @@
+n m
+4 15
diff --git a/mysql-test/r/3.23/rpl000008.result b/mysql-test/r/3.23/rpl000008.result
new file mode 100644
index 00000000000..964ea8d84de
--- /dev/null
+++ b/mysql-test/r/3.23/rpl000008.result
@@ -0,0 +1,2 @@
+n m k
+4 15 55
diff --git a/mysql-test/r/3.23/rpl000009.result b/mysql-test/r/3.23/rpl000009.result
new file mode 100644
index 00000000000..08f13272f2a
--- /dev/null
+++ b/mysql-test/r/3.23/rpl000009.result
@@ -0,0 +1,2 @@
+n m
+4 15
diff --git a/mysql-test/t/3.23/rpl000007-slave.opt b/mysql-test/t/3.23/rpl000007-slave.opt
new file mode 100644
index 00000000000..9ff99337d1f
--- /dev/null
+++ b/mysql-test/t/3.23/rpl000007-slave.opt
@@ -0,0 +1 @@
+--replicate-do-table=test.bar
diff --git a/mysql-test/t/3.23/rpl000007.test b/mysql-test/t/3.23/rpl000007.test
new file mode 100644
index 00000000000..5b9ef12bddd
--- /dev/null
+++ b/mysql-test/t/3.23/rpl000007.test
@@ -0,0 +1,19 @@
+#this one assumes we are ignoring updates on table foo, but doing
+#the ones on bar
+source t/include/master-slave.inc;
+connection slave;
+use test;
+drop table if exists foo;
+create table foo (n int);
+insert into foo values(4);
+connection master;
+use test;
+drop table if exists foo;
+create table foo (n int);
+insert into foo values(5);
+drop table if exists bar;
+create table bar (m int);
+insert into bar values(15);
+connection slave;
+sleep 1;
+@r/3.23/rpl000007.result select foo.n,bar.m from foo,bar;
diff --git a/mysql-test/t/3.23/rpl000008-slave.opt b/mysql-test/t/3.23/rpl000008-slave.opt
new file mode 100644
index 00000000000..79b3bf6174b
--- /dev/null
+++ b/mysql-test/t/3.23/rpl000008-slave.opt
@@ -0,0 +1 @@
+--replicate-ignore-table=test.foo
diff --git a/mysql-test/t/3.23/rpl000008.test b/mysql-test/t/3.23/rpl000008.test
new file mode 100644
index 00000000000..58819c2835f
--- /dev/null
+++ b/mysql-test/t/3.23/rpl000008.test
@@ -0,0 +1,22 @@
+#this one assumes we are ignoring updates on table foo, but doing
+#the ones on all other tables
+source t/include/master-slave.inc;
+connection slave;
+use test;
+drop table if exists foo;
+create table foo (n int);
+insert into foo values(4);
+connection master;
+use test;
+drop table if exists foo;
+create table foo (n int);
+insert into foo values(5);
+drop table if exists bar;
+create table bar (m int);
+insert into bar values(15);
+drop table if exists choo;
+create table choo (k int);
+insert into choo values(55);
+connection slave;
+sleep 1;
+@r/3.23/rpl000008.result select foo.n,bar.m,choo.k from foo,bar,choo;
diff --git a/mysql-test/t/3.23/rpl000009-slave.opt b/mysql-test/t/3.23/rpl000009-slave.opt
new file mode 100644
index 00000000000..245e310c5d8
--- /dev/null
+++ b/mysql-test/t/3.23/rpl000009-slave.opt
@@ -0,0 +1 @@
+--replicate-wild-do-table=bar.%
diff --git a/mysql-test/t/3.23/rpl000009.test b/mysql-test/t/3.23/rpl000009.test
new file mode 100644
index 00000000000..ae491e1ab98
--- /dev/null
+++ b/mysql-test/t/3.23/rpl000009.test
@@ -0,0 +1,23 @@
+#this one assumes we are ignoring updates on tables in database foo, but doing
+#the ones in database bar
+source t/include/master-slave.inc;
+connection master;
+drop database if exists foo;
+create database foo;
+drop database if exists bar;
+create database bar;
+connection slave;
+sleep 1;
+drop table if exists foo.foo;
+create table foo.foo (n int);
+insert into foo.foo values(4);
+connection master;
+drop table if exists foo.foo;
+create table foo.foo (n int);
+insert into foo.foo values(5);
+drop table if exists bar.bar;
+create table bar.bar (m int);
+insert into bar.bar values(15);
+connection slave;
+sleep 1;
+@r/3.23/rpl000009.result select foo.foo.n,bar.bar.m from foo.foo,bar.bar;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 0fe3b725e34..eca9eca56c4 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -583,6 +583,11 @@ bool check_column_name(const char *name);
bool check_table_name(const char *name, uint length);
char *get_field(MEM_ROOT *mem,TABLE *table,uint fieldnr);
int wild_case_compare(const char *str,const char *wildstr);
+int wild_compare(const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,char escape);
+int wild_case_compare(const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,char escape);
+
/* from hostname.cc */
struct in_addr;
my_string ip_to_hostname(struct in_addr *in,uint *errors);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index bbacf46dd01..8bb4cded39e 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2231,7 +2231,7 @@ enum options {
OPT_REPLICATE_REWRITE_DB, OPT_SERVER_ID, OPT_SKIP_SLAVE_START,
OPT_SKIP_INNOBASE,OPT_SAFEMALLOC_MEM_LIMIT,
OPT_REPLICATE_DO_TABLE, OPT_REPLICATE_IGNORE_TABLE,
- OPT_REPL_WILD_DO_TABLE, OPT_REPL_WILD_IGNORE_TABLE
+ OPT_REPLICATE_WILD_DO_TABLE, OPT_REPLICATE_WILD_IGNORE_TABLE
};
static struct option long_options[] = {
@@ -2302,13 +2302,13 @@ static struct option long_options[] = {
{"replicate-do-table", required_argument, 0,
(int) OPT_REPLICATE_DO_TABLE},
{"replicate-wild-do-table", required_argument, 0,
- (int) OPT_REPL_WILD_DO_TABLE},
+ (int) OPT_REPLICATE_WILD_DO_TABLE},
{"replicate-ignore-db", required_argument, 0,
(int) OPT_REPLICATE_IGNORE_DB},
{"replicate-ignore-table", required_argument, 0,
(int) OPT_REPLICATE_IGNORE_TABLE},
{"replicate-wild-ignore-table", required_argument, 0,
- (int) OPT_REPL_WILD_IGNORE_TABLE},
+ (int) OPT_REPLICATE_WILD_IGNORE_TABLE},
{"replicate-rewrite-db", required_argument, 0,
(int) OPT_REPLICATE_REWRITE_DB},
{"safe-mode", no_argument, 0, (int) OPT_SAFE},
@@ -2961,6 +2961,32 @@ static void get_options(int argc,char **argv)
table_rules_on = 1;
break;
}
+ case (int)OPT_REPLICATE_WILD_DO_TABLE:
+ {
+ if(!wild_do_table_inited)
+ init_table_rule_array(&replicate_wild_do_table,
+ &wild_do_table_inited);
+ if(add_wild_table_rule(&replicate_wild_do_table, optarg))
+ {
+ fprintf(stderr, "could not add do table rule '%s'\n", optarg);
+ exit(1);
+ }
+ table_rules_on = 1;
+ break;
+ }
+ case (int)OPT_REPLICATE_WILD_IGNORE_TABLE:
+ {
+ if(!wild_ignore_table_inited)
+ init_table_rule_array(&replicate_wild_ignore_table,
+ &wild_ignore_table_inited);
+ if(add_wild_table_rule(&replicate_wild_ignore_table, optarg))
+ {
+ fprintf(stderr, "could not add do table rule '%s'\n", optarg);
+ exit(1);
+ }
+ table_rules_on = 1;
+ break;
+ }
case (int)OPT_REPLICATE_IGNORE_TABLE:
{
if(!ignore_table_inited)
diff --git a/sql/slave.cc b/sql/slave.cc
index 181a6a9fc00..1e277134641 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -26,10 +26,13 @@ bool slave_running = 0;
pthread_t slave_real_id;
MASTER_INFO glob_mi;
HASH replicate_do_table, replicate_ignore_table;
+DYNAMIC_ARRAY replicate_wild_do_table, replicate_wild_ignore_table;
bool do_table_inited = 0, ignore_table_inited = 0;
+bool wild_do_table_inited = 0, wild_ignore_table_inited = 0;
bool table_rules_on = 0;
+
static inline void skip_load_data_infile(NET* net);
static inline bool slave_killed(THD* thd);
static int init_slave_thread(THD* thd);
@@ -61,6 +64,30 @@ void init_table_rule_hash(HASH* h, bool* h_inited)
*h_inited = 1;
}
+void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited)
+{
+ init_dynamic_array(a, sizeof(TABLE_RULE_ENT*), TABLE_RULE_ARR_SIZE,
+ TABLE_RULE_ARR_SIZE);
+ *a_inited = 1;
+}
+
+static TABLE_RULE_ENT* find_wild(DYNAMIC_ARRAY *a, const char* key, int len)
+{
+ uint i;
+ const char* key_end = key + len;
+
+ for(i = 0; i < a->elements; i++)
+ {
+ TABLE_RULE_ENT* e ;
+ get_dynamic(a, (gptr)&e, i);
+ if(!wild_case_compare(key, key_end, (const char*)e->db,
+ (const char*)(e->db + e->key_len),'\\'))
+ return e;
+ }
+
+ return 0;
+}
+
int tables_ok(THD* thd, TABLE_LIST* tables)
{
for(; tables; tables = tables->next)
@@ -82,9 +109,14 @@ int tables_ok(THD* thd, TABLE_LIST* tables)
if(hash_search(&replicate_ignore_table, (byte*) hash_key, len))
return 0;
}
+ if(wild_do_table_inited && find_wild(&replicate_wild_do_table,
+ hash_key, len)) return 1;
+ if(wild_ignore_table_inited && find_wild(&replicate_wild_ignore_table,
+ hash_key, len)) return 0;
}
- return !do_table_inited; // if no explicit rule found
+ return !do_table_inited && !wild_do_table_inited;
+ // if no explicit rule found
// and there was a do list, do not replicate. If there was
// no do list, go ahead
}
@@ -107,6 +139,24 @@ int add_table_rule(HASH* h, const char* table_spec)
return 0;
}
+int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec)
+{
+ char* dot = strchr(table_spec, '.');
+ if(!dot) return 1;
+ uint len = (uint)strlen(table_spec);
+ if(!len) return 1;
+ TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(sizeof(TABLE_RULE_ENT)
+ + len, MYF(MY_WME));
+ if(!e) return 1;
+ e->db = (char*)e + sizeof(TABLE_RULE_ENT);
+ e->tbl_name = e->db + (dot - table_spec) + 1;
+ e->key_len = len;
+ memcpy(e->db, table_spec, len);
+ insert_dynamic(a, (gptr)&e);
+ return 0;
+}
+
+
static inline bool slave_killed(THD* thd)
{
return abort_slave || abort_loop || thd->killed;
@@ -957,7 +1007,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused)))
goto err;
thd->proc_info = "waiting to reconnect after a failed dump request";
- vio_close(mysql->net.vio);
+ if(mysql->net.vio)
+ vio_close(mysql->net.vio);
safe_sleep(thd, glob_mi.connect_retry);
if(slave_killed(thd))
goto err;
@@ -983,7 +1034,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused)))
if (event_len == packet_error)
{
thd->proc_info = "waiting to reconnect after a failed read";
- vio_close(mysql->net.vio);
+ if(mysql->net.vio)
+ vio_close(mysql->net.vio);
safe_sleep(thd, glob_mi.connect_retry);
if(slave_killed(thd))
goto err;
diff --git a/sql/slave.h b/sql/slave.h
index 5df90cbf55b..47cfa77a8e4 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -56,6 +56,7 @@ typedef struct st_table_rule_ent
} TABLE_RULE_ENT;
#define TABLE_RULE_HASH_SIZE 16
+#define TABLE_RULE_ARR_SIZE 16
int flush_master_info(MASTER_INFO* mi);
@@ -76,7 +77,9 @@ int db_ok(const char* db, I_List<i_string> &do_list,
// do and ignore lists - used in replication
int add_table_rule(HASH* h, const char* table_spec);
+int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec);
void init_table_rule_hash(HASH* h, bool* h_inited);
+void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited);
int init_master_info(MASTER_INFO* mi);
extern bool opt_log_slave_updates ;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 4ccf3481763..c7d50ee182e 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -74,13 +74,15 @@ static void free_var(user_var_entry *entry)
** Thread specific functions
****************************************************************************/
-THD::THD()
+THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
+ insert_id_used(0),
+ bootstrap(0),in_lock_tables(0),
+ global_read_lock(0)
{
host=user=db=query=ip=0;
proc_info="login";
locked=killed=count_cuted_fields=some_tables_deleted=no_errors=password=
- fatal_error=query_start_used=last_insert_id_used=insert_id_used=
- user_time=bootstrap=in_lock_tables=global_read_lock=0;
+ query_start_used=0;
query_length=col_access=0;
query_error=0;
server_id = ::server_id;
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 4b9ebef21f1..174d07d8ec4 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -541,7 +541,7 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
#define likeconv(A) (uchar) my_sort_order[(uchar) (A)]
#endif
-static int wild_case_compare(const char *str,const char *str_end,
+int wild_case_compare(const char *str,const char *str_end,
const char *wildstr,const char *wildend,
char escape)
{
@@ -676,7 +676,7 @@ int wild_case_compare(String &match,String &wild, char escape)
** The following is used when using LIKE on binary strings
*/
-static int wild_compare(const char *str,const char *str_end,
+int wild_compare(const char *str,const char *str_end,
const char *wildstr,const char *wildend,char escape)
{
int result= -1; // Not found, using wildcards