· 8 years ago · Mar 08, 2018, 09:10 PM
1manish@Nightfury:~/trunk/valgrind/mysql-trunk$ bzr diff
2=== modified file 'client/mysqlbinlog.cc'
3--- client/mysqlbinlog.cc 2011-08-29 12:08:58 +0000
4+++ client/mysqlbinlog.cc 2011-11-08 12:04:14 +0000
5@@ -48,12 +48,15 @@
6
7 #define BIN_LOG_HEADER_SIZE 4U
8 #define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
9+#define INTVAR_DYNAMIC_INIT 16
10+#define INTVAR_DYNAMIC_INCR 1
11
12
13 #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
14
15 char server_version[SERVER_VERSION_LENGTH];
16 ulong server_id = 0;
17+DYNAMIC_ARRAY buff_ev;
18
19 // needed by net_serv.c
20 ulong bytes_sent = 0L, bytes_received = 0L;
21@@ -724,11 +727,53 @@
22
23 switch (ev_type) {
24 case QUERY_EVENT:
25- if (!((Query_log_event*)ev)->is_trans_keyword() &&
26- shall_skip_database(((Query_log_event*)ev)->db))
27+ {
28+ bool parent_query_skips=
29+ !((Query_log_event*) ev)->is_trans_keyword() &&
30+ shall_skip_database(((Query_log_event*) ev)->db);
31+
32+ if(buff_ev.elements == 0)
33+ {
34+ if (parent_query_skips)
35+ goto end;
36+ ev->print(result_file, print_event_info);
37+ break;
38+ }
39+
40+ for (uint i=0; i < buff_ev.elements; i++)
41+ {
42+ Log_event* temp_ev= (Log_event *) pop_dynamic(&buff_ev);
43+ if (!parent_query_skips)
44+ temp_ev->print(result_file, print_event_info);
45+ delete temp_ev;
46+ }
47+ freeze_size(&buff_ev);
48+ reset_dynamic(&buff_ev);
49+
50+ if (parent_query_skips)
51 goto end;
52 ev->print(result_file, print_event_info);
53 break;
54+ }
55+
56+ case INTVAR_EVENT:
57+ {
58+ insert_dynamic(&buff_ev, (uchar*) ev);
59+ break;
60+ }
61+
62+ case RAND_EVENT:
63+ {
64+ insert_dynamic(&buff_ev, (uchar*) ev);
65+ break;
66+ }
67+
68+ case USER_VAR_EVENT:
69+ {
70+ insert_dynamic(&buff_ev, (uchar*) ev);
71+ break;
72+ }
73+
74
75 case CREATE_FILE_EVENT:
76 {
77@@ -2189,6 +2234,18 @@
78 DBUG_PROCESS(argv[0]);
79
80 my_init_time(); // for time functions
81+ /*
82+ A pointer of type Log_event can point to
83+ INTVAR
84+ USER_VAR
85+ RANDOM
86+ events, when we allocate a element of sizeof(Log_event*)
87+ for the DYNAMIC_ARRAY.
88+ */
89+
90+ if((my_init_dynamic_array(&buff_ev, sizeof(Log_event*),
91+ INTVAR_DYNAMIC_INIT, INTVAR_DYNAMIC_INCR)))
92+ exit(1);
93
94 if (load_defaults("my", load_default_groups, &argc, &argv))
95 exit(1);
96
97=== added file 'mysql-test/suite/rpl/r/rpl_binlog_check.result'
98--- mysql-test/suite/rpl/r/rpl_binlog_check.result 1970-01-01 00:00:00 +0000
99+++ mysql-test/suite/rpl/r/rpl_binlog_check.result 2011-10-10 07:17:02 +0000
100@@ -0,0 +1,19 @@
101+include/master-slave.inc
102+[connection master]
103+include/rpl_reset.inc
104+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
105+use test;
106+drop table if exists foo;
107+create table foo (i int, j int, bar int auto_increment, unique key (bar))
108+engine= innodb;
109+set autocommit= 0;
110+insert into foo (i, j) values (Rand(), @2);
111+commit;
112+drop table if exists foo;
113+# Search for occurrences of SET INSERT_ID in the output from mysqlbinlog
114+# Search for occurrences of RAND in the output from mysqlbinlog
115+# Search for occurrences of USER_VAR in the output from mysqlbinlog
116+- Occurrences: 0
117+- Occurrences: 0
118+- Occurrences: 0
119+include/rpl_end.inc
120
121=== added file 'mysql-test/suite/rpl/t/rpl_binlog_check.test'
122--- mysql-test/suite/rpl/t/rpl_binlog_check.test 1970-01-01 00:00:00 +0000
123+++ mysql-test/suite/rpl/t/rpl_binlog_check.test 2011-11-08 12:19:47 +0000
124@@ -0,0 +1,55 @@
125+# BUG#11746146: 23894: EMYSQLBINLOG OUTPUTS SET INSERT_ID=N STATEMENTS UNNECESARILY WITH --DATABA.
126+#
127+
128+#
129+# mysqlbinlog --database=bar N-bin.000002 >002bar.txt
130+# will output all the SET INSERT_ID=n assignments in the binary log even if the
131+# database bar isn't mentioned in the binary log.
132+#
133+
134+--source include/master-slave.inc
135+--source include/rpl_reset.inc
136+
137+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
138+--sync_slave_with_master
139+use test;
140+--disable_warnings
141+drop table if exists foo;
142+--enable_warnings
143+create table foo (i int, j int, bar int auto_increment, unique key (bar))
144+engine= innodb;
145+set autocommit= 0;
146+--disable_warnings
147+insert into foo (i, j) values (Rand(), @2);
148+--enable_warnings
149+commit;
150+drop table if exists foo;
151+--enable_warnings
152+
153+--let $MYSQLD_DATADIR= `select @@datadir`
154+--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
155+--let $prefix= `select uuid()`
156+--let $out_file= $MYSQLTEST_VARDIR/tmp/$prefix.out
157+--exec $MYSQL_BINLOG --database=bar $MYSQLD_DATADIR/$binlog_file >$out_file
158+
159+--let OUTF= $out_file
160+
161+--echo # Search for occurrences of SET INSERT_ID in the output from mysqlbinlog
162+--echo # Search for occurrences of RAND in the output from mysqlbinlog
163+--echo # Search for occurrences of USER_VAR in the output from mysqlbinlog
164+
165+perl;
166+ use strict;
167+ my $outf= $ENV{'OUTF'} or die "OUTF not set";
168+ open(FILE, "$outf") or die("Unable to open $outf: $!\n");
169+ my $count_intvar = () = grep(/SET INSERT_ID/gi,<FILE>);
170+ my $count_rand = () = grep(/RAND/gi,<FILE>);
171+ my $count_user_var = () = grep(/User_var/gi,<FILE>);
172+ print "- Occurrences: $count_intvar\n";
173+ print "- Occurrences: $count_rand\n";
174+ print "- Occurrences: $count_user_var\n";
175+ close(FILE);
176+EOF
177+
178+--remove_file $out_file
179+--source include/rpl_end.inc