Merge lp:~tsarev/percona-server/18205_02_wl36.patch into lp:percona-server/rnt-5.1

Proposed by Oleg Tsarev
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: 210
Merged at revision: 210
Proposed branch: lp:~tsarev/percona-server/18205_02_wl36.patch
Merge into: lp:percona-server/rnt-5.1
Prerequisite: lp:~tsarev/percona-server/18205_01_mysqlbinlog_fix.patch
Diff against target: 424 lines (+174/-48)
3 files modified
patches/series (+1/-1)
patches/wl36.patch (+170/-43)
patches/wl47.patch (+3/-4)
To merge this branch: bzr merge lp:~tsarev/percona-server/18205_02_wl36.patch
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+90836@code.launchpad.net

This proposal supersedes a proposal from 2012-01-30.

Description of the change

Renamed patch mwl36.patch to wl36.patch.
Fixed code policy.
Added test.

I didn't run full testing on Jenkins, because changes in code doesn't change the compile result.
I added new test "wl36" and checked it locally, also with --repeat option (test works fine).

(issue 18205 - prepare lp:percona-server/rnt-5.1 patches to merge to lp:percona-server/5.1)

after merge this fix to lp:percona-server/rnt-5.1 I will propose for merge it to lp:percona-server/5.1

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Based on my understanding of the coding standards, there is no need to rewrite single-line
// foo
to
/* foo */

The standards say:

    Single-line comments like this are OK in C++

 // We must check if stack_size = Solaris 2.9 can return 0 here.

review: Needs Fixing
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

LGTM, thank you.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'patches/series'
2--- patches/series 2011-12-22 14:17:38 +0000
3+++ patches/series 2012-01-31 08:20:27 +0000
4@@ -69,7 +69,7 @@
5 bug860910.patch
6 bug45702.patch
7 mysqlbinlog_fix.patch
8-mwl36.patch
9+wl36.patch
10 wl47.patch
11 wl5151.patch
12 slave_type_conversions_error_on_truncate.patch
13
14=== renamed file 'patches/mwl36.patch' => 'patches/wl36.patch'
15--- patches/mwl36.patch 2011-11-17 12:41:18 +0000
16+++ patches/wl36.patch 2012-01-31 08:20:27 +0000
17@@ -44,8 +44,8 @@
18 +/* Needed for Rpl_filter */
19 +CHARSET_INFO* system_charset_info= &my_charset_utf8_general_ci;
20 +
21-+#include "sql_string.h" // needed for Rpl_filter
22-+#include "sql_list.h" // needed for Rpl_filter
23++#include "sql_string.h" // needed for Rpl_filter
24++#include "sql_list.h" // needed for Rpl_filter
25 +#include "rpl_filter.h"
26 +
27 +Rpl_filter *binlog_filter;
28@@ -53,7 +53,7 @@
29 #define BIN_LOG_HEADER_SIZE 4
30 #define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
31
32-@@ -623,6 +632,42 @@
33+@@ -623,6 +633,49 @@
34
35
36 /**
37@@ -63,31 +63,38 @@
38 + We have to do it here (see process_event() below) and to suppress
39 + producing USE statements by corresponding log event print-functions.
40 +*/
41-+
42 +void print_use_stmt(PRINT_EVENT_INFO* pinfo, const char* db, size_t db_len)
43 +{
44-+ // pinfo->db is the current db.
45-+ // If current db is the same as required db, do nothing.
46++ /*
47++ pinfo->db is the current db.
48++ If current db is the same as required db, do nothing.
49++ */
50 + if (!db || !memcmp(pinfo->db, db, db_len + 1))
51 + return;
52 +
53-+ // Current db and required db are different.
54-+ // Check for rewrite rule for required db. (Note that in a rewrite rule
55-+ // neither db_from nor db_to part can be empty).
56-+ size_t len_to= 0;
57-+ const char *db_to= binlog_filter->get_rewrite_db(db, &len_to);
58++ /*
59++ Current db and required db are different.
60++ Check for rewrite rule for required db. (Note that in a rewrite rule
61++ neither db_from nor db_to part can be empty)
62++ */
63++ size_t len_to= 0;
64++ const char* db_to= binlog_filter->get_rewrite_db(db, &len_to);
65 +
66-+ // If there is no rewrite rule for db (in this case len_to is left = 0),
67-+ // printing of the corresponding USE statement is left for log event
68-+ // print-function.
69++ /*
70++ If there is no rewrite rule for db (in this case len_to is left = 0),
71++ printing of the corresponding USE statement is left for log event
72++ print-function.
73++ */
74 + if (!len_to)
75 + return;
76 +
77 + // In case of rewrite rule print USE statement for db_to
78 + fprintf(result_file, "use %s%s\n", db_to, pinfo->delimiter);
79 +
80-+ // Copy the *original* db to pinfo to suppress emiting
81-+ // of USE stmts by log_event print-functions.
82++ /*
83++ Copy the *original* db to pinfo to suppress emiting
84++ of USE stmts by log_event print-functions.
85++ */
86 + memcpy(pinfo->db, db, db_len + 1);
87 +}
88 +
89@@ -96,28 +103,33 @@
90 Prints the given event in base64 format.
91
92 The header is printed to the head cache and the body is printed to
93-@@ -741,9 +786,11 @@
94+@@ -741,10 +798,12 @@
95
96 switch (ev_type) {
97 case QUERY_EVENT:
98+- if (!((Query_log_event*)ev)->is_trans_keyword())
99 + {
100 + Query_log_event *qe= (Query_log_event*)ev;
101- if (!((Query_log_event*)ev)->is_trans_keyword())
102++ if (!qe->is_trans_keyword())
103 {
104 - if (shall_skip_database(((Query_log_event*)ev)->db))
105 + if (shall_skip_database(qe->db))
106 goto end;
107 }
108 else
109-@@ -752,6 +799,7 @@
110- // from binary log 5.0, make it compatible with 5.1
111+ {
112+@@ -754,16 +815,18 @@
113+ */
114 ev->flags|= LOG_EVENT_SUPPRESS_USE_F;
115 }
116 + print_use_stmt(print_event_info, qe->db, qe->db_len);
117 if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
118 {
119 if ((retval= write_event_header_and_base64(ev, result_file,
120-@@ -762,6 +810,7 @@
121+ print_event_info)) !=
122+ OK_CONTINUE)
123+ goto end;
124+ }
125 else
126 ev->print(result_file, print_event_info);
127 break;
128@@ -125,7 +137,7 @@
129
130 case CREATE_FILE_EVENT:
131 {
132-@@ -883,6 +932,7 @@
133+@@ -885,6 +952,7 @@
134
135 if (!shall_skip_database(exlq->db))
136 {
137@@ -133,12 +145,13 @@
138 if (fname)
139 {
140 convert_path_to_forward_slashes(fname);
141-@@ -906,6 +956,13 @@
142+@@ -908,6 +976,14 @@
143 destroy_evt= FALSE;
144 goto end;
145 }
146-+ size_t len_to= 0;
147-+ const char* db_to= binlog_filter->get_rewrite_db(map->get_db_name(), &len_to);
148++ size_t len_to= 0;
149++ const char* db_to= binlog_filter->get_rewrite_db(map->get_db_name(),
150++ &len_to);
151 + if (len_to && map->rewrite_db(db_to, len_to, glob_description_event))
152 + {
153 + error("Could not rewrite database name");
154@@ -147,15 +160,16 @@
155 }
156 case WRITE_ROWS_EVENT:
157 case DELETE_ROWS_EVENT:
158-@@ -991,14 +1048,16 @@
159+@@ -993,16 +1069,20 @@
160 retval= ERROR_STOP;
161 end:
162 rec_count++;
163-+
164++
165++
166 /*
167 - Destroy the log_event object. If reading from a remote host,
168 - set the temp_buf to NULL so that memory isn't freed twice.
169-+ Destroy the log_event object.
170++ Destroy the log_event object.
171 + MariaDB MWL#36: mainline does this:
172 + If reading from a remote host,
173 + set the temp_buf to NULL so that memory isn't freed twice.
174@@ -165,10 +179,14 @@
175 {
176 - if (remote_opt)
177 - ev->temp_buf= 0;
178- if (destroy_evt) /* destroy it later if not set (ignored table map) */
179+- if (destroy_evt) /* destroy it later if not set (ignored table map) */
180++ /* destroy it later if not set (ignored table map) */
181++ if (destroy_evt)
182 delete ev;
183 }
184-@@ -1164,6 +1223,10 @@
185+ DBUG_RETURN(retval);
186+ }
187+@@ -1166,6 +1248,10 @@
188 "Used to reserve file descriptors for use by this program.",
189 &open_files_limit, &open_files_limit, 0, GET_ULONG,
190 REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0},
191@@ -179,7 +197,7 @@
192 {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
193 };
194
195-@@ -1355,6 +1418,53 @@
196+@@ -1359,6 +1445,53 @@
197 (find_type_or_exit(argument, &base64_output_mode_typelib, opt->name)-1);
198 }
199 break;
200@@ -187,8 +205,8 @@
201 + {
202 + /* See also handling of OPT_REPLICATE_REWRITE_DB in sql/mysqld.cc */
203 + char* ptr;
204-+ char* key= argument; // db-from
205-+ char* val; // db-to
206++ char* key= argument; // db-from
207++ char* val; // db-to
208 +
209 + // Where key begins
210 + while (*key && my_isspace(&my_charset_latin1, *key))
211@@ -233,7 +251,7 @@
212 case 'v':
213 if (argument == disabled_my_option)
214 verbose= 0;
215-@@ -1628,7 +1738,7 @@
216+@@ -1632,7 +1775,7 @@
217 If reading from a remote host, ensure the temp_buf for the
218 Log_event class is pointing to the incoming stream.
219 */
220@@ -242,7 +260,7 @@
221
222 Log_event_type type= ev->get_type_code();
223 if (glob_description_event->binlog_version >= 3 ||
224-@@ -2028,6 +2138,8 @@
225+@@ -2032,6 +2175,8 @@
226 return retval;
227 }
228
229@@ -251,7 +269,7 @@
230
231 int main(int argc, char** argv)
232 {
233-@@ -2040,6 +2152,13 @@
234+@@ -2044,6 +2189,13 @@
235
236 my_init_time(); // for time functions
237
238@@ -265,7 +283,7 @@
239 if (load_defaults("my", load_default_groups, &argc, &argv))
240 exit(1);
241 defaults_argv= argv;
242-@@ -2128,6 +2247,8 @@
243+@@ -2132,6 +2284,8 @@
244 if (result_file != stdout)
245 my_fclose(result_file, MYF(0));
246 cleanup();
247@@ -274,7 +292,7 @@
248 free_defaults(defaults_argv);
249 my_free_open_file_info();
250 load_processor.destroy();
251-@@ -2139,6 +2260,12 @@
252+@@ -2143,6 +2297,12 @@
253 DBUG_RETURN(retval == ERROR_STOP ? 1 : 0);
254 }
255
256@@ -287,7 +305,7 @@
257 /*
258 We must include this here as it's compiled with different options for
259 the server
260-@@ -2149,4 +2276,7 @@
261+@@ -2153,4 +2313,7 @@
262 #include "my_decimal.cc"
263 #include "log_event.cc"
264 #include "log_event_old.cc"
265@@ -475,9 +493,9 @@
266 *description_event);
267 virtual ~Log_event() { free_temp_buf();}
268 - void register_temp_buf(char* buf) { temp_buf = buf; }
269-+ void register_temp_buf(char* buf, bool must_free)
270-+ {
271-+ temp_buf= buf;
272++ void register_temp_buf(char* buf, bool must_free)
273++ {
274++ temp_buf= buf;
275 + event_owns_temp_buf= must_free;
276 + }
277 void free_temp_buf()
278@@ -490,7 +508,7 @@
279 temp_buf = 0;
280 }
281 }
282-@@ -3358,6 +3370,8 @@
283+@@ -3358,6 +3372,8 @@
284 ulong get_table_id() const { return m_table_id; }
285 const char *get_table_name() const { return m_tblnam; }
286 const char *get_db_name() const { return m_dbnam; }
287@@ -635,3 +653,112 @@
288
289
290 void *sql_calloc(size_t size)
291+--- /dev/null
292++++ b/mysql-test/r/wl36.result
293+@@ -0,0 +1,48 @@
294++CREATE DATABASE a;
295++USE a;
296++CREATE TABLE t1(a INT);
297++CREATE DATABASE b;
298++USE b;
299++CREATE TABLE t1(b INT);
300++CREATE DATABASE c;
301++USE c;
302++CREATE TABLE t1(c INT);
303++RESET MASTER;
304++USE a;
305++INSERT INTO t1 VALUES(0);
306++USE b;
307++INSERT INTO t1 VALUES(1);
308++FLUSH LOGS;
309++#
310++# Apply log with ''
311++#
312++a
313++0
314++b
315++1
316++c
317++#
318++# Apply log with '--rewrite-db="a->c"'
319++#
320++a
321++b
322++1
323++c
324++0
325++#
326++# Apply log with '--rewrite-db="a->b"'
327++#
328++a
329++b
330++0
331++1
332++c
333++USE a;
334++DROP TABLE t1;
335++DROP DATABASE a;
336++USE b;
337++DROP TABLE t1;
338++DROP DATABASE b;
339++USE c;
340++DROP TABLE t1;
341++DROP DATABASE c;
342+--- /dev/null
343++++ b/mysql-test/t/wl36.test
344+@@ -0,0 +1,55 @@
345++#
346++# WL #36: http://askmonty.org/worklog/Server-Sprint/?tid=36
347++# This is basic test for --rewrite-db option.
348++# mysqlbinlog --rewrite-db="from->to" should rewrite database
349++#
350++
351++--source include/have_log_bin.inc
352++
353++CREATE DATABASE a; USE a; CREATE TABLE t1(a INT);
354++
355++CREATE DATABASE b; USE b; CREATE TABLE t1(b INT);
356++
357++CREATE DATABASE c; USE c; CREATE TABLE t1(c INT);
358++
359++RESET MASTER;
360++--let MYSQLD_DATA_DIR=`select @@datadir`
361++--let BIN_LOG_FILE_NAME=query_get_value(show master status, File, 1)
362++--let BIN_LOG_START_POSITION=query_get_value(show master status, Position, 1)
363++USE a; INSERT INTO t1 VALUES(0);
364++USE b; INSERT INTO t1 VALUES(1);
365++--let BIN_LOG_STOP_POSITION=query_get_value(show master status, Position, 1)
366++FLUSH LOGS;
367++
368++--let BIN_LOG_FULL_PATH=`SELECT CONCAT("$MYSQLD_DATA_DIR", "$BIN_LOG_FILE_NAME")`
369++
370++--let i=3
371++# i=3: rewrite nothing
372++# i=2: rewrite a->c
373++# i=0: rewrite a->b
374++--disable_query_log
375++while ($i)
376++{
377++--let REWRITE=`SELECT CASE $i WHEN 3 THEN '' WHEN 2 THEN '--rewrite-db="a->c"' WHEN 1 THEN '--rewrite-db="a->b"' END`
378++
379++USE a; DELETE FROM t1;
380++USE b; DELETE FROM t1;
381++USE c; DELETE FROM t1;
382++
383++--echo #
384++--echo # Apply log with '$REWRITE'
385++--echo #
386++
387++--exec $MYSQL_BINLOG $REWRITE --start-position=$BIN_LOG_START_POSITION --stop-position=$BIN_LOG_STOP_POSITION $BIN_LOG_FULL_PATH | $MYSQL
388++
389++USE a; SELECT * FROM t1;
390++USE b; SELECT * FROM t1;
391++USE c; SELECT * FROM t1;
392++
393++dec $i;
394++}
395++--enable_query_log
396++
397++USE a; DROP TABLE t1; DROP DATABASE a;
398++USE b; DROP TABLE t1; DROP DATABASE b;
399++USE c; DROP TABLE t1; DROP DATABASE c;
400
401=== modified file 'patches/wl47.patch'
402--- patches/wl47.patch 2011-11-17 12:41:18 +0000
403+++ patches/wl47.patch 2012-01-31 08:20:27 +0000
404@@ -116,7 +116,7 @@
405 case TABLE_MAP_EVENT:
406 {
407 Table_map_log_event *map= ((Table_map_log_event *)ev);
408-@@ -956,6 +1034,13 @@
409+@@ -956,5 +1034,12 @@
410 destroy_evt= FALSE;
411 goto end;
412 }
413@@ -127,9 +127,8 @@
414 + */
415 + print_annotate_event(print_event_info);
416 +
417- size_t len_to= 0;
418- const char* db_to= binlog_filter->get_rewrite_db(map->get_db_name(), &len_to);
419- if (len_to && map->rewrite_db(db_to, len_to, glob_description_event))
420+ size_t len_to= 0;
421+ const char* db_to= binlog_filter->get_rewrite_db(map->get_db_name(),
422 @@ -992,6 +1077,13 @@
423 if (print_event_info->m_table_map_ignored.count() > 0)
424 print_event_info->m_table_map_ignored.clear_tables();

Subscribers

People subscribed via source and target branches