Skip to content

Commit 75f382e

Browse files
author
Alfranio Correia
committed
merge mysql-5.1-rep+2 --> mysql-5.1-rep+3
2 parents 9b8e816 + 34ab452 commit 75f382e

File tree

9 files changed

+346
-11
lines changed

9 files changed

+346
-11
lines changed

include/mysql_com.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ enum enum_server_command
115115
thread */
116116
#define REFRESH_MASTER 128 /* Remove all bin logs in the index
117117
and truncate the index */
118+
#define REFRESH_ERROR_LOG 256 /* Rotate only the erorr log */
119+
#define REFRESH_ENGINE_LOG 512 /* Flush all storage engine logs */
120+
#define REFRESH_BINARY_LOG 1024 /* Flush the binary log */
121+
#define REFRESH_RELAY_LOG 2048 /* Flush the relay log */
122+
#define REFRESH_GENERAL_LOG 4096 /* Flush the general log */
123+
#define REFRESH_SLOW_LOG 8192 /* Flush the slow query log */
118124

119125
/* The following can't be set with mysql_refresh() */
120126
#define REFRESH_READ_LOCK 16384 /* Lock tables for read */
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
stop slave;
2+
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
3+
reset master;
4+
reset slave;
5+
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
6+
start slave;
7+
# Make sure the 'master_log.err-old' file does not
8+
# exist before execute 'flush error logs' statement.
9+
# Test if support 'flush error logs' statement.
10+
flush error logs;
11+
# Check the 'master_log.err-old' file is created
12+
# after executed 'flush error logs' statement.
13+
# Make sure binary logs was not be flushed
14+
# after execute 'flush error logs' statement.
15+
# Make sure relay logs was not be flushed
16+
# after execute 'flush error logs' statement.
17+
# Make sure the 'slave-relay-bin.000004' file does not
18+
# exist before execute 'flush relay logs' statement.
19+
# Test if support 'flush relay logs' statement.
20+
flush relay logs;
21+
# Check the 'slave-relay-bin.000004' file is created
22+
# after executed 'flush relay logs' statement.
23+
# Make sure binary logs was not be flushed
24+
# after execute 'flush relay logs' statement.
25+
# Test if support 'flush slow logs' statement.
26+
flush slow logs;
27+
# Make sure binary logs was not be flushed
28+
# after execute 'flush slow logs' statement.
29+
# Test if support 'flush general logs' statement.
30+
flush general logs;
31+
# Make sure binary logs was not be flushed
32+
# after execute 'flush general logs' statement.
33+
# Test if support 'flush engine logs' statement.
34+
flush engine logs;
35+
# Make sure binary logs was not be flushed
36+
# after execute 'flush engine logs' statement.
37+
# Make sure the 'master-bin.000002' file does not
38+
# exist before execute 'flush binary logs' statement.
39+
# Test if support 'flush binary logs' statement.
40+
flush binary logs;
41+
# Check the 'master-bin.000002' file is created
42+
# after executed 'flush binary logs' statement.
43+
# Make sure the 'slave-relay-bin.000007' file does not exist
44+
# exist before execute 'flush error logs, relay logs' statement.
45+
# Make sure the 'master_log.err-old' file does not exist
46+
# before execute 'flush error logs, relay logs' statement.
47+
# Test if support to combine all kinds of logs into one statement.
48+
flush error logs, relay logs;
49+
# Check the 'master_log.err-old' file is created
50+
# after executed 'flush error logs, relay logs' statement.
51+
# Make sure binary logs was not be flushed
52+
# after execute 'flush error logs, relay logs' statement.
53+
# Check the 'slave-relay-bin.000007' file is created after
54+
# execute 'flush error logs, relay logs' statement.
55+
# Make sure the 'slave-relay-bin.000008' and 'slave-relay-bin.000009'
56+
# files do not exist before execute 'flush error logs, relay logs'
57+
# statement.
58+
# Make sure the 'master_log.err-old' file does not exist
59+
# before execute 'flush logs' statement.
60+
# Test if 'flush logs' statement works fine and flush all the logs.
61+
flush logs;
62+
# Check the 'master_log.err-old' file is created
63+
# after executed 'flush logs' statement.
64+
# Check 'master-bin.000003' is created
65+
# after execute 'flush logs' statement.
66+
# Check the 'slave-relay-bin.000008' and 'slave-relay-bin.000009'
67+
# files are created after execute 'flush logs' statement.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--log-error=$MYSQLTEST_VARDIR/tmp/master_log.err
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
#
2+
# WL#5124
3+
# This test verifies if the 'flush individual logs' statement
4+
# works fine.
5+
#
6+
7+
--source include/master-slave.inc
8+
--source include/have_binlog_format_statement.inc
9+
connection master;
10+
11+
# Test 'flush error logs' statement.
12+
--echo # Make sure the 'master_log.err-old' file does not
13+
--echo # exist before execute 'flush error logs' statement.
14+
--error 1
15+
file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
16+
17+
--echo # Test if support 'flush error logs' statement.
18+
flush error logs;
19+
20+
--echo # Check the 'master_log.err-old' file is created
21+
--echo # after executed 'flush error logs' statement.
22+
file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
23+
file_exists $MYSQLTEST_VARDIR/tmp/master_log.err;
24+
25+
--echo # Make sure binary logs was not be flushed
26+
--echo # after execute 'flush error logs' statement.
27+
--error 1
28+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
29+
30+
sync_slave_with_master;
31+
--echo # Make sure relay logs was not be flushed
32+
--echo # after execute 'flush error logs' statement.
33+
--error 1
34+
file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000004;
35+
36+
37+
# Test 'flush relay logs' statement.
38+
--echo # Make sure the 'slave-relay-bin.000004' file does not
39+
--echo # exist before execute 'flush relay logs' statement.
40+
--error 1
41+
file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000004;
42+
43+
connection master;
44+
--echo # Test if support 'flush relay logs' statement.
45+
flush relay logs;
46+
47+
sync_slave_with_master;
48+
--echo # Check the 'slave-relay-bin.000004' file is created
49+
--echo # after executed 'flush relay logs' statement.
50+
file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000004;
51+
52+
connection master;
53+
--echo # Make sure binary logs was not be flushed
54+
--echo # after execute 'flush relay logs' statement.
55+
--error 1
56+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
57+
58+
59+
# Test 'flush slow logs' statement.
60+
--echo # Test if support 'flush slow logs' statement.
61+
flush slow logs;
62+
63+
--echo # Make sure binary logs was not be flushed
64+
--echo # after execute 'flush slow logs' statement.
65+
--error 1
66+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
67+
68+
69+
# Test 'flush general logs' statement.
70+
--echo # Test if support 'flush general logs' statement.
71+
flush general logs;
72+
73+
--echo # Make sure binary logs was not be flushed
74+
--echo # after execute 'flush general logs' statement.
75+
--error 1
76+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
77+
78+
79+
# Test 'flush engine logs' statement.
80+
--echo # Test if support 'flush engine logs' statement.
81+
flush engine logs;
82+
83+
--echo # Make sure binary logs was not be flushed
84+
--echo # after execute 'flush engine logs' statement.
85+
--error 1
86+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
87+
88+
89+
# Test 'flush binary logs' statement.
90+
--echo # Make sure the 'master-bin.000002' file does not
91+
--echo # exist before execute 'flush binary logs' statement.
92+
--error 1
93+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
94+
95+
--echo # Test if support 'flush binary logs' statement.
96+
flush binary logs;
97+
98+
--echo # Check the 'master-bin.000002' file is created
99+
--echo # after executed 'flush binary logs' statement.
100+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000002;
101+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000001;
102+
103+
104+
# Test 'flush error logs, relay logs' statement
105+
sync_slave_with_master;
106+
--echo # Make sure the 'slave-relay-bin.000007' file does not exist
107+
--echo # exist before execute 'flush error logs, relay logs' statement.
108+
--error 1
109+
file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000007;
110+
111+
connection master;
112+
remove_file $MYSQLTEST_VARDIR/tmp/master_log.err-old;
113+
114+
--echo # Make sure the 'master_log.err-old' file does not exist
115+
--echo # before execute 'flush error logs, relay logs' statement.
116+
--error 1
117+
file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
118+
119+
--echo # Test if support to combine all kinds of logs into one statement.
120+
flush error logs, relay logs;
121+
122+
--echo # Check the 'master_log.err-old' file is created
123+
--echo # after executed 'flush error logs, relay logs' statement.
124+
file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
125+
file_exists $MYSQLTEST_VARDIR/tmp/master_log.err;
126+
127+
--echo # Make sure binary logs was not be flushed
128+
--echo # after execute 'flush error logs, relay logs' statement.
129+
--error 1
130+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000003;
131+
132+
sync_slave_with_master;
133+
--echo # Check the 'slave-relay-bin.000007' file is created after
134+
--echo # execute 'flush error logs, relay logs' statement.
135+
file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000007;
136+
137+
138+
# Test 'flush logs' statement
139+
--echo # Make sure the 'slave-relay-bin.000008' and 'slave-relay-bin.000009'
140+
--echo # files do not exist before execute 'flush error logs, relay logs'
141+
--echo # statement.
142+
--error 1
143+
file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000008;
144+
--error 1
145+
file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000009;
146+
147+
connection master;
148+
remove_file $MYSQLTEST_VARDIR/tmp/master_log.err-old;
149+
150+
--echo # Make sure the 'master_log.err-old' file does not exist
151+
--echo # before execute 'flush logs' statement.
152+
--error 1
153+
file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
154+
155+
--echo # Test if 'flush logs' statement works fine and flush all the logs.
156+
flush logs;
157+
158+
--echo # Check the 'master_log.err-old' file is created
159+
--echo # after executed 'flush logs' statement.
160+
file_exists $MYSQLTEST_VARDIR/tmp/master_log.err-old;
161+
file_exists $MYSQLTEST_VARDIR/tmp/master_log.err;
162+
163+
--echo # Check 'master-bin.000003' is created
164+
--echo # after execute 'flush logs' statement.
165+
file_exists $MYSQLTEST_VARDIR/mysqld.1/data/master-bin.000003;
166+
167+
sync_slave_with_master;
168+
--echo # Check the 'slave-relay-bin.000008' and 'slave-relay-bin.000009'
169+
--echo # files are created after execute 'flush logs' statement.
170+
file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000008;
171+
file_exists $MYSQLTEST_VARDIR/mysqld.2/data/slave-relay-bin.000009;
172+

sql/lex.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ static SYMBOL symbols[] = {
189189
{ "ENGINE", SYM(ENGINE_SYM)},
190190
{ "ENGINES", SYM(ENGINES_SYM)},
191191
{ "ENUM", SYM(ENUM)},
192+
{ "ERROR", SYM(ERROR_SYM)},
192193
{ "ERRORS", SYM(ERRORS)},
193194
{ "ESCAPE", SYM(ESCAPE_SYM)},
194195
{ "ESCAPED", SYM(ESCAPED)},
@@ -223,6 +224,7 @@ static SYMBOL symbols[] = {
223224
{ "FULL", SYM(FULL)},
224225
{ "FULLTEXT", SYM(FULLTEXT_SYM)},
225226
{ "FUNCTION", SYM(FUNCTION_SYM)},
227+
{ "GENERAL", SYM(GENERAL)},
226228
{ "GEOMETRY", SYM(GEOMETRY_SYM)},
227229
{ "GEOMETRYCOLLECTION",SYM(GEOMETRYCOLLECTION)},
228230
{ "GET_FORMAT", SYM(GET_FORMAT)},
@@ -429,6 +431,7 @@ static SYMBOL symbols[] = {
429431
{ "REDUNDANT", SYM(REDUNDANT_SYM)},
430432
{ "REFERENCES", SYM(REFERENCES)},
431433
{ "REGEXP", SYM(REGEXP)},
434+
{ "RELAY", SYM(RELAY)},
432435
{ "RELAYLOG", SYM(RELAYLOG_SYM)},
433436
{ "RELAY_LOG_FILE", SYM(RELAY_LOG_FILE_SYM)},
434437
{ "RELAY_LOG_POS", SYM(RELAY_LOG_POS_SYM)},
@@ -481,6 +484,7 @@ static SYMBOL symbols[] = {
481484
{ "SIGNED", SYM(SIGNED_SYM)},
482485
{ "SIMPLE", SYM(SIMPLE_SYM)},
483486
{ "SLAVE", SYM(SLAVE)},
487+
{ "SLOW", SYM(SLOW)},
484488
{ "SNAPSHOT", SYM(SNAPSHOT_SYM)},
485489
{ "SMALLINT", SYM(SMALLINT)},
486490
{ "SOCKET", SYM(SOCKET_SYM)},

sql/log.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,54 @@ bool LOGGER::flush_logs(THD *thd)
10051005
}
10061006

10071007

1008+
/**
1009+
Close and reopen the slow log (with locks).
1010+
1011+
@returns FALSE.
1012+
*/
1013+
bool LOGGER::flush_slow_log()
1014+
{
1015+
/*
1016+
Now we lock logger, as nobody should be able to use logging routines while
1017+
log tables are closed
1018+
*/
1019+
logger.lock_exclusive();
1020+
1021+
/* Reopen slow log file */
1022+
if (opt_slow_log)
1023+
file_log_handler->get_mysql_slow_log()->reopen_file();
1024+
1025+
/* End of log flush */
1026+
logger.unlock();
1027+
1028+
return 0;
1029+
}
1030+
1031+
1032+
/**
1033+
Close and reopen the general log (with locks).
1034+
1035+
@returns FALSE.
1036+
*/
1037+
bool LOGGER::flush_general_log()
1038+
{
1039+
/*
1040+
Now we lock logger, as nobody should be able to use logging routines while
1041+
log tables are closed
1042+
*/
1043+
logger.lock_exclusive();
1044+
1045+
/* Reopen general log file */
1046+
if (opt_log)
1047+
file_log_handler->get_mysql_log()->reopen_file();
1048+
1049+
/* End of log flush */
1050+
logger.unlock();
1051+
1052+
return 0;
1053+
}
1054+
1055+
10081056
/*
10091057
Log slow query with all enabled log event handlers
10101058

sql/log.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ class LOGGER
574574
void init_base();
575575
void init_log_tables();
576576
bool flush_logs(THD *thd);
577+
bool flush_slow_log();
578+
bool flush_general_log();
577579
/* Perform basic logger cleanup. this will leave e.g. error log open. */
578580
void cleanup_base();
579581
/* Free memory. Nothing could be logged after this function is called */

0 commit comments

Comments
 (0)