Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
efb07750
Commit
efb07750
authored
Mar 21, 2005
by
lars@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
f1ce374a
c6d85289
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
743 additions
and
504 deletions
+743
-504
sql/Makefile.am
sql/Makefile.am
+3
-2
sql/log.cc
sql/log.cc
+4
-2
sql/log_event.cc
sql/log_event.cc
+6
-5
sql/mysql_priv.h
sql/mysql_priv.h
+0
-1
sql/mysqld.cc
sql/mysqld.cc
+22
-46
sql/repl_failsafe.cc
sql/repl_failsafe.cc
+5
-4
sql/rpl_filter.cc
sql/rpl_filter.cc
+539
-0
sql/rpl_filter.h
sql/rpl_filter.h
+110
-0
sql/slave.cc
sql/slave.cc
+11
-379
sql/slave.h
sql/slave.h
+5
-34
sql/sql_acl.cc
sql/sql_acl.cc
+10
-13
sql/sql_acl.h
sql/sql_acl.h
+3
-0
sql/sql_class.h
sql/sql_class.h
+6
-5
sql/sql_parse.cc
sql/sql_parse.cc
+13
-10
sql/sql_repl.cc
sql/sql_repl.cc
+3
-2
sql/sql_repl.h
sql/sql_repl.h
+3
-1
No files found.
sql/Makefile.am
View file @
efb07750
...
...
@@ -55,7 +55,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
ha_ndbcluster.h opt_range.h protocol.h
\
sql_select.h structs.h table.h sql_udf.h hash_filo.h
\
lex.h lex_symbol.h sql_acl.h sql_crypt.h
\
log_event.h sql_repl.h slave.h
\
log_event.h sql_repl.h slave.h
rpl_filter.h
\
stacktrace.h sql_sort.h sql_cache.h set_var.h
\
spatial.h gstream.h client_settings.h tzfile.h
\
tztime.h my_decimal.h
\
...
...
@@ -90,7 +90,8 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc
\
sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc
\
sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc
\
slave.cc sql_repl.cc sql_union.cc sql_derived.cc
\
slave.cc sql_repl.cc rpl_filter.cc
\
sql_union.cc sql_derived.cc
\
client.c sql_client.cc mini_client_errors.c pack.c
\
stacktrace.c repl_failsafe.h repl_failsafe.cc
\
sql_olap.cc sql_view.cc
\
...
...
sql/log.cc
View file @
efb07750
...
...
@@ -24,6 +24,7 @@
#include "mysql_priv.h"
#include "sql_repl.h"
#include "rpl_filter.h"
#include <my_dir.h>
#include <stdarg.h>
...
...
@@ -1571,10 +1572,11 @@ bool MYSQL_LOG::write(Log_event *event_info)
binlog_[wild_]{do|ignore}_table?" (WL#1049)"
*/
if
((
thd
&&
!
(
thd
->
options
&
OPTION_BIN_LOG
))
||
(
!
db_ok
(
local_db
,
binlog_do_db
,
binlog_ignore
_db
)))
(
!
binlog_filter
->
db_ok
(
local
_db
)))
{
VOID
(
pthread_mutex_unlock
(
&
LOCK_log
));
DBUG_PRINT
(
"error"
,(
"!db_ok('%s')"
,
local_db
));
DBUG_PRINT
(
"info"
,(
"db_ok('%s')==%d"
,
local_db
,
binlog_filter
->
db_ok
(
local_db
)));
DBUG_RETURN
(
0
);
}
#endif
/* HAVE_REPLICATION */
...
...
sql/log_event.cc
View file @
efb07750
...
...
@@ -21,6 +21,7 @@
#endif
#include "mysql_priv.h"
#include "slave.h"
#include "rpl_filter.h"
#include <my_dir.h>
#endif
/* MYSQL_CLIENT */
...
...
@@ -1445,7 +1446,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli, const char *query
*/
thd
->
catalog
=
(
char
*
)
catalog
;
thd
->
db_length
=
db_len
;
thd
->
db
=
(
char
*
)
rewrite_db
(
db
,
&
thd
->
db_length
);
thd
->
db
=
(
char
*
)
rpl_filter
->
get_
rewrite_db
(
db
,
&
thd
->
db_length
);
thd
->
variables
.
auto_increment_increment
=
auto_increment_increment
;
thd
->
variables
.
auto_increment_offset
=
auto_increment_offset
;
...
...
@@ -1464,7 +1465,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli, const char *query
clear_all_errors
(
thd
,
rli
);
if
(
db_ok
(
thd
->
db
,
replicate_do_db
,
replicate_ignore_
db
))
if
(
rpl_filter
->
db_ok
(
thd
->
db
))
{
thd
->
set_time
((
time_t
)
when
);
thd
->
query_length
=
q_len_arg
;
...
...
@@ -2569,7 +2570,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
bool
use_rli_only_for_errors
)
{
thd
->
db_length
=
db_len
;
thd
->
db
=
(
char
*
)
rewrite_db
(
db
,
&
thd
->
db_length
);
thd
->
db
=
(
char
*
)
rpl_filter
->
get_
rewrite_db
(
db
,
&
thd
->
db_length
);
DBUG_ASSERT
(
thd
->
query
==
0
);
thd
->
query_length
=
0
;
// Should not be needed
thd
->
query_error
=
0
;
...
...
@@ -2598,7 +2599,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
al. Another way is do the filtering in the I/O thread (more efficient: no
disk writes at all).
*/
if
(
db_ok
(
thd
->
db
,
replicate_do_db
,
replicate_ignore_
db
))
if
(
rpl_filter
->
db_ok
(
thd
->
db
))
{
thd
->
set_time
((
time_t
)
when
);
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
...
...
@@ -2620,7 +2621,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
tables
.
updating
=
1
;
// the table will be opened in mysql_load
if
(
table_rules_on
&&
!
tables_ok
(
thd
,
&
tables
))
if
(
rpl_filter
->
is_on
()
&&
!
rpl_filter
->
tables_ok
(
thd
->
db
,
&
tables
))
{
// TODO: this is a bug - this needs to be moved to the I/O thread
if
(
net
)
...
...
sql/mysql_priv.h
View file @
efb07750
...
...
@@ -1128,7 +1128,6 @@ extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
extern
String
null_string
;
extern
HASH
open_cache
;
extern
TABLE
*
unused_tables
;
extern
I_List
<
i_string
>
binlog_do_db
,
binlog_ignore_db
;
extern
const
char
*
any_db
;
extern
struct
my_option
my_long_options
[];
...
...
sql/mysqld.cc
View file @
efb07750
...
...
@@ -19,6 +19,7 @@
#include <my_dir.h>
#include "slave.h"
#include "sql_repl.h"
#include "rpl_filter.h"
#include "repl_failsafe.h"
#include "stacktrace.h"
#include "mysqld_suffix.h"
...
...
@@ -397,12 +398,10 @@ Le_creator le_creator;
FILE
*
bootstrap_file
;
int
bootstrap_error
;
I_List
<
i_string_pair
>
replicate_rewrite_db
;
I_List
<
i_string
>
replicate_do_db
,
replicate_ignore_db
;
// allow the user to tell us which db to replicate and which to ignore
I_List
<
i_string
>
binlog_do_db
,
binlog_ignore_db
;
I_List
<
THD
>
threads
,
thread_cache
;
I_List
<
NAMED_LIST
>
key_caches
;
Rpl_filter
*
rpl_filter
;
Rpl_filter
*
binlog_filter
;
struct
system_variables
global_system_variables
;
struct
system_variables
max_system_variables
;
...
...
@@ -1013,12 +1012,9 @@ void clean_up(bool print_message)
free_max_user_conn
();
#ifdef HAVE_REPLICATION
end_slave_list
();
free_list
(
&
replicate_do_db
);
free_list
(
&
replicate_ignore_db
);
free_list
(
&
binlog_do_db
);
free_list
(
&
binlog_ignore_db
);
free_list
(
&
replicate_rewrite_db
);
#endif
delete
binlog_filter
;
delete
rpl_filter
;
#ifdef HAVE_OPENSSL
if
(
ssl_acceptor_fd
)
my_free
((
gptr
)
ssl_acceptor_fd
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
@@ -2970,9 +2966,16 @@ int win_main(int argc, char **argv)
int
main
(
int
argc
,
char
**
argv
)
#endif
{
DEBUGGER_OFF
;
rpl_filter
=
new
Rpl_filter
;
binlog_filter
=
new
Rpl_filter
;
if
(
!
rpl_filter
||
!
binlog_filter
)
{
sql_perror
(
"Could not allocate replication and binlog filters"
);
exit
(
1
);
}
MY_INIT
(
argv
[
0
]);
// init my_sys library & pthreads
#ifdef _CUSTOMSTARTUPCONFIG_
...
...
@@ -3309,7 +3312,6 @@ default_service_handling(char **argv,
int
main
(
int
argc
,
char
**
argv
)
{
/* When several instances are running on the same machine, we
need to have an unique named hEventShudown through the
application PID e.g.: MySQLShutdown1890; MySQLShutdown2342
...
...
@@ -5882,13 +5884,6 @@ static void mysql_init_variables(void)
exit
(
1
);
multi_keycache_init
();
/* set key_cache_hash.default_value = dflt_key_cache */
/* Initialize structures that is used when processing options */
replicate_rewrite_db
.
empty
();
replicate_do_db
.
empty
();
replicate_ignore_db
.
empty
();
binlog_do_db
.
empty
();
binlog_ignore_db
.
empty
();
/* Set directory paths */
strmake
(
language
,
LANGUAGE
,
sizeof
(
language
)
-
1
);
strmake
(
mysql_real_data_home
,
get_relative_path
(
DATADIR
),
...
...
@@ -6143,14 +6138,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
}
case
(
int
)
OPT_REPLICATE_IGNORE_DB
:
{
i_string
*
db
=
new
i_string
(
argument
);
replicate_ignore_db
.
push_back
(
db
);
rpl_filter
->
add_ignore_db
(
argument
);
break
;
}
case
(
int
)
OPT_REPLICATE_DO_DB
:
{
i_string
*
db
=
new
i_string
(
argument
);
replicate_do_db
.
push_back
(
db
);
rpl_filter
->
add_do_db
(
argument
);
break
;
}
case
(
int
)
OPT_REPLICATE_REWRITE_DB
:
...
...
@@ -6183,71 +6176,54 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
exit
(
1
);
}
i_string_pair
*
db_pair
=
new
i_string_pair
(
key
,
val
);
replicate_rewrite_db
.
push_back
(
db_pair
);
rpl_filter
->
add_db_rewrite
(
key
,
val
);
break
;
}
case
(
int
)
OPT_BINLOG_IGNORE_DB
:
{
i_string
*
db
=
new
i_string
(
argument
);
binlog_ignore_db
.
push_back
(
db
);
binlog_filter
->
add_ignore_db
(
argument
);
break
;
}
case
(
int
)
OPT_BINLOG_DO_DB
:
{
i_string
*
db
=
new
i_string
(
argument
);
binlog_do_db
.
push_back
(
db
);
binlog_filter
->
add_do_db
(
argument
);
break
;
}
case
(
int
)
OPT_REPLICATE_DO_TABLE
:
{
if
(
!
do_table_inited
)
init_table_rule_hash
(
&
replicate_do_table
,
&
do_table_inited
);
if
(
add_table_rule
(
&
replicate_do_table
,
argument
))
if
(
rpl_filter
->
add_do_table
(
argument
))
{
fprintf
(
stderr
,
"Could not add do table rule '%s'!
\n
"
,
argument
);
exit
(
1
);
}
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
,
argument
))
if
(
rpl_filter
->
add_wild_do_table
(
argument
))
{
fprintf
(
stderr
,
"Could not add do table rule '%s'!
\n
"
,
argument
);
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
,
argument
))
if
(
rpl_filter
->
add_wild_ignore_table
(
argument
))
{
fprintf
(
stderr
,
"Could not add ignore table rule '%s'!
\n
"
,
argument
);
exit
(
1
);
}
table_rules_on
=
1
;
break
;
}
case
(
int
)
OPT_REPLICATE_IGNORE_TABLE
:
{
if
(
!
ignore_table_inited
)
init_table_rule_hash
(
&
replicate_ignore_table
,
&
ignore_table_inited
);
if
(
add_table_rule
(
&
replicate_ignore_table
,
argument
))
if
(
rpl_filter
->
add_ignore_table
(
argument
))
{
fprintf
(
stderr
,
"Could not add ignore table rule '%s'!
\n
"
,
argument
);
exit
(
1
);
}
table_rules_on
=
1
;
break
;
}
#endif
/* HAVE_REPLICATION */
...
...
sql/repl_failsafe.cc
View file @
efb07750
...
...
@@ -20,6 +20,7 @@
#include "repl_failsafe.h"
#include "sql_repl.h"
#include "slave.h"
#include "rpl_filter.h"
#include "log_event.h"
#include <mysql.h>
...
...
@@ -735,14 +736,14 @@ static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db,
TABLE_LIST
table
;
const
char
*
table_name
=
row
[
0
];
int
error
;
if
(
table_rules_on
)
if
(
rpl_filter
->
is_on
()
)
{
bzero
((
char
*
)
&
table
,
sizeof
(
table
));
//just for safe
table
.
db
=
(
char
*
)
db
;
table
.
table_name
=
(
char
*
)
table_name
;
table
.
updating
=
1
;
if
(
!
tables_ok
(
thd
,
&
table
))
if
(
!
rpl_filter
->
tables_ok
(
thd
->
db
,
&
table
))
continue
;
}
/* download master's table and overwrite slave's table */
...
...
@@ -860,8 +861,8 @@ bool load_master_data(THD* thd)
data from master
*/
if
(
!
db_ok
(
db
,
replicate_do_db
,
replicate_ignore_db
)
||
!
db_ok_with_wild_table
(
db
)
||
if
(
!
rpl_filter
->
db_ok
(
db
)
||
!
rpl_filter
->
db_ok_with_wild_table
(
db
)
||
!
strcmp
(
db
,
"mysql"
))
{
*
cur_table_res
=
0
;
...
...
sql/rpl_filter.cc
0 → 100644
View file @
efb07750
This diff is collapsed.
Click to expand it.
sql/rpl_filter.h
0 → 100644
View file @
efb07750
/* Copyright (C) 2000-2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef __RPL_FILTER_H__
#define __RPL_FILTER_H__
#include "mysql.h"
#include "my_list.h"
typedef
struct
st_table_rule_ent
{
char
*
db
;
char
*
tbl_name
;
uint
key_len
;
}
TABLE_RULE_ENT
;
/*
Rpl_filter
Inclusion and exclusion rules of tables and databases.
Also handles rewrites of db.
Used for replication and binlogging.
*/
class
Rpl_filter
{
public:
Rpl_filter
();
~
Rpl_filter
();
Rpl_filter
(
Rpl_filter
const
&
);
Rpl_filter
&
operator
=
(
Rpl_filter
const
&
);
/* Checks - returns true if ok to replicate/log */
bool
tables_ok
(
const
char
*
db
,
TABLE_LIST
*
tables
);
bool
db_ok
(
const
char
*
db
);
bool
db_ok_with_wild_table
(
const
char
*
db
);
bool
is_on
();
/* Setters - add filtering rules */
int
add_do_table
(
const
char
*
table_spec
);
int
add_ignore_table
(
const
char
*
table_spec
);
int
add_wild_do_table
(
const
char
*
table_spec
);
int
add_wild_ignore_table
(
const
char
*
table_spec
);
void
add_do_db
(
const
char
*
db_spec
);
void
add_ignore_db
(
const
char
*
db_spec
);
void
add_db_rewrite
(
const
char
*
from_db
,
const
char
*
to_db
);
/* Getters - to get information about current rules */
void
get_do_table
(
String
*
str
);
void
get_ignore_table
(
String
*
str
);
void
get_wild_do_table
(
String
*
str
);
void
get_wild_ignore_table
(
String
*
str
);
const
char
*
get_rewrite_db
(
const
char
*
db
,
uint32
*
new_len
);
I_List
<
i_string
>*
get_do_db
();
I_List
<
i_string
>*
get_ignore_db
();
private:
bool
table_rules_on
;
void
init_table_rule_hash
(
HASH
*
h
,
bool
*
h_inited
);
void
init_table_rule_array
(
DYNAMIC_ARRAY
*
a
,
bool
*
a_inited
);
int
add_table_rule
(
HASH
*
h
,
const
char
*
table_spec
);
int
add_wild_table_rule
(
DYNAMIC_ARRAY
*
a
,
const
char
*
table_spec
);
void
free_string_array
(
DYNAMIC_ARRAY
*
a
);
void
table_rule_ent_hash_to_str
(
String
*
s
,
HASH
*
h
);
void
table_rule_ent_dynamic_array_to_str
(
String
*
s
,
DYNAMIC_ARRAY
*
a
);
TABLE_RULE_ENT
*
find_wild
(
DYNAMIC_ARRAY
*
a
,
const
char
*
key
,
int
len
);
HASH
do_table
;
HASH
ignore_table
;
DYNAMIC_ARRAY
wild_do_table
;
DYNAMIC_ARRAY
wild_ignore_table
;
bool
do_table_inited
;
bool
ignore_table_inited
;
bool
wild_do_table_inited
;
bool
wild_ignore_table_inited
;
I_List
<
i_string
>
do_db
;
I_List
<
i_string
>
ignore_db
;
I_List
<
i_string_pair
>
rewrite_db
;
};
#endif // __TABLE_FILTER_H__
sql/slave.cc
View file @
efb07750
This diff is collapsed.
Click to expand it.
sql/slave.h
View file @
efb07750
...
...
@@ -21,10 +21,14 @@
#include "mysql.h"
#include "my_list.h"
#include "rpl_filter.h"
#define SLAVE_NET_TIMEOUT 3600
#define MAX_SLAVE_ERRMSG 1024
#define MAX_SLAVE_ERROR 2000
extern
Rpl_filter
*
rpl_filter
;
/*****************************************************************************
MySQL Replication
...
...
@@ -454,15 +458,6 @@ typedef struct st_master_info
int
queue_event
(
MASTER_INFO
*
mi
,
const
char
*
buf
,
ulong
event_len
);
typedef
struct
st_table_rule_ent
{
char
*
db
;
char
*
tbl_name
;
uint
key_len
;
}
TABLE_RULE_ENT
;
#define TABLE_RULE_HASH_SIZE 16
#define TABLE_RULE_ARR_SIZE 16
#define MAX_SLAVE_ERRMSG 1024
#define RPL_LOG_NAME (rli->group_master_log_name[0] ? rli->group_master_log_name :\
...
...
@@ -516,27 +511,9 @@ int mysql_table_dump(THD* thd, const char* db,
int
fetch_master_table
(
THD
*
thd
,
const
char
*
db_name
,
const
char
*
table_name
,
MASTER_INFO
*
mi
,
MYSQL
*
mysql
,
bool
overwrite
);
void
table_rule_ent_hash_to_str
(
String
*
s
,
HASH
*
h
);
void
table_rule_ent_dynamic_array_to_str
(
String
*
s
,
DYNAMIC_ARRAY
*
a
);
bool
show_master_info
(
THD
*
thd
,
MASTER_INFO
*
mi
);
bool
show_binlog_info
(
THD
*
thd
);
/* See if the query uses any tables that should not be replicated */
bool
tables_ok
(
THD
*
thd
,
TABLE_LIST
*
tables
);
/*
Check to see if the database is ok to operate on with respect to the
do and ignore lists - used in replication
*/
int
db_ok
(
const
char
*
db
,
I_List
<
i_string
>
&
do_list
,
I_List
<
i_string
>
&
ignore_list
);
int
db_ok_with_wild_table
(
const
char
*
db
);
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
);
const
char
*
rewrite_db
(
const
char
*
db
,
uint32
*
new_db_len
);
const
char
*
print_slave_db_safe
(
const
char
*
db
);
int
check_expected_error
(
THD
*
thd
,
RELAY_LOG_INFO
*
rli
,
int
error_code
);
void
skip_load_data_infile
(
NET
*
net
);
...
...
@@ -569,11 +546,7 @@ extern "C" pthread_handler_decl(handle_slave_sql,arg);
extern
bool
volatile
abort_loop
;
extern
MASTER_INFO
main_mi
,
*
active_mi
;
/* active_mi for multi-master */
extern
LIST
master_list
;
extern
HASH
replicate_do_table
,
replicate_ignore_table
;
extern
DYNAMIC_ARRAY
replicate_wild_do_table
,
replicate_wild_ignore_table
;
extern
bool
do_table_inited
,
ignore_table_inited
,
wild_do_table_inited
,
wild_ignore_table_inited
;
extern
bool
table_rules_on
,
replicate_same_server_id
;
extern
bool
replicate_same_server_id
;
extern
int
disconnect_slave_event_count
,
abort_slave_event_count
;
...
...
@@ -587,8 +560,6 @@ extern my_bool master_ssl;
extern
my_string
master_ssl_ca
,
master_ssl_capath
,
master_ssl_cert
,
master_ssl_cipher
,
master_ssl_key
;
extern
I_List
<
i_string
>
replicate_do_db
,
replicate_ignore_db
;
extern
I_List
<
i_string_pair
>
replicate_rewrite_db
;
extern
I_List
<
THD
>
threads
;
#endif
...
...
sql/sql_acl.cc
View file @
efb07750
...
...
@@ -27,9 +27,6 @@
#include "mysql_priv.h"
#include "hash_filo.h"
#ifdef HAVE_REPLICATION
#include "sql_repl.h" //for tables_ok()
#endif
#include <m_ctype.h>
#include <stdarg.h>
#include "sp_head.h"
...
...
@@ -1499,7 +1496,7 @@ static bool update_user_table(THD *thd, const char *host, const char *user,
GRANT and REVOKE are applied the slave in/exclusion rules as they are
some kind of updates to the mysql.% tables.
*/
if
(
thd
->
slave_thread
&&
table_rules_on
)
if
(
thd
->
slave_thread
&&
rpl_filter
->
is_on
()
)
{
/*
The tables must be marked "updating" so that tables_ok() takes them into
...
...
@@ -1507,7 +1504,7 @@ static bool update_user_table(THD *thd, const char *host, const char *user,
*/
tables
.
updating
=
1
;
/* Thanks to bzero, tables.next==0 */
if
(
!
tables_ok
(
0
,
&
tables
))
if
(
!
rpl_filter
->
tables_ok
(
0
,
&
tables
))
DBUG_RETURN
(
0
);
}
#endif
...
...
@@ -2670,14 +2667,14 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list,
GRANT and REVOKE are applied the slave in/exclusion rules as they are
some kind of updates to the mysql.% tables.
*/
if
(
thd
->
slave_thread
&&
table_rules_on
)
if
(
thd
->
slave_thread
&&
rpl_filter
->
is_on
()
)
{
/*
The tables must be marked "updating" so that tables_ok() takes them into
account in tests.
*/
tables
[
0
].
updating
=
tables
[
1
].
updating
=
tables
[
2
].
updating
=
1
;
if
(
!
tables_ok
(
0
,
tables
))
if
(
!
rpl_filter
->
tables_ok
(
0
,
tables
))
DBUG_RETURN
(
FALSE
);
}
#endif
...
...
@@ -2873,14 +2870,14 @@ bool mysql_procedure_grant(THD *thd, TABLE_LIST *table_list,
GRANT and REVOKE are applied the slave in/exclusion rules as they are
some kind of updates to the mysql.% tables.
*/
if
(
thd
->
slave_thread
&&
table_rules_on
)
if
(
thd
->
slave_thread
&&
rpl_filter
->
is_on
()
)
{
/*
The tables must be marked "updating" so that tables_ok() takes them into
account in tests.
*/
tables
[
0
].
updating
=
tables
[
1
].
updating
=
1
;
if
(
!
tables_ok
(
0
,
tables
))
if
(
!
rpl_filter
->
tables_ok
(
0
,
tables
))
DBUG_RETURN
(
FALSE
);
}
#endif
...
...
@@ -3002,14 +2999,14 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
GRANT and REVOKE are applied the slave in/exclusion rules as they are
some kind of updates to the mysql.% tables.
*/
if
(
thd
->
slave_thread
&&
table_rules_on
)
if
(
thd
->
slave_thread
&&
rpl_filter
->
is_on
()
)
{
/*
The tables must be marked "updating" so that tables_ok() takes them into
account in tests.
*/
tables
[
0
].
updating
=
tables
[
1
].
updating
=
1
;
if
(
!
tables_ok
(
0
,
tables
))
if
(
!
rpl_filter
->
tables_ok
(
0
,
tables
))
DBUG_RETURN
(
FALSE
);
}
#endif
...
...
@@ -4210,7 +4207,7 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
GRANT and REVOKE are applied the slave in/exclusion rules as they are
some kind of updates to the mysql.% tables.
*/
if
(
thd
->
slave_thread
&&
table_rules_on
)
if
(
thd
->
slave_thread
&&
rpl_filter
->
is_on
()
)
{
/*
The tables must be marked "updating" so that tables_ok() takes them into
...
...
@@ -4218,7 +4215,7 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
*/
tables
[
0
].
updating
=
tables
[
1
].
updating
=
tables
[
2
].
updating
=
tables
[
3
].
updating
=
tables
[
4
].
updating
=
1
;
if
(
!
tables_ok
(
0
,
tables
))
if
(
!
rpl_filter
->
tables_ok
(
0
,
tables
))
DBUG_RETURN
(
1
);
tables
[
0
].
updating
=
tables
[
1
].
updating
=
tables
[
2
].
updating
=
tables
[
3
].
updating
=
tables
[
4
].
updating
=
0
;;
...
...
sql/sql_acl.h
View file @
efb07750
...
...
@@ -14,6 +14,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "slave.h" // for tables_ok(), rpl_filter
extern
Rpl_filter
*
rpl_filter
;
#define SELECT_ACL (1L << 0)
#define INSERT_ACL (1L << 1)
#define UPDATE_ACL (1L << 2)
...
...
sql/sql_class.h
View file @
efb07750
...
...
@@ -466,19 +466,20 @@ class LEX_COLUMN : public Sql_alloc
class
i_string
:
public
ilink
{
public:
char
*
ptr
;
c
onst
c
har
*
ptr
;
i_string
()
:
ptr
(
0
)
{
}
i_string
(
char
*
s
)
:
ptr
(
s
)
{}
i_string
(
c
onst
c
har
*
s
)
:
ptr
(
s
)
{}
};
/* needed for linked list of two strings for replicate-rewrite-db */
class
i_string_pair
:
public
ilink
{
public:
char
*
key
;
char
*
val
;
c
onst
c
har
*
key
;
c
onst
c
har
*
val
;
i_string_pair
()
:
key
(
0
),
val
(
0
)
{
}
i_string_pair
(
char
*
key_arg
,
char
*
val_arg
)
:
key
(
key_arg
),
val
(
val_arg
)
{}
i_string_pair
(
const
char
*
key_arg
,
const
char
*
val_arg
)
:
key
(
key_arg
),
val
(
val_arg
)
{}
};
...
...
sql/sql_parse.cc
View file @
efb07750
...
...
@@ -16,6 +16,7 @@
#include "mysql_priv.h"
#include "sql_repl.h"
#include "rpl_filter.h"
#include "repl_failsafe.h"
#include <m_ctype.h>
#include <myisam.h>
...
...
@@ -167,10 +168,12 @@ static bool begin_trans(THD *thd)
#ifdef HAVE_REPLICATION
inline
bool
all_tables_not_ok
(
THD
*
thd
,
TABLE_LIST
*
tables
)
{
return
(
table_rules_on
&&
tables
&&
!
tables_ok
(
thd
,
tables
)
&&
return
(
rpl_filter
->
is_on
()
&&
tables
&&
!
rpl_filter
->
tables_ok
(
thd
->
db
,
tables
)
&&
((
thd
->
lex
->
sql_command
!=
SQLCOM_DELETE_MULTI
)
||
!
tables_ok
(
thd
,
(
TABLE_LIST
*
)
thd
->
lex
->
auxilliary_table_list
.
first
)));
!
rpl_filter
->
tables_ok
(
thd
->
db
,
(
TABLE_LIST
*
)
thd
->
lex
->
auxilliary_table_list
.
first
)));
}
#endif
...
...
@@ -3441,9 +3444,9 @@ mysql_execute_command(THD *thd)
above was not called. So we have to check rules again here.
*/
#ifdef HAVE_REPLICATION
if
(
thd
->
slave_thread
&&
(
!
db_ok
(
lex
->
name
,
replicate_do_db
,
replicate_ignore_db
)
||
!
db_ok_with_wild_table
(
lex
->
name
)))
if
(
thd
->
slave_thread
&&
(
!
rpl_filter
->
db_ok
(
lex
->
name
)
||
!
rpl_filter
->
db_ok_with_wild_table
(
lex
->
name
)))
{
my_message
(
ER_SLAVE_IGNORED_TABLE
,
ER
(
ER_SLAVE_IGNORED_TABLE
),
MYF
(
0
));
break
;
...
...
@@ -3471,8 +3474,8 @@ mysql_execute_command(THD *thd)
*/
#ifdef HAVE_REPLICATION
if
(
thd
->
slave_thread
&&
(
!
db_ok
(
lex
->
name
,
replicate_do_db
,
replicate_ignore_db
)
||
!
db_ok_with_wild_table
(
lex
->
name
)))
(
!
rpl_filter
->
db_ok
(
lex
->
name
)
||
!
rpl_filter
->
db_ok_with_wild_table
(
lex
->
name
)))
{
my_message
(
ER_SLAVE_IGNORED_TABLE
,
ER
(
ER_SLAVE_IGNORED_TABLE
),
MYF
(
0
));
break
;
...
...
@@ -3511,8 +3514,8 @@ mysql_execute_command(THD *thd)
*/
#ifdef HAVE_REPLICATION
if
(
thd
->
slave_thread
&&
(
!
db_ok
(
db
,
replicate_do_db
,
replicate_ignore_db
)
||
!
db_ok_with_wild_table
(
db
)))
(
!
rpl_filter
->
db_ok
(
lex
->
name
)
||
!
rpl_filter
->
db_ok_with_wild_table
(
lex
->
name
)))
{
my_message
(
ER_SLAVE_IGNORED_TABLE
,
ER
(
ER_SLAVE_IGNORED_TABLE
),
MYF
(
0
));
break
;
...
...
sql/sql_repl.cc
View file @
efb07750
...
...
@@ -19,6 +19,7 @@
#include "sql_repl.h"
#include "log_event.h"
#include "rpl_filter.h"
#include <my_dir.h>
int
max_binlog_dump_events
=
0
;
// unlimited
...
...
@@ -1429,8 +1430,8 @@ bool show_binlog_info(THD* thd)
int
dir_len
=
dirname_length
(
li
.
log_file_name
);
protocol
->
store
(
li
.
log_file_name
+
dir_len
,
&
my_charset_bin
);
protocol
->
store
((
ulonglong
)
li
.
pos
);
protocol
->
store
(
&
binlog_do_db
);
protocol
->
store
(
&
binlog_ignore_db
);
protocol
->
store
(
binlog_filter
->
get_do_db
()
);
protocol
->
store
(
binlog_filter
->
get_ignore_db
()
);
if
(
protocol
->
write
())
DBUG_RETURN
(
TRUE
);
}
...
...
sql/sql_repl.h
View file @
efb07750
...
...
@@ -17,6 +17,9 @@
#ifdef HAVE_REPLICATION
#include "slave.h"
extern
Rpl_filter
*
binlog_filter
;
extern
Rpl_filter
*
rpl_filter
;
typedef
struct
st_slave_info
{
uint32
server_id
;
...
...
@@ -31,7 +34,6 @@ typedef struct st_slave_info
extern
my_bool
opt_show_slave_auth_info
;
extern
char
*
master_host
,
*
master_info_file
;
extern
bool
server_id_supplied
;
extern
I_List
<
i_string
>
binlog_do_db
,
binlog_ignore_db
;
extern
int
max_binlog_dump_events
;
extern
my_bool
opt_sporadic_binlog_dump_fail
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment