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
47ee6c54
Commit
47ee6c54
authored
Dec 14, 2009
by
Alfranio Correia
Browse files
Options
Browse Files
Download
Plain Diff
merge mysql-5.1-rep+2 --> mysql-5.1-rep+3
parents
9ad023af
40d7826e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
346 additions
and
11 deletions
+346
-11
include/mysql_com.h
include/mysql_com.h
+6
-0
mysql-test/suite/rpl/r/rpl_flush_logs.result
mysql-test/suite/rpl/r/rpl_flush_logs.result
+67
-0
mysql-test/suite/rpl/t/rpl_flush_logs-master.opt
mysql-test/suite/rpl/t/rpl_flush_logs-master.opt
+1
-0
mysql-test/suite/rpl/t/rpl_flush_logs.test
mysql-test/suite/rpl/t/rpl_flush_logs.test
+172
-0
sql/lex.h
sql/lex.h
+4
-0
sql/log.cc
sql/log.cc
+48
-0
sql/log.h
sql/log.h
+2
-0
sql/sql_parse.cc
sql/sql_parse.cc
+28
-11
sql/sql_yacc.yy
sql/sql_yacc.yy
+18
-0
No files found.
include/mysql_com.h
View file @
47ee6c54
...
...
@@ -115,6 +115,12 @@ enum enum_server_command
thread */
#define REFRESH_MASTER 128
/* Remove all bin logs in the index
and truncate the index */
#define REFRESH_ERROR_LOG 256
/* Rotate only the erorr log */
#define REFRESH_ENGINE_LOG 512
/* Flush all storage engine logs */
#define REFRESH_BINARY_LOG 1024
/* Flush the binary log */
#define REFRESH_RELAY_LOG 2048
/* Flush the relay log */
#define REFRESH_GENERAL_LOG 4096
/* Flush the general log */
#define REFRESH_SLOW_LOG 8192
/* Flush the slow query log */
/* The following can't be set with mysql_refresh() */
#define REFRESH_READ_LOCK 16384
/* Lock tables for read */
...
...
mysql-test/suite/rpl/r/rpl_flush_logs.result
0 → 100644
View file @
47ee6c54
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;
# Make sure the 'master_log.err-old' file does not
# exist before execute 'flush error logs' statement.
# Test if support 'flush error logs' statement.
flush error logs;
# Check the 'master_log.err-old' file is created
# after executed 'flush error logs' statement.
# Make sure binary logs was not be flushed
# after execute 'flush error logs' statement.
# Make sure relay logs was not be flushed
# after execute 'flush error logs' statement.
# Make sure the 'slave-relay-bin.000004' file does not
# exist before execute 'flush relay logs' statement.
# Test if support 'flush relay logs' statement.
flush relay logs;
# Check the 'slave-relay-bin.000004' file is created
# after executed 'flush relay logs' statement.
# Make sure binary logs was not be flushed
# after execute 'flush relay logs' statement.
# Test if support 'flush slow logs' statement.
flush slow logs;
# Make sure binary logs was not be flushed
# after execute 'flush slow logs' statement.
# Test if support 'flush general logs' statement.
flush general logs;
# Make sure binary logs was not be flushed
# after execute 'flush general logs' statement.
# Test if support 'flush engine logs' statement.
flush engine logs;
# Make sure binary logs was not be flushed
# after execute 'flush engine logs' statement.
# Make sure the 'master-bin.000002' file does not
# exist before execute 'flush binary logs' statement.
# Test if support 'flush binary logs' statement.
flush binary logs;
# Check the 'master-bin.000002' file is created
# after executed 'flush binary logs' statement.
# Make sure the 'slave-relay-bin.000007' file does not exist
# exist before execute 'flush error logs, relay logs' statement.
# Make sure the 'master_log.err-old' file does not exist
# before execute 'flush error logs, relay logs' statement.
# Test if support to combine all kinds of logs into one statement.
flush error logs, relay logs;
# Check the 'master_log.err-old' file is created
# after executed 'flush error logs, relay logs' statement.
# Make sure binary logs was not be flushed
# after execute 'flush error logs, relay logs' statement.
# Check the 'slave-relay-bin.000007' file is created after
# execute 'flush error logs, relay logs' statement.
# Make sure the 'slave-relay-bin.000008' and 'slave-relay-bin.000009'
# files do not exist before execute 'flush error logs, relay logs'
# statement.
# Make sure the 'master_log.err-old' file does not exist
# before execute 'flush logs' statement.
# Test if 'flush logs' statement works fine and flush all the logs.
flush logs;
# Check the 'master_log.err-old' file is created
# after executed 'flush logs' statement.
# Check 'master-bin.000003' is created
# after execute 'flush logs' statement.
# Check the 'slave-relay-bin.000008' and 'slave-relay-bin.000009'
# files are created after execute 'flush logs' statement.
mysql-test/suite/rpl/t/rpl_flush_logs-master.opt
0 → 100644
View file @
47ee6c54
--log-error=$MYSQLTEST_VARDIR/tmp/master_log.err
mysql-test/suite/rpl/t/rpl_flush_logs.test
0 → 100644
View file @
47ee6c54
#
# WL#5124
# This test verifies if the 'flush individual logs' statement
# works fine.
#
--
source
include
/
master
-
slave
.
inc
--
source
include
/
have_binlog_format_statement
.
inc
connection
master
;
# Test 'flush error logs' statement.
--
echo
# Make sure the 'master_log.err-old' file does not
--
echo
# exist before execute 'flush error logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
-
old
;
--
echo
# Test if support 'flush error logs' statement.
flush
error
logs
;
--
echo
# Check the 'master_log.err-old' file is created
--
echo
# after executed 'flush error logs' statement.
file_exists
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
-
old
;
file_exists
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
;
--
echo
# Make sure binary logs was not be flushed
--
echo
# after execute 'flush error logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000002
;
sync_slave_with_master
;
--
echo
# Make sure relay logs was not be flushed
--
echo
# after execute 'flush error logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
2
/
data
/
slave
-
relay
-
bin
.
000004
;
# Test 'flush relay logs' statement.
--
echo
# Make sure the 'slave-relay-bin.000004' file does not
--
echo
# exist before execute 'flush relay logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
2
/
data
/
slave
-
relay
-
bin
.
000004
;
connection
master
;
--
echo
# Test if support 'flush relay logs' statement.
flush
relay
logs
;
sync_slave_with_master
;
--
echo
# Check the 'slave-relay-bin.000004' file is created
--
echo
# after executed 'flush relay logs' statement.
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
2
/
data
/
slave
-
relay
-
bin
.
000004
;
connection
master
;
--
echo
# Make sure binary logs was not be flushed
--
echo
# after execute 'flush relay logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000002
;
# Test 'flush slow logs' statement.
--
echo
# Test if support 'flush slow logs' statement.
flush
slow
logs
;
--
echo
# Make sure binary logs was not be flushed
--
echo
# after execute 'flush slow logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000002
;
# Test 'flush general logs' statement.
--
echo
# Test if support 'flush general logs' statement.
flush
general
logs
;
--
echo
# Make sure binary logs was not be flushed
--
echo
# after execute 'flush general logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000002
;
# Test 'flush engine logs' statement.
--
echo
# Test if support 'flush engine logs' statement.
flush
engine
logs
;
--
echo
# Make sure binary logs was not be flushed
--
echo
# after execute 'flush engine logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000002
;
# Test 'flush binary logs' statement.
--
echo
# Make sure the 'master-bin.000002' file does not
--
echo
# exist before execute 'flush binary logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000002
;
--
echo
# Test if support 'flush binary logs' statement.
flush
binary
logs
;
--
echo
# Check the 'master-bin.000002' file is created
--
echo
# after executed 'flush binary logs' statement.
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000002
;
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000001
;
# Test 'flush error logs, relay logs' statement
sync_slave_with_master
;
--
echo
# Make sure the 'slave-relay-bin.000007' file does not exist
--
echo
# exist before execute 'flush error logs, relay logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
2
/
data
/
slave
-
relay
-
bin
.
000007
;
connection
master
;
remove_file
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
-
old
;
--
echo
# Make sure the 'master_log.err-old' file does not exist
--
echo
# before execute 'flush error logs, relay logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
-
old
;
--
echo
# Test if support to combine all kinds of logs into one statement.
flush
error
logs
,
relay
logs
;
--
echo
# Check the 'master_log.err-old' file is created
--
echo
# after executed 'flush error logs, relay logs' statement.
file_exists
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
-
old
;
file_exists
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
;
--
echo
# Make sure binary logs was not be flushed
--
echo
# after execute 'flush error logs, relay logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000003
;
sync_slave_with_master
;
--
echo
# Check the 'slave-relay-bin.000007' file is created after
--
echo
# execute 'flush error logs, relay logs' statement.
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
2
/
data
/
slave
-
relay
-
bin
.
000007
;
# Test 'flush logs' statement
--
echo
# Make sure the 'slave-relay-bin.000008' and 'slave-relay-bin.000009'
--
echo
# files do not exist before execute 'flush error logs, relay logs'
--
echo
# statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
2
/
data
/
slave
-
relay
-
bin
.
00000
8
;
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
2
/
data
/
slave
-
relay
-
bin
.
00000
9
;
connection
master
;
remove_file
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
-
old
;
--
echo
# Make sure the 'master_log.err-old' file does not exist
--
echo
# before execute 'flush logs' statement.
--
error
1
file_exists
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
-
old
;
--
echo
# Test if 'flush logs' statement works fine and flush all the logs.
flush
logs
;
--
echo
# Check the 'master_log.err-old' file is created
--
echo
# after executed 'flush logs' statement.
file_exists
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
-
old
;
file_exists
$MYSQLTEST_VARDIR
/
tmp
/
master_log
.
err
;
--
echo
# Check 'master-bin.000003' is created
--
echo
# after execute 'flush logs' statement.
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
1
/
data
/
master
-
bin
.
000003
;
sync_slave_with_master
;
--
echo
# Check the 'slave-relay-bin.000008' and 'slave-relay-bin.000009'
--
echo
# files are created after execute 'flush logs' statement.
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
2
/
data
/
slave
-
relay
-
bin
.
00000
8
;
file_exists
$MYSQLTEST_VARDIR
/
mysqld
.
2
/
data
/
slave
-
relay
-
bin
.
00000
9
;
sql/lex.h
View file @
47ee6c54
...
...
@@ -189,6 +189,7 @@ static SYMBOL symbols[] = {
{
"ENGINE"
,
SYM
(
ENGINE_SYM
)},
{
"ENGINES"
,
SYM
(
ENGINES_SYM
)},
{
"ENUM"
,
SYM
(
ENUM
)},
{
"ERROR"
,
SYM
(
ERROR_SYM
)},
{
"ERRORS"
,
SYM
(
ERRORS
)},
{
"ESCAPE"
,
SYM
(
ESCAPE_SYM
)},
{
"ESCAPED"
,
SYM
(
ESCAPED
)},
...
...
@@ -223,6 +224,7 @@ static SYMBOL symbols[] = {
{
"FULL"
,
SYM
(
FULL
)},
{
"FULLTEXT"
,
SYM
(
FULLTEXT_SYM
)},
{
"FUNCTION"
,
SYM
(
FUNCTION_SYM
)},
{
"GENERAL"
,
SYM
(
GENERAL
)},
{
"GEOMETRY"
,
SYM
(
GEOMETRY_SYM
)},
{
"GEOMETRYCOLLECTION"
,
SYM
(
GEOMETRYCOLLECTION
)},
{
"GET_FORMAT"
,
SYM
(
GET_FORMAT
)},
...
...
@@ -429,6 +431,7 @@ static SYMBOL symbols[] = {
{
"REDUNDANT"
,
SYM
(
REDUNDANT_SYM
)},
{
"REFERENCES"
,
SYM
(
REFERENCES
)},
{
"REGEXP"
,
SYM
(
REGEXP
)},
{
"RELAY"
,
SYM
(
RELAY
)},
{
"RELAYLOG"
,
SYM
(
RELAYLOG_SYM
)},
{
"RELAY_LOG_FILE"
,
SYM
(
RELAY_LOG_FILE_SYM
)},
{
"RELAY_LOG_POS"
,
SYM
(
RELAY_LOG_POS_SYM
)},
...
...
@@ -481,6 +484,7 @@ static SYMBOL symbols[] = {
{
"SIGNED"
,
SYM
(
SIGNED_SYM
)},
{
"SIMPLE"
,
SYM
(
SIMPLE_SYM
)},
{
"SLAVE"
,
SYM
(
SLAVE
)},
{
"SLOW"
,
SYM
(
SLOW
)},
{
"SNAPSHOT"
,
SYM
(
SNAPSHOT_SYM
)},
{
"SMALLINT"
,
SYM
(
SMALLINT
)},
{
"SOCKET"
,
SYM
(
SOCKET_SYM
)},
...
...
sql/log.cc
View file @
47ee6c54
...
...
@@ -1005,6 +1005,54 @@ bool LOGGER::flush_logs(THD *thd)
}
/**
Close and reopen the slow log (with locks).
@returns FALSE.
*/
bool
LOGGER
::
flush_slow_log
()
{
/*
Now we lock logger, as nobody should be able to use logging routines while
log tables are closed
*/
logger
.
lock_exclusive
();
/* Reopen slow log file */
if
(
opt_slow_log
)
file_log_handler
->
get_mysql_slow_log
()
->
reopen_file
();
/* End of log flush */
logger
.
unlock
();
return
0
;
}
/**
Close and reopen the general log (with locks).
@returns FALSE.
*/
bool
LOGGER
::
flush_general_log
()
{
/*
Now we lock logger, as nobody should be able to use logging routines while
log tables are closed
*/
logger
.
lock_exclusive
();
/* Reopen general log file */
if
(
opt_log
)
file_log_handler
->
get_mysql_log
()
->
reopen_file
();
/* End of log flush */
logger
.
unlock
();
return
0
;
}
/*
Log slow query with all enabled log event handlers
...
...
sql/log.h
View file @
47ee6c54
...
...
@@ -574,6 +574,8 @@ class LOGGER
void
init_base
();
void
init_log_tables
();
bool
flush_logs
(
THD
*
thd
);
bool
flush_slow_log
();
bool
flush_general_log
();
/* Perform basic logger cleanup. this will leave e.g. error log open. */
void
cleanup_base
();
/* Free memory. Nothing could be logged after this function is called */
...
...
sql/sql_parse.cc
View file @
47ee6c54
...
...
@@ -6666,6 +6666,30 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
tables.
*/
options
|=
REFRESH_BINARY_LOG
;
options
|=
REFRESH_RELAY_LOG
;
options
|=
REFRESH_SLOW_LOG
;
options
|=
REFRESH_GENERAL_LOG
;
options
|=
REFRESH_ENGINE_LOG
;
options
|=
REFRESH_ERROR_LOG
;
}
if
(
options
&
REFRESH_ERROR_LOG
)
if
(
flush_error_log
())
result
=
1
;
if
((
options
&
REFRESH_SLOW_LOG
)
&&
opt_slow_log
)
logger
.
flush_slow_log
();
if
((
options
&
REFRESH_GENERAL_LOG
)
&&
opt_log
)
logger
.
flush_general_log
();
if
(
options
&
REFRESH_ENGINE_LOG
)
if
(
ha_flush_logs
(
NULL
))
result
=
1
;
if
(
options
&
REFRESH_BINARY_LOG
)
{
/*
Writing this command to the binlog may result in infinite loops
when doing mysqlbinlog|mysql, and anyway it does not really make
...
...
@@ -6673,23 +6697,16 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
than it would help them)
*/
tmp_write_to_binlog
=
0
;
if
(
mysql_bin_log
.
is_open
()
)
{
if
(
mysql_bin_log
.
is_open
())
mysql_bin_log
.
rotate_and_purge
(
RP_FORCE_ROTATE
);
}
if
(
options
&
REFRESH_RELAY_LOG
)
{
#ifdef HAVE_REPLICATION
pthread_mutex_lock
(
&
LOCK_active_mi
);
rotate_relay_log
(
active_mi
);
pthread_mutex_unlock
(
&
LOCK_active_mi
);
#endif
/* flush slow and general logs */
logger
.
flush_logs
(
thd
);
if
(
ha_flush_logs
(
NULL
))
result
=
1
;
if
(
flush_error_log
())
result
=
1
;
}
#ifdef HAVE_QUERY_CACHE
if
(
options
&
REFRESH_QUERY_CACHE_FREE
)
...
...
sql/sql_yacc.yy
View file @
47ee6c54
...
...
@@ -681,6 +681,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token ENUM
%token EQ /* OPERATOR */
%token EQUAL_SYM /* OPERATOR */
%token ERROR_SYM
%token ERRORS
%token ESCAPED
%token ESCAPE_SYM /* SQL-2003-R */
...
...
@@ -714,6 +715,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token FULLTEXT_SYM
%token FUNCTION_SYM /* SQL-2003-R */
%token GE
%token GENERAL
%token GEOMETRYCOLLECTION
%token GEOMETRY_SYM
%token GET_FORMAT /* MYSQL-FUNC */
...
...
@@ -931,6 +933,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token REDUNDANT_SYM
%token REFERENCES /* SQL-2003-R */
%token REGEXP
%token RELAY
%token RELAYLOG_SYM
%token RELAY_LOG_FILE_SYM
%token RELAY_LOG_POS_SYM
...
...
@@ -985,6 +988,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token SIGNED_SYM
%token SIMPLE_SYM /* SQL-2003-N */
%token SLAVE
%token SLOW
%token SMALLINT /* SQL-2003-R */
%token SNAPSHOT_SYM
%token SOCKET_SYM
...
...
@@ -10325,6 +10329,18 @@ flush_option:
opt_table_list {}
| TABLES WITH READ_SYM LOCK_SYM
{ Lex->type|= REFRESH_TABLES | REFRESH_READ_LOCK; }
| ERROR_SYM LOGS_SYM
{ Lex->type|= REFRESH_ERROR_LOG; }
| ENGINE_SYM LOGS_SYM
{ Lex->type|= REFRESH_ENGINE_LOG; }
| GENERAL LOGS_SYM
{ Lex->type|= REFRESH_GENERAL_LOG; }
| SLOW LOGS_SYM
{ Lex->type|= REFRESH_SLOW_LOG; }
| BINARY LOGS_SYM
{ Lex->type|= REFRESH_BINARY_LOG; }
| RELAY LOGS_SYM
{ Lex->type|= REFRESH_RELAY_LOG; }
| QUERY_SYM CACHE_SYM
{ Lex->type|= REFRESH_QUERY_CACHE_FREE; }
| HOSTS_SYM
...
...
@@ -11448,6 +11464,7 @@ keyword_sp:
| ENUM {}
| ENGINE_SYM {}
| ENGINES_SYM {}
| ERROR_SYM {}
| ERRORS {}
| ESCAPE_SYM {}
| EVENT_SYM {}
...
...
@@ -11572,6 +11589,7 @@ keyword_sp:
| REDO_BUFFER_SIZE_SYM {}
| REDOFILE_SYM {}
| REDUNDANT_SYM {}
| RELAY {}
| RELAYLOG_SYM {}
| RELAY_LOG_FILE_SYM {}
| RELAY_LOG_POS_SYM {}
...
...
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