Merge lp:~vlad-lesin/percona-server/5.5-bug1049871-injections into lp:percona-server/5.5

Proposed by Vlad Lesin
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 384
Proposed branch: lp:~vlad-lesin/percona-server/5.5-bug1049871-injections
Merge into: lp:percona-server/5.5
Diff against target: 3353 lines (+1256/-507)
42 files modified
Percona-Server/client/CMakeLists.txt (+1/-1)
Percona-Server/client/sql_string.cc (+44/-0)
Percona-Server/client/sql_string.h (+10/-0)
Percona-Server/mysql-test/r/func_compress.result (+2/-2)
Percona-Server/mysql-test/r/func_math.result (+4/-4)
Percona-Server/mysql-test/r/mysqlbinlog.result (+16/-16)
Percona-Server/mysql-test/r/mysqlbinlog2.result (+35/-35)
Percona-Server/mysql-test/r/mysqlbinlog_row.result (+1/-1)
Percona-Server/mysql-test/r/mysqlbinlog_row_innodb.result (+4/-4)
Percona-Server/mysql-test/r/mysqlbinlog_row_myisam.result (+4/-4)
Percona-Server/mysql-test/r/mysqlbinlog_row_trans.result (+1/-1)
Percona-Server/mysql-test/r/user_var-binlog.result (+1/-1)
Percona-Server/mysql-test/r/variables.result (+1/-1)
Percona-Server/mysql-test/suite/binlog/r/binlog_base64_flag.result (+1/-1)
Percona-Server/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result (+1/-1)
Percona-Server/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result (+2/-2)
Percona-Server/mysql-test/suite/rpl/r/rpl_mdev382.result (+326/-0)
Percona-Server/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result (+4/-4)
Percona-Server/mysql-test/suite/rpl/r/rpl_sp.result (+6/-6)
Percona-Server/mysql-test/suite/rpl/t/rpl_mdev382.test (+256/-0)
Percona-Server/sql/ha_ndbcluster_binlog.cc (+17/-8)
Percona-Server/sql/item.cc (+17/-1)
Percona-Server/sql/item.h (+1/-0)
Percona-Server/sql/item_func.cc (+3/-3)
Percona-Server/sql/item_func.h (+1/-1)
Percona-Server/sql/log.cc (+6/-6)
Percona-Server/sql/log_event.cc (+258/-204)
Percona-Server/sql/log_event.h (+25/-22)
Percona-Server/sql/log_event_old.cc (+1/-1)
Percona-Server/sql/log_event_old.h (+1/-1)
Percona-Server/sql/sql_base.cc (+24/-13)
Percona-Server/sql/sql_db.cc (+19/-29)
Percona-Server/sql/sql_load.cc (+37/-54)
Percona-Server/sql/sql_repl.cc (+1/-1)
Percona-Server/sql/sql_select.cc (+11/-2)
Percona-Server/sql/sql_show.cc (+6/-37)
Percona-Server/sql/sql_show.h (+1/-1)
Percona-Server/sql/sql_string.cc (+61/-10)
Percona-Server/sql/sql_string.h (+11/-0)
Percona-Server/sql/sql_table.cc (+11/-10)
Percona-Server/sql/sql_truncate.cc (+23/-18)
Percona-Server/sql/sql_yacc.yy (+1/-1)
To merge this branch: bzr merge lp:~vlad-lesin/percona-server/5.5-bug1049871-injections
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Laurynas Biveinis (community) Approve
Review via email: mp+127723@code.launchpad.net

Description of the change

The fix for bug #1049871.

Jenkins build:
http://jenkins.percona.com/view/PS 5.5/job/percona-server-5.5-param/529

The original patch is here:
http://bazaar.launchpad.net/~maria-captains/maria/5.5/revision/3508

The difference between original patch and this one is this patch doesn't
use custom %`s "printf" specifier for identifiers quoting. Using that specifier
leads to compiller warnings/errors. That warnings/errors could be suppressed
with certain compiler options but such approach can lead to runtime errors
in the code that is not checked on valid printf specifiers. Besides that
the original patch contains two quoting functions (one for mysqlsql string
class and one for mysql prinf functions) which leads to necessity to edit
two places if something should be changed in quoting function.

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

This is only a partial review.

   - The commit message for 5.5 should just say "merge|automerge|some
     other merge from 5.1" and describe the differences, if any,
     from the 5.1 version. This way it becomes easier to tell
     merges/new patches apart in the bzr log.
   - #if 0 block in sql_insert.cc
   - Same comments as for 5.1 version, except that formatting issue at
     1177-1178.

review: Needs Fixing
Revision history for this message
Vlad Lesin (vlad-lesin) wrote :

> - The commit message for 5.5 should just say "merge|automerge|some
> other merge from 5.1" and describe the differences, if any,
> from the 5.1 version. This way it becomes easier to tell
> merges/new patches apart in the bzr log.
> - #if 0 block in sql_insert.cc
> - Same comments as for 5.1 version, except that formatting issue at
> 1177-1178.
Done.

Revision history for this message
Vlad Lesin (vlad-lesin) wrote :
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Looks good to me. This is still a partial review, please coordinate with Stewart on how to proceed.

review: Approve
Revision history for this message
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/client/CMakeLists.txt'
2--- Percona-Server/client/CMakeLists.txt 2012-02-16 09:48:16 +0000
3+++ Percona-Server/client/CMakeLists.txt 2012-10-10 20:41:51 +0000
4@@ -57,7 +57,7 @@
5 MYSQL_ADD_EXECUTABLE(mysql_plugin mysql_plugin.c)
6 TARGET_LINK_LIBRARIES(mysql_plugin mysqlclient)
7
8-MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc)
9+MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc sql_string.cc)
10 TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient)
11
12 MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
13
14=== modified file 'Percona-Server/client/sql_string.cc'
15--- Percona-Server/client/sql_string.cc 2012-05-10 07:49:14 +0000
16+++ Percona-Server/client/sql_string.cc 2012-10-10 20:41:51 +0000
17@@ -478,6 +478,50 @@
18 return FALSE;
19 }
20
21+bool String::append_identifier(const char *name,
22+ uint length,
23+ CHARSET_INFO *ci,
24+ int quote_char)
25+{
26+ const char *name_end;
27+ char q= (char)quote_char;
28+ CHARSET_INFO *lci = ci ? ci : charset();
29+
30+ if (quote_char == EOF)
31+ return append(name, length, charset());
32+
33+ /*
34+ The identifier must be quoted as it includes a quote character or
35+ it's a keyword
36+ */
37+
38+ (void)reserve(length*2 + 2);
39+ if (append(&q, 1, lci))
40+ return true;
41+
42+ for (name_end= name+length ; name < name_end ; name+= length)
43+ {
44+ uchar chr= (uchar) *name;
45+ length= my_mbcharlen(lci, chr);
46+ /*
47+ my_mbcharlen can return 0 on a wrong multibyte
48+ sequence. It is possible when upgrading from 4.0,
49+ and identifier contains some accented characters.
50+ The manual says it does not work. So we'll just
51+ change length to 1 not to hang in the endless loop.
52+ */
53+ if (!length)
54+ length= 1;
55+ if (length == 1 && chr == (uchar) q &&
56+ append(&q, 1, lci))
57+ return true;
58+ if (append(name, length, lci))
59+ return true;
60+ }
61+ return append(&q, 1, lci);
62+}
63+
64+
65 uint32 String::numchars()
66 {
67 return str_charset->cset->numchars(str_charset, Ptr, Ptr+str_length);
68
69=== modified file 'Percona-Server/client/sql_string.h'
70--- Percona-Server/client/sql_string.h 2012-05-10 07:49:14 +0000
71+++ Percona-Server/client/sql_string.h 2012-10-10 20:41:51 +0000
72@@ -22,6 +22,12 @@
73 #pragma interface /* gcc class implementation */
74 #endif
75
76+#define QUOTED_IDENTIFIER(str_name, buf_size, q, cs, id_name, id_size) \
77+ char buf_##str_name[(buf_size)]; \
78+ String str_name((buf_##str_name), (buf_size), (cs)); \
79+ str_name.length(0); \
80+ str_name.append_identifier((id_name), (id_size), (cs), (q));
81+
82 class String;
83 int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
84 String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
85@@ -244,6 +250,10 @@
86 bool append(IO_CACHE* file, uint32 arg_length);
87 bool append_with_prefill(const char *s, uint32 arg_length,
88 uint32 full_length, char fill_char);
89+ bool append_identifier(const char *name,
90+ uint length,
91+ CHARSET_INFO *ci,
92+ int quote_char);
93 int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
94 int strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
95 bool replace(uint32 offset,uint32 arg_length,const char *to,uint32 length);
96
97=== modified file 'Percona-Server/mysql-test/r/func_compress.result'
98--- Percona-Server/mysql-test/r/func_compress.result 2009-09-10 09:18:29 +0000
99+++ Percona-Server/mysql-test/r/func_compress.result 2012-10-10 20:41:51 +0000
100@@ -11,7 +11,7 @@
101 id select_type table type possible_keys key key_len ref rows filtered Extra
102 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
103 Warnings:
104-Note 1003 select uncompress(compress((@test_compress_string))) AS `uncompress(compress(@test_compress_string))`
105+Note 1003 select uncompress(compress((@`test_compress_string`))) AS `uncompress(compress(@test_compress_string))`
106 select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
107 uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)
108 1
109@@ -19,7 +19,7 @@
110 id select_type table type possible_keys key key_len ref rows filtered Extra
111 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
112 Warnings:
113-Note 1003 select (uncompressed_length(compress((@test_compress_string))) = length((@test_compress_string))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)`
114+Note 1003 select (uncompressed_length(compress((@`test_compress_string`))) = length((@`test_compress_string`))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)`
115 select uncompressed_length(compress(@test_compress_string));
116 uncompressed_length(compress(@test_compress_string))
117 117
118
119=== modified file 'Percona-Server/mysql-test/r/func_math.result'
120--- Percona-Server/mysql-test/r/func_math.result 2011-07-18 09:21:14 +0000
121+++ Percona-Server/mysql-test/r/func_math.result 2012-10-10 20:41:51 +0000
122@@ -638,13 +638,13 @@
123 DROP TABLE t1;
124 SET @a:=999999999999999999999999999999999999999999999999999999999999999999999999999999999;
125 SELECT @a + @a;
126-ERROR 22003: DECIMAL value is out of range in '((@a) + (@a))'
127+ERROR 22003: DECIMAL value is out of range in '((@`a`) + (@`a`))'
128 SELECT @a * @a;
129-ERROR 22003: DECIMAL value is out of range in '((@a) * (@a))'
130+ERROR 22003: DECIMAL value is out of range in '((@`a`) * (@`a`))'
131 SELECT -@a - @a;
132-ERROR 22003: DECIMAL value is out of range in '(-((@a)) - (@a))'
133+ERROR 22003: DECIMAL value is out of range in '(-((@`a`)) - (@`a`))'
134 SELECT @a / 0.5;
135-ERROR 22003: DECIMAL value is out of range in '((@a) / 0.5)'
136+ERROR 22003: DECIMAL value is out of range in '((@`a`) / 0.5)'
137 SELECT COT(1/0);
138 COT(1/0)
139 NULL
140
141=== modified file 'Percona-Server/mysql-test/r/mysqlbinlog.result'
142--- Percona-Server/mysql-test/r/mysqlbinlog.result 2012-05-10 07:49:14 +0000
143+++ Percona-Server/mysql-test/r/mysqlbinlog.result 2012-10-10 20:41:51 +0000
144@@ -18,7 +18,7 @@
145 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
146 DELIMITER /*!*/;
147 ROLLBACK/*!*/;
148-use test/*!*/;
149+use `test`/*!*/;
150 SET TIMESTAMP=1000000000/*!*/;
151 SET @@session.pseudo_thread_id=999999999/*!*/;
152 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
153@@ -111,7 +111,7 @@
154 SET @@session.collation_database=DEFAULT/*!*/;
155 BEGIN
156 /*!*/;
157-use test/*!*/;
158+use `test`/*!*/;
159 SET TIMESTAMP=1000000000/*!*/;
160 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
161 /*!*/;
162@@ -202,7 +202,7 @@
163 SET @@session.collation_database=DEFAULT/*!*/;
164 BEGIN
165 /*!*/;
166-use test/*!*/;
167+use `test`/*!*/;
168 SET TIMESTAMP=1000000000/*!*/;
169 insert into t1 values ("Alas")
170 /*!*/;
171@@ -219,7 +219,7 @@
172 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
173 DELIMITER /*!*/;
174 ROLLBACK/*!*/;
175-use test/*!*/;
176+use `test`/*!*/;
177 SET TIMESTAMP=1000000000/*!*/;
178 SET @@session.pseudo_thread_id=999999999/*!*/;
179 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
180@@ -312,7 +312,7 @@
181 SET @@session.collation_database=DEFAULT/*!*/;
182 BEGIN
183 /*!*/;
184-use test/*!*/;
185+use `test`/*!*/;
186 SET TIMESTAMP=1000000000/*!*/;
187 LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
188 /*!*/;
189@@ -403,7 +403,7 @@
190 SET @@session.collation_database=DEFAULT/*!*/;
191 BEGIN
192 /*!*/;
193-use test/*!*/;
194+use `test`/*!*/;
195 SET TIMESTAMP=1000000000/*!*/;
196 insert into t1 values ("Alas")
197 /*!*/;
198@@ -420,7 +420,7 @@
199 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
200 DELIMITER /*!*/;
201 ROLLBACK/*!*/;
202-use test/*!*/;
203+use `test`/*!*/;
204 SET TIMESTAMP=1108844556/*!*/;
205 SET @@session.pseudo_thread_id=999999999/*!*/;
206 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
207@@ -438,7 +438,7 @@
208 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
209 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
210 DELIMITER /*!*/;
211-use test/*!*/;
212+use `test`/*!*/;
213 SET TIMESTAMP=1108844556/*!*/;
214 SET @@session.pseudo_thread_id=999999999/*!*/;
215 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
216@@ -498,7 +498,7 @@
217 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
218 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
219 DELIMITER /*!*/;
220-use test/*!*/;
221+use `test`/*!*/;
222 SET TIMESTAMP=1000000000/*!*/;
223 SET @@session.pseudo_thread_id=999999999/*!*/;
224 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
225@@ -548,7 +548,7 @@
226 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
227 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
228 DELIMITER /*!*/;
229-use test/*!*/;
230+use `test`/*!*/;
231 SET TIMESTAMP=1000000000/*!*/;
232 SET @@session.pseudo_thread_id=999999999/*!*/;
233 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
234@@ -725,7 +725,7 @@
235 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
236 DELIMITER /*!*/;
237 ROLLBACK/*!*/;
238-use test/*!*/;
239+use `test`/*!*/;
240 SET TIMESTAMP=1253783037/*!*/;
241 SET @@session.pseudo_thread_id=999999999/*!*/;
242 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
243@@ -822,22 +822,22 @@
244 SET @@session.collation_database=DEFAULT/*!*/;
245 BEGIN
246 /*!*/;
247-use test/*!*/;
248+use `test`/*!*/;
249 SET TIMESTAMP=1266652094/*!*/;
250 SavePoint mixed_cases
251 /*!*/;
252-use db1/*!*/;
253+use `db1`/*!*/;
254 SET TIMESTAMP=1266652094/*!*/;
255 INSERT INTO db1.t2 VALUES("in savepoint mixed_cases")
256 /*!*/;
257 SET TIMESTAMP=1266652094/*!*/;
258 INSERT INTO db1.t1 VALUES(40)
259 /*!*/;
260-use test/*!*/;
261+use `test`/*!*/;
262 SET TIMESTAMP=1266652094/*!*/;
263 ROLLBACK TO mixed_cases
264 /*!*/;
265-use db1/*!*/;
266+use `db1`/*!*/;
267 SET TIMESTAMP=1266652094/*!*/;
268 INSERT INTO db1.t2 VALUES("after rollback to")
269 /*!*/;
270@@ -865,7 +865,7 @@
271 SET @@session.collation_database=DEFAULT/*!*/;
272 BEGIN
273 /*!*/;
274-use test/*!*/;
275+use `test`/*!*/;
276 SET TIMESTAMP=1266652094/*!*/;
277 SavePoint mixed_cases
278 /*!*/;
279
280=== modified file 'Percona-Server/mysql-test/r/mysqlbinlog2.result'
281--- Percona-Server/mysql-test/r/mysqlbinlog2.result 2010-01-07 15:39:11 +0000
282+++ Percona-Server/mysql-test/r/mysqlbinlog2.result 2012-10-10 20:41:51 +0000
283@@ -19,7 +19,7 @@
284 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
285 DELIMITER /*!*/;
286 ROLLBACK/*!*/;
287-use test/*!*/;
288+use `test`/*!*/;
289 SET TIMESTAMP=1579609942/*!*/;
290 SET @@session.pseudo_thread_id=999999999/*!*/;
291 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
292@@ -103,7 +103,7 @@
293 BEGIN
294 /*!*/;
295 SET INSERT_ID=1/*!*/;
296-use test/*!*/;
297+use `test`/*!*/;
298 SET TIMESTAMP=1579609942/*!*/;
299 insert into t1 values(null, "a")
300 /*!*/;
301@@ -172,7 +172,7 @@
302 BEGIN
303 /*!*/;
304 SET INSERT_ID=3/*!*/;
305-use test/*!*/;
306+use `test`/*!*/;
307 SET TIMESTAMP=1579609944/*!*/;
308 insert into t1 values(null, "c")
309 /*!*/;
310@@ -209,7 +209,7 @@
311 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
312 DELIMITER /*!*/;
313 ROLLBACK/*!*/;
314-use test/*!*/;
315+use `test`/*!*/;
316 SET TIMESTAMP=1579609942/*!*/;
317 SET @@session.pseudo_thread_id=999999999/*!*/;
318 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
319@@ -263,7 +263,7 @@
320 BEGIN
321 /*!*/;
322 SET INSERT_ID=3/*!*/;
323-use test/*!*/;
324+use `test`/*!*/;
325 SET TIMESTAMP=1579609944/*!*/;
326 insert into t1 values(null, "c")
327 /*!*/;
328@@ -289,7 +289,7 @@
329 BEGIN
330 /*!*/;
331 SET INSERT_ID=3/*!*/;
332-use test/*!*/;
333+use `test`/*!*/;
334 SET TIMESTAMP=1579609944/*!*/;
335 insert into t1 values(null, "c")
336 /*!*/;
337@@ -326,7 +326,7 @@
338 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
339 DELIMITER /*!*/;
340 ROLLBACK/*!*/;
341-use test/*!*/;
342+use `test`/*!*/;
343 SET TIMESTAMP=1579609942/*!*/;
344 SET @@session.pseudo_thread_id=999999999/*!*/;
345 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
346@@ -369,7 +369,7 @@
347 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
348 DELIMITER /*!*/;
349 ROLLBACK/*!*/;
350-use test/*!*/;
351+use `test`/*!*/;
352 SET TIMESTAMP=1579609942/*!*/;
353 SET @@session.pseudo_thread_id=999999999/*!*/;
354 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
355@@ -445,7 +445,7 @@
356 BEGIN
357 /*!*/;
358 SET INSERT_ID=6/*!*/;
359-use test/*!*/;
360+use `test`/*!*/;
361 SET TIMESTAMP=1579609943/*!*/;
362 insert into t1 values(null, "f")
363 /*!*/;
364@@ -474,7 +474,7 @@
365 BEGIN
366 /*!*/;
367 SET INSERT_ID=1/*!*/;
368-use test/*!*/;
369+use `test`/*!*/;
370 SET TIMESTAMP=1579609942/*!*/;
371 insert into t1 values(null, "a")
372 /*!*/;
373@@ -535,7 +535,7 @@
374 BEGIN
375 /*!*/;
376 SET INSERT_ID=6/*!*/;
377-use test/*!*/;
378+use `test`/*!*/;
379 SET TIMESTAMP=1579609943/*!*/;
380 insert into t1 values(null, "f")
381 /*!*/;
382@@ -564,7 +564,7 @@
383 BEGIN
384 /*!*/;
385 SET INSERT_ID=3/*!*/;
386-use test/*!*/;
387+use `test`/*!*/;
388 SET TIMESTAMP=1579609944/*!*/;
389 insert into t1 values(null, "c")
390 /*!*/;
391@@ -605,7 +605,7 @@
392 BEGIN
393 /*!*/;
394 SET INSERT_ID=6/*!*/;
395-use test/*!*/;
396+use `test`/*!*/;
397 SET TIMESTAMP=1579609943/*!*/;
398 insert into t1 values(null, "f")
399 /*!*/;
400@@ -622,7 +622,7 @@
401 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
402 DELIMITER /*!*/;
403 ROLLBACK/*!*/;
404-use test/*!*/;
405+use `test`/*!*/;
406 SET TIMESTAMP=1579609942/*!*/;
407 SET @@session.pseudo_thread_id=999999999/*!*/;
408 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
409@@ -720,7 +720,7 @@
410 BEGIN
411 /*!*/;
412 SET INSERT_ID=3/*!*/;
413-use test/*!*/;
414+use `test`/*!*/;
415 SET TIMESTAMP=1579609944/*!*/;
416 insert into t1 values(null, "c")
417 /*!*/;
418@@ -761,7 +761,7 @@
419 BEGIN
420 /*!*/;
421 SET INSERT_ID=6/*!*/;
422-use test/*!*/;
423+use `test`/*!*/;
424 SET TIMESTAMP=1579609943/*!*/;
425 insert into t1 values(null, "f")
426 /*!*/;
427@@ -778,7 +778,7 @@
428 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
429 DELIMITER /*!*/;
430 ROLLBACK/*!*/;
431-use test/*!*/;
432+use `test`/*!*/;
433 SET TIMESTAMP=1579609942/*!*/;
434 SET @@session.pseudo_thread_id=999999999/*!*/;
435 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
436@@ -820,7 +820,7 @@
437 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
438 DELIMITER /*!*/;
439 ROLLBACK/*!*/;
440-use test/*!*/;
441+use `test`/*!*/;
442 SET TIMESTAMP=1579609942/*!*/;
443 SET @@session.pseudo_thread_id=999999999/*!*/;
444 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
445@@ -904,7 +904,7 @@
446 BEGIN
447 /*!*/;
448 SET INSERT_ID=1/*!*/;
449-use test/*!*/;
450+use `test`/*!*/;
451 SET TIMESTAMP=1579609942/*!*/;
452 insert into t1 values(null, "a")
453 /*!*/;
454@@ -972,7 +972,7 @@
455 BEGIN
456 /*!*/;
457 SET INSERT_ID=3/*!*/;
458-use test/*!*/;
459+use `test`/*!*/;
460 SET TIMESTAMP=1579609944/*!*/;
461 insert into t1 values(null, "c")
462 /*!*/;
463@@ -1009,7 +1009,7 @@
464 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
465 DELIMITER /*!*/;
466 ROLLBACK/*!*/;
467-use test/*!*/;
468+use `test`/*!*/;
469 SET TIMESTAMP=1579609942/*!*/;
470 SET @@session.pseudo_thread_id=999999999/*!*/;
471 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
472@@ -1062,7 +1062,7 @@
473 BEGIN
474 /*!*/;
475 SET INSERT_ID=3/*!*/;
476-use test/*!*/;
477+use `test`/*!*/;
478 SET TIMESTAMP=1579609944/*!*/;
479 insert into t1 values(null, "c")
480 /*!*/;
481@@ -1088,7 +1088,7 @@
482 BEGIN
483 /*!*/;
484 SET INSERT_ID=3/*!*/;
485-use test/*!*/;
486+use `test`/*!*/;
487 SET TIMESTAMP=1579609944/*!*/;
488 insert into t1 values(null, "c")
489 /*!*/;
490@@ -1125,7 +1125,7 @@
491 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
492 DELIMITER /*!*/;
493 ROLLBACK/*!*/;
494-use test/*!*/;
495+use `test`/*!*/;
496 SET TIMESTAMP=1579609942/*!*/;
497 SET @@session.pseudo_thread_id=999999999/*!*/;
498 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
499@@ -1167,7 +1167,7 @@
500 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
501 DELIMITER /*!*/;
502 ROLLBACK/*!*/;
503-use test/*!*/;
504+use `test`/*!*/;
505 SET TIMESTAMP=1579609942/*!*/;
506 SET @@session.pseudo_thread_id=999999999/*!*/;
507 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
508@@ -1243,7 +1243,7 @@
509 BEGIN
510 /*!*/;
511 SET INSERT_ID=6/*!*/;
512-use test/*!*/;
513+use `test`/*!*/;
514 SET TIMESTAMP=1579609943/*!*/;
515 insert into t1 values(null, "f")
516 /*!*/;
517@@ -1272,7 +1272,7 @@
518 BEGIN
519 /*!*/;
520 SET INSERT_ID=1/*!*/;
521-use test/*!*/;
522+use `test`/*!*/;
523 SET TIMESTAMP=1579609942/*!*/;
524 insert into t1 values(null, "a")
525 /*!*/;
526@@ -1333,7 +1333,7 @@
527 BEGIN
528 /*!*/;
529 SET INSERT_ID=6/*!*/;
530-use test/*!*/;
531+use `test`/*!*/;
532 SET TIMESTAMP=1579609943/*!*/;
533 insert into t1 values(null, "f")
534 /*!*/;
535@@ -1361,7 +1361,7 @@
536 BEGIN
537 /*!*/;
538 SET INSERT_ID=3/*!*/;
539-use test/*!*/;
540+use `test`/*!*/;
541 SET TIMESTAMP=1579609944/*!*/;
542 insert into t1 values(null, "c")
543 /*!*/;
544@@ -1402,7 +1402,7 @@
545 BEGIN
546 /*!*/;
547 SET INSERT_ID=6/*!*/;
548-use test/*!*/;
549+use `test`/*!*/;
550 SET TIMESTAMP=1579609943/*!*/;
551 insert into t1 values(null, "f")
552 /*!*/;
553@@ -1419,7 +1419,7 @@
554 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
555 DELIMITER /*!*/;
556 ROLLBACK/*!*/;
557-use test/*!*/;
558+use `test`/*!*/;
559 SET TIMESTAMP=1579609942/*!*/;
560 SET @@session.pseudo_thread_id=999999999/*!*/;
561 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
562@@ -1516,7 +1516,7 @@
563 BEGIN
564 /*!*/;
565 SET INSERT_ID=3/*!*/;
566-use test/*!*/;
567+use `test`/*!*/;
568 SET TIMESTAMP=1579609944/*!*/;
569 insert into t1 values(null, "c")
570 /*!*/;
571@@ -1557,7 +1557,7 @@
572 BEGIN
573 /*!*/;
574 SET INSERT_ID=6/*!*/;
575-use test/*!*/;
576+use `test`/*!*/;
577 SET TIMESTAMP=1579609943/*!*/;
578 insert into t1 values(null, "f")
579 /*!*/;
580@@ -1574,7 +1574,7 @@
581 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
582 DELIMITER /*!*/;
583 ROLLBACK/*!*/;
584-use test/*!*/;
585+use `test`/*!*/;
586 SET TIMESTAMP=1579609942/*!*/;
587 SET @@session.pseudo_thread_id=999999999/*!*/;
588 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
589@@ -1616,7 +1616,7 @@
590 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
591 DELIMITER /*!*/;
592 ROLLBACK/*!*/;
593-use test/*!*/;
594+use `test`/*!*/;
595 SET TIMESTAMP=1579609942/*!*/;
596 SET @@session.pseudo_thread_id=999999999/*!*/;
597 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
598
599=== modified file 'Percona-Server/mysql-test/r/mysqlbinlog_row.result'
600--- Percona-Server/mysql-test/r/mysqlbinlog_row.result 2010-08-23 22:31:12 +0000
601+++ Percona-Server/mysql-test/r/mysqlbinlog_row.result 2012-10-10 20:41:51 +0000
602@@ -336,7 +336,7 @@
603 ROLLBACK/*!*/;
604 # at #
605 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
606-use test/*!*/;
607+use `test`/*!*/;
608 SET TIMESTAMP=1000000000/*!*/;
609 SET @@session.pseudo_thread_id=#/*!*/;
610 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
611
612=== modified file 'Percona-Server/mysql-test/r/mysqlbinlog_row_innodb.result'
613--- Percona-Server/mysql-test/r/mysqlbinlog_row_innodb.result 2010-03-24 15:03:44 +0000
614+++ Percona-Server/mysql-test/r/mysqlbinlog_row_innodb.result 2012-10-10 20:41:51 +0000
615@@ -2253,7 +2253,7 @@
616 ROLLBACK/*!*/;
617 # at #
618 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
619-use test/*!*/;
620+use `test`/*!*/;
621 SET TIMESTAMP=1000000000/*!*/;
622 SET @@session.pseudo_thread_id=#/*!*/;
623 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
624@@ -3876,7 +3876,7 @@
625 ROLLBACK/*!*/;
626 # at #
627 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
628-use test/*!*/;
629+use `test`/*!*/;
630 SET TIMESTAMP=1000000000/*!*/;
631 SET @@session.pseudo_thread_id=#/*!*/;
632 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
633@@ -4243,7 +4243,7 @@
634 ROLLBACK/*!*/;
635 # at #
636 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
637-use test/*!*/;
638+use `test`/*!*/;
639 SET TIMESTAMP=1000000000/*!*/;
640 SET @@session.pseudo_thread_id=#/*!*/;
641 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
642@@ -4804,7 +4804,7 @@
643 ROLLBACK/*!*/;
644 # at #
645 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
646-use test/*!*/;
647+use `test`/*!*/;
648 SET TIMESTAMP=1000000000/*!*/;
649 SET @@session.pseudo_thread_id=#/*!*/;
650 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
651
652=== modified file 'Percona-Server/mysql-test/r/mysqlbinlog_row_myisam.result'
653--- Percona-Server/mysql-test/r/mysqlbinlog_row_myisam.result 2010-03-12 12:42:30 +0000
654+++ Percona-Server/mysql-test/r/mysqlbinlog_row_myisam.result 2012-10-10 20:41:51 +0000
655@@ -2253,7 +2253,7 @@
656 ROLLBACK/*!*/;
657 # at #
658 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
659-use test/*!*/;
660+use `test`/*!*/;
661 SET TIMESTAMP=1000000000/*!*/;
662 SET @@session.pseudo_thread_id=#/*!*/;
663 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
664@@ -3898,7 +3898,7 @@
665 ROLLBACK/*!*/;
666 # at #
667 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
668-use test/*!*/;
669+use `test`/*!*/;
670 SET TIMESTAMP=1000000000/*!*/;
671 SET @@session.pseudo_thread_id=#/*!*/;
672 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
673@@ -4271,7 +4271,7 @@
674 ROLLBACK/*!*/;
675 # at #
676 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
677-use test/*!*/;
678+use `test`/*!*/;
679 SET TIMESTAMP=1000000000/*!*/;
680 SET @@session.pseudo_thread_id=#/*!*/;
681 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
682@@ -4842,7 +4842,7 @@
683 ROLLBACK/*!*/;
684 # at #
685 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
686-use test/*!*/;
687+use `test`/*!*/;
688 SET TIMESTAMP=1000000000/*!*/;
689 SET @@session.pseudo_thread_id=#/*!*/;
690 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
691
692=== modified file 'Percona-Server/mysql-test/r/mysqlbinlog_row_trans.result'
693--- Percona-Server/mysql-test/r/mysqlbinlog_row_trans.result 2010-01-07 15:39:11 +0000
694+++ Percona-Server/mysql-test/r/mysqlbinlog_row_trans.result 2012-10-10 20:41:51 +0000
695@@ -132,7 +132,7 @@
696 ROLLBACK/*!*/;
697 # at #
698 #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
699-use test/*!*/;
700+use `test`/*!*/;
701 SET TIMESTAMP=1000000000/*!*/;
702 SET @@session.pseudo_thread_id=#/*!*/;
703 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
704
705=== modified file 'Percona-Server/mysql-test/r/user_var-binlog.result'
706--- Percona-Server/mysql-test/r/user_var-binlog.result 2010-01-07 15:39:11 +0000
707+++ Percona-Server/mysql-test/r/user_var-binlog.result 2012-10-10 20:41:51 +0000
708@@ -34,7 +34,7 @@
709 BEGIN
710 /*!*/;
711 SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`/*!*/;
712-use test/*!*/;
713+use `test`/*!*/;
714 SET TIMESTAMP=10000/*!*/;
715 INSERT INTO t1 VALUES(@`a b`)
716 /*!*/;
717
718=== modified file 'Percona-Server/mysql-test/r/variables.result'
719--- Percona-Server/mysql-test/r/variables.result 2011-03-28 10:57:54 +0000
720+++ Percona-Server/mysql-test/r/variables.result 2012-10-10 20:41:51 +0000
721@@ -77,7 +77,7 @@
722 id select_type table type possible_keys key key_len ref rows filtered Extra
723 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
724 Warnings:
725-Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@t1) AS `@t1`,(@t2) AS `@t2`,(@t3) AS `@t3`
726+Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@`t1`) AS `@t1`,(@`t2`) AS `@t2`,(@`t3`) AS `@t3`
727 select @t5;
728 @t5
729 1.23456
730
731=== modified file 'Percona-Server/mysql-test/suite/binlog/r/binlog_base64_flag.result'
732--- Percona-Server/mysql-test/suite/binlog/r/binlog_base64_flag.result 2011-02-23 11:54:58 +0000
733+++ Percona-Server/mysql-test/suite/binlog/r/binlog_base64_flag.result 2012-10-10 20:41:51 +0000
734@@ -35,7 +35,7 @@
735 # at 4
736 <#>ROLLBACK/*!*/;
737 # at 102
738-<#>use test/*!*/;
739+<#>use `test`/*!*/;
740 SET TIMESTAMP=1196959712/*!*/;
741 <#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
742 SET @@session.sql_mode=0/*!*/;
743
744=== modified file 'Percona-Server/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result'
745--- Percona-Server/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2010-01-07 15:39:11 +0000
746+++ Percona-Server/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2012-10-10 20:41:51 +0000
747@@ -26,7 +26,7 @@
748 BEGIN
749 /*!*/;
750 SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/;
751-use test/*!*/;
752+use `test`/*!*/;
753 SET TIMESTAMP=10000/*!*/;
754 insert into t2 values (@v)
755 /*!*/;
756
757=== modified file 'Percona-Server/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result'
758--- Percona-Server/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2011-05-12 04:56:41 +0000
759+++ Percona-Server/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2012-10-10 20:41:51 +0000
760@@ -698,7 +698,7 @@
761 master-bin.000001 # Intvar # # INSERT_ID=10
762 master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
763 master-bin.000001 # Intvar # # INSERT_ID=10
764-master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`= @b + bug27417(2) ;file_id=#
765+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= @b + bug27417(2) ;file_id=#
766 master-bin.000001 # Query # # ROLLBACK
767 /* the output must denote there is the query */;
768 drop trigger trg_del_t2;
769@@ -950,7 +950,7 @@
770 master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
771 master-bin.000001 # Intvar # # INSERT_ID=10
772 master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
773-master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`= @b + bug27417(2) ;file_id=#
774+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= @b + bug27417(2) ;file_id=#
775 master-bin.000001 # Query # # ROLLBACK
776 drop trigger trg_del_t2;
777 drop table t1,t2,t3,t4,t5;
778
779=== added file 'Percona-Server/mysql-test/suite/rpl/r/rpl_mdev382.result'
780--- Percona-Server/mysql-test/suite/rpl/r/rpl_mdev382.result 1970-01-01 00:00:00 +0000
781+++ Percona-Server/mysql-test/suite/rpl/r/rpl_mdev382.result 2012-10-10 20:41:51 +0000
782@@ -0,0 +1,326 @@
783+include/master-slave.inc
784+[connection master]
785+create table t1 (a int primary key) engine=innodb;
786+create table t2 (a int primary key) engine=myisam;
787+begin;
788+insert into t1 values (1);
789+SET sql_mode = 'ANSI_QUOTES';
790+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
791+insert into t1 values (2);
792+insert into t2 values (1);
793+SET sql_mode = '';
794+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
795+Warnings:
796+Warning 1196 Some non-transactional changed tables couldn't be rolled back
797+insert into t1 values (3);
798+commit;
799+show binlog events from <binlog_start>;
800+Log_name Pos Event_type Server_id End_log_pos Info
801+master-bin.000001 # Query # # use `test`; create table t1 (a int primary key) engine=innodb
802+master-bin.000001 # Query # # use `test`; create table t2 (a int primary key) engine=myisam
803+master-bin.000001 # Query # # BEGIN
804+master-bin.000001 # Query # # use `test`; insert into t2 values (1)
805+master-bin.000001 # Query # # COMMIT
806+master-bin.000001 # Query # # BEGIN
807+master-bin.000001 # Query # # use `test`; insert into t1 values (1)
808+master-bin.000001 # Query # # SAVEPOINT "a`; create database couldbebadthingshere; savepoint `dummy"
809+master-bin.000001 # Query # # use `test`; insert into t1 values (2)
810+master-bin.000001 # Query # # ROLLBACK TO `a``; create database couldbebadthingshere; savepoint ``dummy`
811+master-bin.000001 # Query # # use `test`; insert into t1 values (3)
812+master-bin.000001 # Xid # # COMMIT /* XID */
813+BEGIN;
814+insert into t1 values(10);
815+set sql_mode = 'ANSI_QUOTES';
816+set sql_quote_show_create = 1;
817+savepoint a;
818+insert into t1 values(11);
819+savepoint "a""a";
820+insert into t1 values(12);
821+set sql_quote_show_create = 0;
822+savepoint b;
823+insert into t1 values(13);
824+savepoint "b""b";
825+insert into t1 values(14);
826+set sql_mode = '';
827+set sql_quote_show_create = 1;
828+savepoint c;
829+insert into t1 values(15);
830+savepoint `c``c`;
831+insert into t1 values(16);
832+set sql_quote_show_create = 0;
833+savepoint d;
834+insert into t1 values(17);
835+savepoint `d``d`;
836+insert into t1 values(18);
837+COMMIT;
838+set sql_quote_show_create = 1;
839+show binlog events from <binlog_start>;
840+Log_name Pos Event_type Server_id End_log_pos Info
841+master-bin.000001 # Query # # BEGIN
842+master-bin.000001 # Query # # use `test`; insert into t1 values(10)
843+master-bin.000001 # Query # # SAVEPOINT "a"
844+master-bin.000001 # Query # # use `test`; insert into t1 values(11)
845+master-bin.000001 # Query # # SAVEPOINT "a""a"
846+master-bin.000001 # Query # # use `test`; insert into t1 values(12)
847+master-bin.000001 # Query # # SAVEPOINT b
848+master-bin.000001 # Query # # use `test`; insert into t1 values(13)
849+master-bin.000001 # Query # # SAVEPOINT "b""b"
850+master-bin.000001 # Query # # use `test`; insert into t1 values(14)
851+master-bin.000001 # Query # # SAVEPOINT `c`
852+master-bin.000001 # Query # # use `test`; insert into t1 values(15)
853+master-bin.000001 # Query # # SAVEPOINT `c``c`
854+master-bin.000001 # Query # # use `test`; insert into t1 values(16)
855+master-bin.000001 # Query # # SAVEPOINT d
856+master-bin.000001 # Query # # use `test`; insert into t1 values(17)
857+master-bin.000001 # Query # # SAVEPOINT `d``d`
858+master-bin.000001 # Query # # use `test`; insert into t1 values(18)
859+master-bin.000001 # Xid # # COMMIT /* XID */
860+*** Test correct USE statement in SHOW BINLOG EVENTS ***
861+set sql_mode = 'ANSI_QUOTES';
862+CREATE DATABASE "db1`; SELECT 'oops!'";
863+use "db1`; SELECT 'oops!'";
864+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
865+INSERT INTO t1 VALUES (1);
866+set sql_mode = '';
867+INSERT INTO t1 VALUES (2);
868+set sql_mode = 'ANSI_QUOTES';
869+show binlog events from <binlog_start>;
870+Log_name Pos Event_type Server_id End_log_pos Info
871+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
872+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
873+master-bin.000001 # Query # # BEGIN
874+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (1)
875+master-bin.000001 # Query # # COMMIT
876+master-bin.000001 # Query # # BEGIN
877+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (2)
878+master-bin.000001 # Query # # COMMIT
879+set sql_mode = '';
880+set sql_quote_show_create = 0;
881+show binlog events from <binlog_start>;
882+Log_name Pos Event_type Server_id End_log_pos Info
883+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
884+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
885+master-bin.000001 # Query # # BEGIN
886+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
887+master-bin.000001 # Query # # COMMIT
888+master-bin.000001 # Query # # BEGIN
889+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
890+master-bin.000001 # Query # # COMMIT
891+set sql_quote_show_create = 1;
892+show binlog events from <binlog_start>;
893+Log_name Pos Event_type Server_id End_log_pos Info
894+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
895+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
896+master-bin.000001 # Query # # BEGIN
897+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
898+master-bin.000001 # Query # # COMMIT
899+master-bin.000001 # Query # # BEGIN
900+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
901+master-bin.000001 # Query # # COMMIT
902+DROP TABLE t1;
903+use test;
904+***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
905+use `db1``; SELECT 'oops!'`;
906+set timestamp=1000000000;
907+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
908+`c``3` VARCHAR(7));
909+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
910+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
911+ LINES TERMINATED BY '\n'
912+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
913+SELECT * FROM `t``1`;
914+a`1 b`2 c`3
915+fo\o bar |b"a'z!
916+truncate `t``1`;
917+use test;
918+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt'
919+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
920+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
921+ LINES TERMINATED BY '\n'
922+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
923+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
924+a`1 b`2 c`3
925+fo\o bar |b"a'z!
926+show binlog events from <binlog_start>;
927+Log_name Pos Event_type Server_id End_log_pos Info
928+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
929+`c``3` VARCHAR(7))
930+master-bin.000001 # Query # # BEGIN
931+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
932+master-bin.000001 # Execute_load_query # # use `db1``; SELECT 'oops!'`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!") ;file_id=#
933+master-bin.000001 # Xid # # COMMIT /* XID */
934+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; truncate `t``1`
935+master-bin.000001 # Query # # BEGIN
936+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
937+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!") ;file_id=#
938+master-bin.000001 # Xid # # COMMIT /* XID */
939+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
940+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
941+DELIMITER /*!*/;
942+ROLLBACK/*!*/;
943+use `db1``; SELECT 'oops!'`/*!*/;
944+SET TIMESTAMP=1000000000/*!*/;
945+SET @@session.pseudo_thread_id=999999999/*!*/;
946+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
947+SET @@session.sql_mode=0/*!*/;
948+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
949+/*!\C latin1 *//*!*/;
950+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
951+SET @@session.lc_time_names=0/*!*/;
952+SET @@session.collation_database=DEFAULT/*!*/;
953+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
954+`c``3` VARCHAR(7))
955+/*!*/;
956+SET TIMESTAMP=1000000000/*!*/;
957+BEGIN
958+/*!*/;
959+SET TIMESTAMP=1000000000/*!*/;
960+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!")
961+/*!*/;
962+COMMIT/*!*/;
963+SET TIMESTAMP=1000000000/*!*/;
964+truncate `t``1`
965+/*!*/;
966+SET TIMESTAMP=1000000000/*!*/;
967+BEGIN
968+/*!*/;
969+use `test`/*!*/;
970+SET TIMESTAMP=1000000000/*!*/;
971+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!")
972+/*!*/;
973+COMMIT/*!*/;
974+DELIMITER ;
975+# End of log file
976+ROLLBACK /* added by mysqlbinlog */;
977+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
978+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
979+a`1 b`2 c`3
980+fo\o bar |b"a'z!
981+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
982+drop table t1,t2;
983+*** Test truncation of long SET expression in LOAD DATA ***
984+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
985+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE t1
986+FIELDS TERMINATED BY ','
987+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
988+SELECT * FROM t1 ORDER BY a;
989+a b
990+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
991+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
992+show binlog events from <binlog_start>;
993+Log_name Pos Event_type Server_id End_log_pos Info
994+master-bin.000001 # Query # # BEGIN
995+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
996+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE `t1` FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b) ;file_id=#
997+master-bin.000001 # Xid # # COMMIT /* XID */
998+SELECT * FROM t1 ORDER BY a;
999+a b
1000+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
1001+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
1002+DROP TABLE t1;
1003+*** Test user variables whose names require correct quoting ***
1004+use `db1``; SELECT 'oops!'`;
1005+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
1006+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
1007+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
1008+@`a``1`:=a1 @`a``2`:=a2 @`a``3`:=a3 @`a``4`:=a4 @`b```:=b @```c`:=c @```d```:=d
1009+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.234560123456789e125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1010+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
1011+show binlog events from <binlog_start>;
1012+Log_name Pos Event_type Server_id End_log_pos Info
1013+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
1014+master-bin.000001 # Query # # BEGIN
1015+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
1016+master-bin.000001 # Xid # # COMMIT /* XID */
1017+master-bin.000001 # Query # # BEGIN
1018+master-bin.000001 # User var # # @`a``1`=-9223372036854775808
1019+master-bin.000001 # User var # # @`a``2`=42
1020+master-bin.000001 # User var # # @`a``3`=9223372036854775807
1021+master-bin.000001 # User var # # @`a``4`=18446744073709551615
1022+master-bin.000001 # User var # # @`b```=-1.234560123456789e125
1023+master-bin.000001 # User var # # @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789
1024+master-bin.000001 # User var # # @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE latin1_swedish_ci
1025+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
1026+master-bin.000001 # Xid # # COMMIT /* XID */
1027+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
1028+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
1029+DELIMITER /*!*/;
1030+ROLLBACK/*!*/;
1031+use `db1``; SELECT 'oops!'`/*!*/;
1032+SET TIMESTAMP=1000000000/*!*/;
1033+SET @@session.pseudo_thread_id=999999999/*!*/;
1034+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
1035+SET @@session.sql_mode=0/*!*/;
1036+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
1037+/*!\C latin1 *//*!*/;
1038+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
1039+SET @@session.lc_time_names=0/*!*/;
1040+SET @@session.collation_database=DEFAULT/*!*/;
1041+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
1042+/*!*/;
1043+SET TIMESTAMP=1000000000/*!*/;
1044+BEGIN
1045+/*!*/;
1046+SET TIMESTAMP=1000000000/*!*/;
1047+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
1048+/*!*/;
1049+COMMIT/*!*/;
1050+SET TIMESTAMP=1000000000/*!*/;
1051+BEGIN
1052+/*!*/;
1053+SET @`a``1`:=-9223372036854775808/*!*/;
1054+SET @`a``2`:=42/*!*/;
1055+SET @`a``3`:=9223372036854775807/*!*/;
1056+SET @`a``4`:=18446744073709551615/*!*/;
1057+SET @`b```:=-1.2345601234568e+125/*!*/;
1058+SET @```c`:=-1234501234567890123456789012345678901234567890123456789.0123456789/*!*/;
1059+SET @```d```:=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE `latin1_swedish_ci`/*!*/;
1060+SET TIMESTAMP=1000000000/*!*/;
1061+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
1062+/*!*/;
1063+COMMIT/*!*/;
1064+DELIMITER ;
1065+# End of log file
1066+ROLLBACK /* added by mysqlbinlog */;
1067+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
1068+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
1069+a1 a2 a3 a4 b c d
1070+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.234560123456789e125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1071+-9223372036854775807 4200 9223372036854775806 18446744073709551614 -6.172800617283945e124 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1072+DROP TABLE t1;
1073+*** Test correct quoting in foreign key error message ***
1074+use `db1``; SELECT 'oops!'`;
1075+CREATE TABLE `t``1` ( `a``` INT PRIMARY KEY) ENGINE=innodb;
1076+CREATE TABLE `t``2` ( `b``` INT PRIMARY KEY, `c``` INT NOT NULL,
1077+FOREIGN KEY fk (`c```) REFERENCES `t``1`(`a```)) ENGINE=innodb;
1078+TRUNCATE `t``1`;
1079+ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`db1``; SELECT 'oops!'`.`t``2`, CONSTRAINT `INNODB_FOREIGN_KEY_NAME` FOREIGN KEY (`c```) REFERENCES `db1``; SELECT 'oops!'`.`t``1` (`a```))
1080+DROP TABLE `t``2`;
1081+DROP TABLE `t``1`;
1082+*** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
1083+include/stop_slave.inc
1084+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
1085+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
1086+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
1087+a`
1088+1
1089+2
1090+5
1091+set timestamp=1000000000;
1092+# The table should be empty on the master.
1093+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
1094+a`
1095+# The DELETE statement should be correctly quoted
1096+show binlog events in 'master-bin.000002' from <binlog_start>;
1097+Log_name Pos Event_type Server_id End_log_pos Info
1098+master-bin.000002 # Query # # BEGIN
1099+master-bin.000002 # Query # # use `test`; DELETE FROM `db1``; SELECT 'oops!'`.`t``1`
1100+master-bin.000002 # Query # # COMMIT
1101+include/start_slave.inc
1102+# The table should be empty on the slave also.
1103+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
1104+a`
1105+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
1106+use test;
1107+DROP DATABASE `db1``; SELECT 'oops!'`;
1108+include/rpl_end.inc
1109
1110=== modified file 'Percona-Server/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result'
1111--- Percona-Server/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2010-12-19 17:15:12 +0000
1112+++ Percona-Server/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2012-10-10 20:41:51 +0000
1113@@ -154,7 +154,7 @@
1114 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
1115 DELIMITER /*!*/;
1116 ROLLBACK/*!*/;
1117-use test/*!*/;
1118+use `test`/*!*/;
1119 SET TIMESTAMP=1000000000/*!*/;
1120 SET @@session.pseudo_thread_id=999999999/*!*/;
1121 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
1122@@ -176,7 +176,7 @@
1123 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
1124 DELIMITER /*!*/;
1125 ROLLBACK/*!*/;
1126-use test/*!*/;
1127+use `test`/*!*/;
1128 SET TIMESTAMP=1000000000/*!*/;
1129 SET @@session.pseudo_thread_id=999999999/*!*/;
1130 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
1131@@ -287,7 +287,7 @@
1132 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
1133 DELIMITER /*!*/;
1134 ROLLBACK/*!*/;
1135-use test/*!*/;
1136+use `test`/*!*/;
1137 SET TIMESTAMP=1000000000/*!*/;
1138 SET @@session.pseudo_thread_id=999999999/*!*/;
1139 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
1140@@ -318,7 +318,7 @@
1141 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
1142 DELIMITER /*!*/;
1143 ROLLBACK/*!*/;
1144-use test/*!*/;
1145+use `test`/*!*/;
1146 SET TIMESTAMP=1000000000/*!*/;
1147 SET @@session.pseudo_thread_id=999999999/*!*/;
1148 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
1149
1150=== modified file 'Percona-Server/mysql-test/suite/rpl/r/rpl_sp.result'
1151--- Percona-Server/mysql-test/suite/rpl/r/rpl_sp.result 2010-12-19 17:15:12 +0000
1152+++ Percona-Server/mysql-test/suite/rpl/r/rpl_sp.result 2012-10-10 20:41:51 +0000
1153@@ -670,7 +670,7 @@
1154 SET TIMESTAMP=t/*!*/;
1155 create database mysqltest1
1156 /*!*/;
1157-use mysqltest1/*!*/;
1158+use `mysqltest1`/*!*/;
1159 SET TIMESTAMP=t/*!*/;
1160 create table t1 (a varchar(100))
1161 /*!*/;
1162@@ -1015,7 +1015,7 @@
1163 SET TIMESTAMP=t/*!*/;
1164 drop user "zedjzlcsjhd"@127.0.0.1
1165 /*!*/;
1166-use test/*!*/;
1167+use `test`/*!*/;
1168 SET TIMESTAMP=t/*!*/;
1169 drop function if exists f1
1170 /*!*/;
1171@@ -1112,7 +1112,7 @@
1172 SET TIMESTAMP=t/*!*/;
1173 create database mysqltest2
1174 /*!*/;
1175-use mysqltest2/*!*/;
1176+use `mysqltest2`/*!*/;
1177 SET TIMESTAMP=t/*!*/;
1178 create table t ( t integer )
1179 /*!*/;
1180@@ -1139,7 +1139,7 @@
1181 SET TIMESTAMP=t/*!*/;
1182 BEGIN
1183 /*!*/;
1184-use mysqltest/*!*/;
1185+use `mysqltest`/*!*/;
1186 SET TIMESTAMP=t/*!*/;
1187 SELECT `mysqltest2`.`f1`()
1188 /*!*/;
1189@@ -1152,14 +1152,14 @@
1190 SET TIMESTAMP=t/*!*/;
1191 drop database mysqltest2
1192 /*!*/;
1193-use test/*!*/;
1194+use `test`/*!*/;
1195 SET TIMESTAMP=t/*!*/;
1196 CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltestbug36570_p1`()
1197 begin
1198 select 1;
1199 end
1200 /*!*/;
1201-use mysql/*!*/;
1202+use `mysql`/*!*/;
1203 SET TIMESTAMP=t/*!*/;
1204 CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.` mysqltestbug36570_p2`( a int)
1205 `label`:
1206
1207=== added file 'Percona-Server/mysql-test/suite/rpl/t/rpl_mdev382.test'
1208--- Percona-Server/mysql-test/suite/rpl/t/rpl_mdev382.test 1970-01-01 00:00:00 +0000
1209+++ Percona-Server/mysql-test/suite/rpl/t/rpl_mdev382.test 2012-10-10 20:41:51 +0000
1210@@ -0,0 +1,256 @@
1211+--source include/have_innodb.inc
1212+--source include/have_binlog_format_statement.inc
1213+--source include/master-slave.inc
1214+
1215+# MDEV-382: multiple SQL injections in replication code.
1216+
1217+# Test previous SQL injection attack against binlog for SAVEPOINT statement.
1218+# The test would cause syntax error on slave due to improper quoting of
1219+# the savepoint name.
1220+connection master;
1221+create table t1 (a int primary key) engine=innodb;
1222+create table t2 (a int primary key) engine=myisam;
1223+
1224+begin;
1225+insert into t1 values (1);
1226+SET sql_mode = 'ANSI_QUOTES';
1227+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
1228+insert into t1 values (2);
1229+insert into t2 values (1);
1230+SET sql_mode = '';
1231+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
1232+insert into t1 values (3);
1233+commit;
1234+
1235+--source include/show_binlog_events.inc
1236+
1237+# This failed due to syntax error in query when the bug was not fixed.
1238+sync_slave_with_master;
1239+connection slave;
1240+
1241+# Test some more combinations of ANSI_QUOTES and sql_quote_show_create
1242+connection master;
1243+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
1244+BEGIN;
1245+insert into t1 values(10);
1246+set sql_mode = 'ANSI_QUOTES';
1247+set sql_quote_show_create = 1;
1248+savepoint a;
1249+insert into t1 values(11);
1250+savepoint "a""a";
1251+insert into t1 values(12);
1252+set sql_quote_show_create = 0;
1253+savepoint b;
1254+insert into t1 values(13);
1255+savepoint "b""b";
1256+insert into t1 values(14);
1257+set sql_mode = '';
1258+set sql_quote_show_create = 1;
1259+savepoint c;
1260+insert into t1 values(15);
1261+savepoint `c``c`;
1262+insert into t1 values(16);
1263+set sql_quote_show_create = 0;
1264+savepoint d;
1265+insert into t1 values(17);
1266+savepoint `d``d`;
1267+insert into t1 values(18);
1268+COMMIT;
1269+set sql_quote_show_create = 1;
1270+
1271+--source include/show_binlog_events.inc
1272+
1273+--echo *** Test correct USE statement in SHOW BINLOG EVENTS ***
1274+connection master;
1275+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
1276+set sql_mode = 'ANSI_QUOTES';
1277+CREATE DATABASE "db1`; SELECT 'oops!'";
1278+use "db1`; SELECT 'oops!'";
1279+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
1280+INSERT INTO t1 VALUES (1);
1281+set sql_mode = '';
1282+INSERT INTO t1 VALUES (2);
1283+set sql_mode = 'ANSI_QUOTES';
1284+--source include/show_binlog_events.inc
1285+set sql_mode = '';
1286+set sql_quote_show_create = 0;
1287+--source include/show_binlog_events.inc
1288+set sql_quote_show_create = 1;
1289+--source include/show_binlog_events.inc
1290+DROP TABLE t1;
1291+
1292+use test;
1293+
1294+--echo ***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
1295+
1296+--let $load_file= $MYSQLTEST_VARDIR/tmp/f'le.txt
1297+--write_file $load_file
1298+'fo\\o','bar'
1299+EOF
1300+
1301+use `db1``; SELECT 'oops!'`;
1302+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
1303+set timestamp=1000000000;
1304+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
1305+ `c``3` VARCHAR(7));
1306+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1307+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
1308+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
1309+ LINES TERMINATED BY '\\n'
1310+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
1311+
1312+SELECT * FROM `t``1`;
1313+# Also test when code prefixes table name with database.
1314+truncate `t``1`;
1315+use test;
1316+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1317+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt'
1318+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
1319+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
1320+ LINES TERMINATED BY '\\n'
1321+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
1322+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
1323+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
1324+
1325+--source include/show_binlog_events.inc
1326+let $MYSQLD_DATADIR= `select @@datadir`;
1327+--replace_regex /LOCAL INFILE '.*SQL_LOAD.*' INTO/LOCAL INFILE '<name>' INTO/
1328+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
1329+
1330+sync_slave_with_master;
1331+connection slave;
1332+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
1333+connection master;
1334+
1335+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
1336+--remove_file $load_file
1337+
1338+connection master;
1339+drop table t1,t2;
1340+
1341+
1342+--echo *** Test truncation of long SET expression in LOAD DATA ***
1343+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
1344+--let $load_file= $MYSQLTEST_VARDIR/tmp/file.txt
1345+--write_file $load_file
1346+1,X
1347+2,A
1348+EOF
1349+
1350+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
1351+# The bug was that the SET expression was truncated to 256 bytes, so test with
1352+# an expression longer than that.
1353+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1354+eval LOAD DATA INFILE '$load_file' INTO TABLE t1
1355+ FIELDS TERMINATED BY ','
1356+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
1357+
1358+SELECT * FROM t1 ORDER BY a;
1359+--source include/show_binlog_events.inc
1360+
1361+sync_slave_with_master;
1362+connection slave;
1363+SELECT * FROM t1 ORDER BY a;
1364+
1365+connection master;
1366+--remove_file $load_file
1367+DROP TABLE t1;
1368+
1369+
1370+--echo *** Test user variables whose names require correct quoting ***
1371+use `db1``; SELECT 'oops!'`;
1372+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
1373+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
1374+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
1375+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
1376+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
1377+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
1378+
1379+--source include/show_binlog_events.inc
1380+
1381+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
1382+
1383+sync_slave_with_master;
1384+connection slave;
1385+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
1386+
1387+connection master;
1388+DROP TABLE t1;
1389+
1390+--echo *** Test correct quoting in foreign key error message ***
1391+use `db1``; SELECT 'oops!'`;
1392+CREATE TABLE `t``1` ( `a``` INT PRIMARY KEY) ENGINE=innodb;
1393+CREATE TABLE `t``2` ( `b``` INT PRIMARY KEY, `c``` INT NOT NULL,
1394+ FOREIGN KEY fk (`c```) REFERENCES `t``1`(`a```)) ENGINE=innodb;
1395+--replace_regex /t@[0-9]+_ibfk_[0-9]+/INNODB_FOREIGN_KEY_NAME/
1396+--error ER_TRUNCATE_ILLEGAL_FK
1397+TRUNCATE `t``1`;
1398+DROP TABLE `t``2`;
1399+DROP TABLE `t``1`;
1400+
1401+
1402+--echo *** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
1403+
1404+# Let's keep the slave stopped during master restart, to avoid any potential
1405+# races between slave reconnect and master restart.
1406+connection slave;
1407+--source include/stop_slave.inc
1408+
1409+connection master;
1410+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
1411+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
1412+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
1413+
1414+# Restart the master mysqld.
1415+# This will cause an implicit truncation of the memory-based table, which will
1416+# cause logging of an explicit DELETE FROM to binlog.
1417+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
1418+wait-rpl_mdev382.test
1419+EOF
1420+
1421+--shutdown_server 30
1422+
1423+--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
1424+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
1425+restart-rpl_mdev382.test
1426+EOF
1427+
1428+connection default;
1429+--enable_reconnect
1430+--source include/wait_until_connected_again.inc
1431+# rpl_end.inc needs to use the connection server_1
1432+connection server_1;
1433+--enable_reconnect
1434+--source include/wait_until_connected_again.inc
1435+connection master;
1436+--enable_reconnect
1437+--source include/wait_until_connected_again.inc
1438+set timestamp=1000000000;
1439+
1440+--echo # The table should be empty on the master.
1441+let $binlog_file= master-bin.000002;
1442+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
1443+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
1444+
1445+--echo # The DELETE statement should be correctly quoted
1446+--source include/show_binlog_events.inc
1447+
1448+connection slave;
1449+--source include/start_slave.inc
1450+
1451+connection master;
1452+sync_slave_with_master;
1453+connection slave;
1454+--echo # The table should be empty on the slave also.
1455+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
1456+
1457+connection master;
1458+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
1459+sync_slave_with_master;
1460+
1461+
1462+connection master;
1463+use test;
1464+DROP DATABASE `db1``; SELECT 'oops!'`;
1465+
1466+--source include/rpl_end.inc
1467
1468=== modified file 'Percona-Server/sql/ha_ndbcluster_binlog.cc'
1469--- Percona-Server/sql/ha_ndbcluster_binlog.cc 2011-07-03 23:48:19 +0000
1470+++ Percona-Server/sql/ha_ndbcluster_binlog.cc 2012-10-10 20:41:51 +0000
1471@@ -1296,7 +1296,9 @@
1472 DBUG_RETURN(0);
1473 }
1474
1475- char tmp_buf2[FN_REFLEN];
1476+ char tmp_buf2_mem[FN_REFLEN];
1477+ String tmp_buf2(tmp_buf2_mem, sizeof(tmp_buf2_mem), system_charset_info);
1478+ tmp_buf2.length(0);
1479 const char *type_str;
1480 switch (type)
1481 {
1482@@ -1305,17 +1307,24 @@
1483 if (thd->lex->sql_command == SQLCOM_DROP_DB)
1484 DBUG_RETURN(0);
1485 /* redo the drop table query as is may contain several tables */
1486- query= tmp_buf2;
1487- query_length= (uint) (strxmov(tmp_buf2, "drop table `",
1488- table_name, "`", NullS) - tmp_buf2);
1489+ tmp_buf2.append(STRING_WITH_LEN("drop table "));
1490+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
1491+ query= tmp_buf2.c_ptr_safe();
1492+ query_length= tmp_buf2.length();
1493 type_str= "drop table";
1494 break;
1495 case SOT_RENAME_TABLE:
1496 /* redo the rename table query as is may contain several tables */
1497- query= tmp_buf2;
1498- query_length= (uint) (strxmov(tmp_buf2, "rename table `",
1499- db, ".", table_name, "` to `",
1500- new_db, ".", new_table_name, "`", NullS) - tmp_buf2);
1501+ tmp_buf2.append(STRING_WITH_LEN("rename table "));
1502+ append_identifier(thd, &tmp_buf2, db, strlen(db));
1503+ tmp_buf2.append(STRING_WITH_LEN("."));
1504+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
1505+ tmp_buf2.append(STRING_WITH_LEN(" to "));
1506+ append_identifier(thd, &tmp_buf2, new_db, strlen(new_db));
1507+ tmp_buf2.append(STRING_WITH_LEN("."));
1508+ append_identifier(thd, &tmp_buf2, new_table_name, strlen(new_table_name));
1509+ query= tmp_buf2.c_ptr_safe();
1510+ query_length= tmp_buf2.length();
1511 type_str= "rename table";
1512 break;
1513 case SOT_CREATE_TABLE:
1514
1515=== modified file 'Percona-Server/sql/item.cc'
1516--- Percona-Server/sql/item.cc 2012-09-17 13:08:32 +0000
1517+++ Percona-Server/sql/item.cc 2012-10-10 20:41:51 +0000
1518@@ -792,15 +792,31 @@
1519 if (!my_charset_same(cs, system_charset_info))
1520 {
1521 size_t res_length;
1522- name= sql_strmake_with_convert(str, name_length= length, cs,
1523+ name= sql_strmake_with_convert(str, length, cs,
1524 MAX_ALIAS_NAME, system_charset_info,
1525 &res_length);
1526+ name_length= res_length;
1527 }
1528 else
1529 name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
1530 }
1531
1532
1533+void Item::set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs)
1534+{
1535+ if (!my_charset_same(cs, system_charset_info))
1536+ {
1537+ size_t res_length;
1538+ name= sql_strmake_with_convert(str, length, cs,
1539+ UINT_MAX, system_charset_info,
1540+ &res_length);
1541+ name_length= res_length;
1542+ }
1543+ else
1544+ name= sql_strmake(str, (name_length= length));
1545+}
1546+
1547+
1548 /**
1549 @details
1550 This function is called when:
1551
1552=== modified file 'Percona-Server/sql/item.h'
1553--- Percona-Server/sql/item.h 2012-02-29 08:45:15 +0000
1554+++ Percona-Server/sql/item.h 2012-10-10 20:41:51 +0000
1555@@ -588,6 +588,7 @@
1556 #endif
1557 } /*lint -e1509 */
1558 void set_name(const char *str, uint length, CHARSET_INFO *cs);
1559+ void set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs);
1560 void rename(char *new_name);
1561 void init_make_field(Send_field *tmp_field,enum enum_field_types type);
1562 virtual void cleanup();
1563
1564=== modified file 'Percona-Server/sql/item_func.cc'
1565--- Percona-Server/sql/item_func.cc 2011-11-15 09:01:29 +0000
1566+++ Percona-Server/sql/item_func.cc 2012-10-10 20:41:51 +0000
1567@@ -5161,7 +5161,7 @@
1568 void Item_func_get_user_var::print(String *str, enum_query_type query_type)
1569 {
1570 str->append(STRING_WITH_LEN("(@"));
1571- str->append(name.str,name.length);
1572+ append_identifier(current_thd, str, name.str, name.length);
1573 str->append(')');
1574 }
1575
1576@@ -5257,10 +5257,10 @@
1577 }
1578
1579
1580-void Item_user_var_as_out_param::print(String *str, enum_query_type query_type)
1581+void Item_user_var_as_out_param::print_for_load(THD *thd, String *str)
1582 {
1583 str->append('@');
1584- str->append(name.str,name.length);
1585+ append_identifier(thd, str, name.str, name.length);
1586 }
1587
1588
1589
1590=== modified file 'Percona-Server/sql/item_func.h'
1591--- Percona-Server/sql/item_func.h 2011-07-03 23:48:19 +0000
1592+++ Percona-Server/sql/item_func.h 2012-10-10 20:41:51 +0000
1593@@ -1574,7 +1574,7 @@
1594 my_decimal *val_decimal(my_decimal *decimal_buffer);
1595 /* fix_fields() binds variable name with its entry structure */
1596 bool fix_fields(THD *thd, Item **ref);
1597- virtual void print(String *str, enum_query_type query_type);
1598+ void print_for_load(THD *thd, String *str);
1599 void set_null_value(CHARSET_INFO* cs);
1600 void set_value(const char *str, uint length, CHARSET_INFO* cs);
1601 };
1602
1603=== modified file 'Percona-Server/sql/log.cc'
1604--- Percona-Server/sql/log.cc 2012-09-28 01:36:45 +0000
1605+++ Percona-Server/sql/log.cc 2012-10-10 20:41:51 +0000
1606@@ -51,6 +51,8 @@
1607 #include "sql_plugin.h"
1608 #include "rpl_handler.h"
1609 #include "debug_sync.h"
1610+#include "sql_show.h"
1611+
1612 /* max size of the log message */
1613 #define MAX_LOG_BUFFER_SIZE 1024
1614 #define MAX_TIME_SIZE 32
1615@@ -2044,9 +2046,8 @@
1616
1617 String log_query;
1618 if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) ||
1619- log_query.append("`") ||
1620- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
1621- log_query.append("`"))
1622+ append_identifier(thd, &log_query,
1623+ thd->lex->ident.str, thd->lex->ident.length))
1624 DBUG_RETURN(1);
1625 int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
1626 Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
1627@@ -2068,9 +2069,8 @@
1628 {
1629 String log_query;
1630 if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
1631- log_query.append("`") ||
1632- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
1633- log_query.append("`"))
1634+ append_identifier(thd, &log_query,
1635+ thd->lex->ident.str, thd->lex->ident.length))
1636 DBUG_RETURN(1);
1637 int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
1638 Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
1639
1640=== modified file 'Percona-Server/sql/log_event.cc'
1641--- Percona-Server/sql/log_event.cc 2012-09-17 13:08:32 +0000
1642+++ Percona-Server/sql/log_event.cc 2012-10-10 20:41:51 +0000
1643@@ -45,12 +45,14 @@
1644 #include "rpl_record.h"
1645 #include "transaction.h"
1646 #include <my_dir.h>
1647+#include "sql_show.h"
1648
1649 #endif /* MYSQL_CLIENT */
1650
1651 #include <base64.h>
1652 #include <my_bitmap.h>
1653 #include "rpl_utility.h"
1654+#include "sql_string.h"
1655
1656 #define log_cs &my_charset_latin1
1657
1658@@ -426,29 +428,28 @@
1659 pretty_print_str()
1660 */
1661
1662-static char *pretty_print_str(char *packet, const char *str, int len)
1663+static void
1664+pretty_print_str(String *packet, const char *str, int len)
1665 {
1666 const char *end= str + len;
1667- char *pos= packet;
1668- *pos++= '\'';
1669+ packet->append(STRING_WITH_LEN("'"));
1670 while (str < end)
1671 {
1672 char c;
1673 switch ((c=*str++)) {
1674- case '\n': *pos++= '\\'; *pos++= 'n'; break;
1675- case '\r': *pos++= '\\'; *pos++= 'r'; break;
1676- case '\\': *pos++= '\\'; *pos++= '\\'; break;
1677- case '\b': *pos++= '\\'; *pos++= 'b'; break;
1678- case '\t': *pos++= '\\'; *pos++= 't'; break;
1679- case '\'': *pos++= '\\'; *pos++= '\''; break;
1680- case 0 : *pos++= '\\'; *pos++= '0'; break;
1681+ case '\n': packet->append(STRING_WITH_LEN("\\n")); break;
1682+ case '\r': packet->append(STRING_WITH_LEN("\\r")); break;
1683+ case '\\': packet->append(STRING_WITH_LEN("\\\\")); break;
1684+ case '\b': packet->append(STRING_WITH_LEN("\\b")); break;
1685+ case '\t': packet->append(STRING_WITH_LEN("\\t")); break;
1686+ case '\'': packet->append(STRING_WITH_LEN("\\'")); break;
1687+ case 0 : packet->append(STRING_WITH_LEN("\\0")); break;
1688 default:
1689- *pos++= c;
1690+ packet->append(&c, 1);
1691 break;
1692 }
1693 }
1694- *pos++= '\'';
1695- return pos;
1696+ packet->append(STRING_WITH_LEN("'"));
1697 }
1698 #endif /* !MYSQL_CLIENT */
1699
1700@@ -879,7 +880,7 @@
1701 Log_event::pack_info()
1702 */
1703
1704-void Log_event::pack_info(Protocol *protocol)
1705+void Log_event::pack_info(THD *thd, Protocol *protocol)
1706 {
1707 protocol->store("", &my_charset_bin);
1708 }
1709@@ -888,7 +889,8 @@
1710 /**
1711 Only called by SHOW BINLOG EVENTS
1712 */
1713-int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
1714+int Log_event::net_send(THD *thd, Protocol *protocol, const char* log_name,
1715+ my_off_t pos)
1716 {
1717 const char *p= strrchr(log_name, FN_LIBCHAR);
1718 const char *event_type;
1719@@ -902,7 +904,7 @@
1720 protocol->store(event_type, strlen(event_type), &my_charset_bin);
1721 protocol->store((uint32) server_id);
1722 protocol->store((ulonglong) log_pos);
1723- pack_info(protocol);
1724+ pack_info(thd, protocol);
1725 return protocol->write();
1726 }
1727 #endif /* HAVE_REPLICATION */
1728@@ -2157,27 +2159,22 @@
1729 show the catalog ??
1730 */
1731
1732-void Query_log_event::pack_info(Protocol *protocol)
1733+void Query_log_event::pack_info(THD *thd, Protocol *protocol)
1734 {
1735 // TODO: show the catalog ??
1736- char *buf, *pos;
1737- if (!(buf= (char*) my_malloc(9 + db_len + q_len, MYF(MY_WME))))
1738- return;
1739- pos= buf;
1740+ char buf_mem[1024];
1741+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
1742+ buf.real_alloc(9 + db_len + q_len);
1743 if (!(flags & LOG_EVENT_SUPPRESS_USE_F)
1744 && db && db_len)
1745 {
1746- pos= strmov(buf, "use `");
1747- memcpy(pos, db, db_len);
1748- pos= strmov(pos+db_len, "`; ");
1749+ buf.append(STRING_WITH_LEN("use "));
1750+ append_identifier(thd, &buf, db, db_len);
1751+ buf.append("; ");
1752 }
1753 if (query && q_len)
1754- {
1755- memcpy(pos, query, q_len);
1756- pos+= q_len;
1757- }
1758- protocol->store(buf, pos-buf, &my_charset_bin);
1759- my_free(buf);
1760+ buf.append(query, q_len);
1761+ protocol->store(&buf);
1762 }
1763 #endif
1764
1765@@ -3047,7 +3044,19 @@
1766 if (different_db)
1767 memcpy(print_event_info->db, db, db_len + 1);
1768 if (db[0] && different_db)
1769- my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
1770+ {
1771+ QUOTED_IDENTIFIER(q_db,
1772+ /* Room for expand ` to `` + initial/final ` + \0 */
1773+ FN_REFLEN*2+3,
1774+ '`',
1775+ &my_charset_bin,
1776+ db,
1777+ db_len);
1778+ my_b_printf(file,
1779+ "use %s%s\n",
1780+ q_db.c_ptr(),
1781+ print_event_info->delimiter);
1782+ }
1783 }
1784
1785 end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
1786@@ -3710,7 +3719,7 @@
1787 */
1788
1789 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
1790-void Start_log_event_v3::pack_info(Protocol *protocol)
1791+void Start_log_event_v3::pack_info(THD *thd, Protocol *protocol)
1792 {
1793 char buf[12 + ST_SERVER_VER_LEN + 14 + 22], *pos;
1794 pos= strmov(buf, "Server ver: ");
1795@@ -4359,131 +4368,115 @@
1796 */
1797
1798 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
1799-uint Load_log_event::get_query_buffer_length()
1800-{
1801- return
1802- 5 + db_len + 3 + // "use DB; "
1803- 18 + fname_len + 2 + // "LOAD DATA INFILE 'file''"
1804- 11 + // "CONCURRENT "
1805- 7 + // LOCAL
1806- 9 + // " REPLACE or IGNORE "
1807- 13 + table_name_len*2 + // "INTO TABLE `table`"
1808- 21 + sql_ex.field_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'"
1809- 23 + sql_ex.enclosed_len*4 + 2 + // " OPTIONALLY ENCLOSED BY 'str'"
1810- 12 + sql_ex.escaped_len*4 + 2 + // " ESCAPED BY 'str'"
1811- 21 + sql_ex.line_term_len*4 + 2 + // " LINES TERMINATED BY 'str'"
1812- 19 + sql_ex.line_start_len*4 + 2 + // " LINES STARTING BY 'str'"
1813- 15 + 22 + // " IGNORE xxx LINES"
1814- 3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)"
1815-}
1816-
1817-
1818-void Load_log_event::print_query(bool need_db, const char *cs, char *buf,
1819- char **end, char **fn_start, char **fn_end)
1820-{
1821- char *pos= buf;
1822-
1823+void Load_log_event::print_query(THD *thd, bool need_db, const char *cs,
1824+ String *buf, my_off_t *fn_start,
1825+ my_off_t *fn_end, const char *qualify_db)
1826+{
1827 if (need_db && db && db_len)
1828 {
1829- pos= strmov(pos, "use `");
1830- memcpy(pos, db, db_len);
1831- pos= strmov(pos+db_len, "`; ");
1832+ buf->append(STRING_WITH_LEN("use "));
1833+ append_identifier(thd, buf, db, db_len);
1834+ buf->append(STRING_WITH_LEN("; "));
1835 }
1836
1837- pos= strmov(pos, "LOAD DATA ");
1838+ buf->append(STRING_WITH_LEN("LOAD DATA "));
1839
1840 if (is_concurrent)
1841- pos= strmov(pos, "CONCURRENT ");
1842+ buf->append(STRING_WITH_LEN("CONCURRENT "));
1843
1844 if (fn_start)
1845- *fn_start= pos;
1846+ *fn_start= buf->length();
1847
1848 if (check_fname_outside_temp_buf())
1849- pos= strmov(pos, "LOCAL ");
1850- pos= strmov(pos, "INFILE '");
1851- memcpy(pos, fname, fname_len);
1852- pos= strmov(pos+fname_len, "' ");
1853+ buf->append(STRING_WITH_LEN("LOCAL "));
1854+ buf->append(STRING_WITH_LEN("INFILE '"));
1855+ buf->append_for_single_quote(fname, fname_len);
1856+ buf->append(STRING_WITH_LEN("' "));
1857
1858 if (sql_ex.opt_flags & REPLACE_FLAG)
1859- pos= strmov(pos, "REPLACE ");
1860+ buf->append(STRING_WITH_LEN("REPLACE "));
1861 else if (sql_ex.opt_flags & IGNORE_FLAG)
1862- pos= strmov(pos, "IGNORE ");
1863+ buf->append(STRING_WITH_LEN("IGNORE "));
1864
1865- pos= strmov(pos ,"INTO");
1866+ buf->append(STRING_WITH_LEN("INTO"));
1867
1868 if (fn_end)
1869- *fn_end= pos;
1870+ *fn_end= buf->length();
1871
1872- pos= strmov(pos ," TABLE `");
1873- memcpy(pos, table_name, table_name_len);
1874- pos+= table_name_len;
1875+ buf->append(STRING_WITH_LEN(" TABLE "));
1876+ if (qualify_db)
1877+ {
1878+ append_identifier(thd, buf, qualify_db, strlen(qualify_db));
1879+ buf->append(STRING_WITH_LEN("."));
1880+ }
1881+ append_identifier(thd, buf, table_name, table_name_len);
1882
1883 if (cs != NULL)
1884 {
1885- pos= strmov(pos ,"` CHARACTER SET ");
1886- pos= strmov(pos , cs);
1887+ buf->append(STRING_WITH_LEN(" CHARACTER SET "));
1888+ buf->append(cs, strlen(cs));
1889 }
1890- else
1891- pos= strmov(pos, "`");
1892
1893 /* We have to create all optional fields as the default is not empty */
1894- pos= strmov(pos, " FIELDS TERMINATED BY ");
1895- pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len);
1896+ buf->append(STRING_WITH_LEN(" FIELDS TERMINATED BY "));
1897+ pretty_print_str(buf, sql_ex.field_term, sql_ex.field_term_len);
1898 if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG)
1899- pos= strmov(pos, " OPTIONALLY ");
1900- pos= strmov(pos, " ENCLOSED BY ");
1901- pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len);
1902-
1903- pos= strmov(pos, " ESCAPED BY ");
1904- pos= pretty_print_str(pos, sql_ex.escaped, sql_ex.escaped_len);
1905-
1906- pos= strmov(pos, " LINES TERMINATED BY ");
1907- pos= pretty_print_str(pos, sql_ex.line_term, sql_ex.line_term_len);
1908+ buf->append(STRING_WITH_LEN(" OPTIONALLY "));
1909+ buf->append(STRING_WITH_LEN(" ENCLOSED BY "));
1910+ pretty_print_str(buf, sql_ex.enclosed, sql_ex.enclosed_len);
1911+
1912+ buf->append(STRING_WITH_LEN(" ESCAPED BY "));
1913+ pretty_print_str(buf, sql_ex.escaped, sql_ex.escaped_len);
1914+
1915+ buf->append(STRING_WITH_LEN(" LINES TERMINATED BY "));
1916+ pretty_print_str(buf, sql_ex.line_term, sql_ex.line_term_len);
1917 if (sql_ex.line_start_len)
1918 {
1919- pos= strmov(pos, " STARTING BY ");
1920- pos= pretty_print_str(pos, sql_ex.line_start, sql_ex.line_start_len);
1921+ buf->append(STRING_WITH_LEN(" STARTING BY "));
1922+ pretty_print_str(buf, sql_ex.line_start, sql_ex.line_start_len);
1923 }
1924
1925 if ((long) skip_lines > 0)
1926 {
1927- pos= strmov(pos, " IGNORE ");
1928- pos= longlong10_to_str((longlong) skip_lines, pos, 10);
1929- pos= strmov(pos," LINES ");
1930+ char skipbuf[22];
1931+ buf->append(STRING_WITH_LEN(" IGNORE "));
1932+ longlong10_to_str((longlong) skip_lines, skipbuf, 10);
1933+ buf->append(skipbuf);
1934+ buf->append(STRING_WITH_LEN(" LINES "));
1935 }
1936
1937 if (num_fields)
1938 {
1939 uint i;
1940 const char *field= fields;
1941- pos= strmov(pos, " (");
1942+ buf->append(STRING_WITH_LEN(" ("));
1943 for (i = 0; i < num_fields; i++)
1944 {
1945 if (i)
1946 {
1947- *pos++= ' ';
1948- *pos++= ',';
1949+ /*
1950+ Yes, the space and comma is reversed here. But this is mostly dead
1951+ code, at most used when reading really old binlogs from old servers,
1952+ so better just leave it as is...
1953+ */
1954+ buf->append(STRING_WITH_LEN(" ,"));
1955 }
1956- memcpy(pos, field, field_lens[i]);
1957- pos+= field_lens[i];
1958+ append_identifier(thd, buf, field, field_lens[i]);
1959 field+= field_lens[i] + 1;
1960 }
1961- *pos++= ')';
1962+ buf->append(STRING_WITH_LEN(")"));
1963 }
1964-
1965- *end= pos;
1966 }
1967
1968
1969-void Load_log_event::pack_info(Protocol *protocol)
1970+void Load_log_event::pack_info(THD *thd, Protocol *protocol)
1971 {
1972- char *buf, *end;
1973+ char query_buffer[1024];
1974+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
1975
1976- if (!(buf= (char*) my_malloc(get_query_buffer_length(), MYF(MY_WME))))
1977- return;
1978- print_query(TRUE, NULL, buf, &end, 0, 0);
1979- protocol->store(buf, end-buf, &my_charset_bin);
1980- my_free(buf);
1981+ query_str.length(0);
1982+ print_query(thd, TRUE, NULL, &query_str, 0, 0, NULL);
1983+ protocol->store(query_str.ptr(), query_str.length(), &my_charset_bin);
1984 }
1985 #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
1986
1987@@ -4758,7 +4751,13 @@
1988 else if (sql_ex.opt_flags & IGNORE_FLAG)
1989 my_b_printf(&cache,"IGNORE ");
1990
1991- my_b_printf(&cache, "INTO TABLE `%s`", table_name);
1992+ QUOTED_IDENTIFIER(quoted_table_name,
1993+ 512,
1994+ '`',
1995+ &my_charset_bin,
1996+ table_name,
1997+ strlen(table_name));
1998+ my_b_printf(&cache, "INTO TABLE %s", quoted_table_name.c_ptr());
1999 my_b_printf(&cache, " FIELDS TERMINATED BY ");
2000 pretty_print_str(&cache, sql_ex.field_term, sql_ex.field_term_len);
2001
2002@@ -4939,29 +4938,21 @@
2003 else
2004 {
2005 char llbuff[22];
2006- char *end;
2007 enum enum_duplicates handle_dup;
2008 bool ignore= 0;
2009 char *load_data_query;
2010- int query_buf_len;
2011+ char query_buffer[1024];
2012+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
2013+ query_str.length(0);
2014
2015- /*
2016- We must allocate some extra memory for query cache
2017- The query buffer layout is:
2018- buffer :==
2019- <statement> The input statement(s)
2020- '\0' Terminating null char (1 byte)
2021- <length> Length of following current database name (size_t)
2022- <db_name> Name of current database
2023- <flags> Flags struct
2024- */
2025- query_buf_len = get_query_buffer_length() + 1 + sizeof(size_t) + thd->db_length
2026- + QUERY_CACHE_FLAGS_SIZE + 1;
2027+ print_query(thd, FALSE, NULL, &query_str, NULL, NULL, NULL);
2028 /*
2029 Forge LOAD DATA INFILE query which will be used in SHOW PROCESS LIST
2030 and written to slave's binlog if binlogging is on.
2031 */
2032- if (!(load_data_query= (char *)thd->alloc(query_buf_len)))
2033+ if (!(load_data_query= (char *) thd->strmake(query_str.ptr(),
2034+ query_str.length() +
2035+ sizeof(size_t))))
2036 {
2037 /*
2038 This will set thd->fatal_error in case of OOM. So we surely will notice
2039@@ -4970,10 +4961,11 @@
2040 goto error;
2041 }
2042
2043- print_query(FALSE, NULL, load_data_query, &end, NULL, NULL);
2044- *end= 0;
2045- memcpy(end+1, (char *) &thd->db_length, sizeof(size_t));
2046- thd->set_query(load_data_query, (uint) (end - load_data_query));
2047+ memcpy(load_data_query + query_str.length() + 1,
2048+ (char *) &thd->db_length,
2049+ sizeof(size_t));
2050+
2051+ thd->set_query(load_data_query, query_str.length());
2052
2053 if (sql_ex.opt_flags & REPLACE_FLAG)
2054 handle_dup= DUP_REPLACE;
2055@@ -5151,7 +5143,7 @@
2056 */
2057
2058 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2059-void Rotate_log_event::pack_info(Protocol *protocol)
2060+void Rotate_log_event::pack_info(THD *thd, Protocol *protocol)
2061 {
2062 char buf1[256], buf[22];
2063 String tmp(buf1, sizeof(buf1), log_cs);
2064@@ -5366,7 +5358,7 @@
2065 */
2066
2067 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2068-void Intvar_log_event::pack_info(Protocol *protocol)
2069+void Intvar_log_event::pack_info(THD *thd, Protocol *protocol)
2070 {
2071 char buf[256], *pos;
2072 pos= strmake(buf, get_var_type_name(), sizeof(buf)-23);
2073@@ -5519,7 +5511,7 @@
2074 **************************************************************************/
2075
2076 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2077-void Rand_log_event::pack_info(Protocol *protocol)
2078+void Rand_log_event::pack_info(THD *thd, Protocol *protocol)
2079 {
2080 char buf1[256], *pos;
2081 pos= strmov(buf1,"rand_seed1=");
2082@@ -5643,7 +5635,7 @@
2083 **************************************************************************/
2084
2085 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2086-void Xid_log_event::pack_info(Protocol *protocol)
2087+void Xid_log_event::pack_info(THD *thd, Protocol *protocol)
2088 {
2089 char buf[128], *pos;
2090 pos= strmov(buf, "COMMIT /* xid=");
2091@@ -5739,84 +5731,122 @@
2092 **************************************************************************/
2093
2094 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2095-void User_var_log_event::pack_info(Protocol* protocol)
2096+static bool
2097+user_var_append_name_part(THD *thd, String *buf,
2098+ const char *name, size_t name_len)
2099 {
2100- char *buf= 0;
2101- uint val_offset= 4 + name_len;
2102- uint event_len= val_offset;
2103+ return buf->append("@") ||
2104+ append_identifier(thd, buf, name, name_len) ||
2105+ buf->append("=");
2106+}
2107
2108+void User_var_log_event::pack_info(THD *thd, Protocol* protocol)
2109+{
2110 if (is_null)
2111 {
2112- if (!(buf= (char*) my_malloc(val_offset + 5, MYF(MY_WME))))
2113+ char buf_mem[FN_REFLEN+7];
2114+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
2115+ buf.length(0);
2116+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
2117+ buf.append("NULL"))
2118 return;
2119- strmov(buf + val_offset, "NULL");
2120- event_len= val_offset + 4;
2121+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
2122 }
2123 else
2124 {
2125 switch (type) {
2126 case REAL_RESULT:
2127+ {
2128 double real_val;
2129+ char buf2[MY_GCVT_MAX_FIELD_WIDTH + 1];
2130+ char buf_mem[FN_REFLEN + MY_GCVT_MAX_FIELD_WIDTH + 1];
2131+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
2132 float8get(real_val, val);
2133- if (!(buf= (char*) my_malloc(val_offset + MY_GCVT_MAX_FIELD_WIDTH + 1,
2134- MYF(MY_WME))))
2135- return;
2136- event_len+= my_gcvt(real_val, MY_GCVT_ARG_DOUBLE, MY_GCVT_MAX_FIELD_WIDTH,
2137- buf + val_offset, NULL);
2138+ my_gcvt(real_val, MY_GCVT_ARG_DOUBLE, MY_GCVT_MAX_FIELD_WIDTH,
2139+ buf2, NULL);
2140+ buf.length(0);
2141+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
2142+ buf.append(buf2))
2143+ return;
2144+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
2145 break;
2146+ }
2147 case INT_RESULT:
2148- if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME))))
2149+ {
2150+ char buf2[22];
2151+ char buf_mem[FN_REFLEN + 22];
2152+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
2153+ buf.length(0);
2154+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
2155+ buf.append(buf2,
2156+ longlong10_to_str(uint8korr(val),
2157+ buf2,
2158+ (flags &
2159+ User_var_log_event::UNSIGNED_F) ?
2160+ 10 : -10)
2161+ -buf2))
2162 return;
2163- event_len= longlong10_to_str(uint8korr(val), buf + val_offset,
2164- ((flags & User_var_log_event::UNSIGNED_F) ?
2165- 10 : -10))-buf;
2166+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
2167 break;
2168+ }
2169 case DECIMAL_RESULT:
2170 {
2171- if (!(buf= (char*) my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH,
2172- MYF(MY_WME))))
2173- return;
2174- String str(buf+val_offset, DECIMAL_MAX_STR_LENGTH, &my_charset_bin);
2175+ char buf_mem[FN_REFLEN + DECIMAL_MAX_STR_LENGTH];
2176+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
2177+ char buf2[DECIMAL_MAX_STR_LENGTH+1];
2178+ String str(buf2, sizeof(buf2), &my_charset_bin);
2179 my_decimal dec;
2180+ buf.length(0);
2181 binary2my_decimal(E_DEC_FATAL_ERROR, (uchar*) (val+2), &dec, val[0],
2182 val[1]);
2183 my_decimal2string(E_DEC_FATAL_ERROR, &dec, 0, 0, 0, &str);
2184- event_len= str.length() + val_offset;
2185+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
2186+ buf.append(buf2))
2187+ return;
2188+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
2189 break;
2190- }
2191+ }
2192 case STRING_RESULT:
2193+ {
2194 /* 15 is for 'COLLATE' and other chars */
2195- buf= (char*) my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15,
2196- MYF(MY_WME));
2197+ char buf_mem[FN_REFLEN + 512 + 1 + 2*MY_CS_NAME_SIZE+15];
2198+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
2199 CHARSET_INFO *cs;
2200- if (!buf)
2201- return;
2202+ buf.length(0);
2203 if (!(cs= get_charset(charset_number, MYF(0))))
2204 {
2205- strmov(buf+val_offset, "???");
2206- event_len+= 3;
2207+ if (buf.append("???"))
2208+ return;
2209 }
2210 else
2211 {
2212- char *p= strxmov(buf + val_offset, "_", cs->csname, " ", NullS);
2213- p= str_to_hex(p, val, val_len);
2214- p= strxmov(p, " COLLATE ", cs->name, NullS);
2215- event_len= p-buf;
2216+ size_t old_len;
2217+ char *beg, *end;
2218+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
2219+ buf.append("_") ||
2220+ buf.append(cs->csname) ||
2221+ buf.append(" "))
2222+ return;
2223+ old_len= buf.length();
2224+ if (buf.reserve(old_len + val_len*2 + 2 + sizeof(" COLLATE ") +
2225+ MY_CS_NAME_SIZE))
2226+ return;
2227+ beg= const_cast<char *>(buf.ptr()) + old_len;
2228+ end= str_to_hex(beg, val, val_len);
2229+ buf.length(old_len + (end - beg));
2230+ if (buf.append(" COLLATE ") ||
2231+ buf.append(cs->name))
2232+ return;
2233 }
2234+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
2235 break;
2236+ }
2237 case ROW_RESULT:
2238 default:
2239 DBUG_ASSERT(1);
2240 return;
2241 }
2242 }
2243- buf[0]= '@';
2244- buf[1]= '`';
2245- memcpy(buf+2, name, name_len);
2246- buf[2+name_len]= '`';
2247- buf[3+name_len]= '=';
2248- protocol->store(buf, event_len, &my_charset_bin);
2249- my_free(buf);
2250 }
2251 #endif /* !MYSQL_CLIENT */
2252
2253@@ -5960,9 +5990,14 @@
2254 my_b_printf(&cache, "\tUser_var\n");
2255 }
2256
2257- my_b_printf(&cache, "SET @`");
2258- my_b_write(&cache, (uchar*) name, (uint) (name_len));
2259- my_b_printf(&cache, "`");
2260+ QUOTED_IDENTIFIER(quoted_name,
2261+ 512,
2262+ '`',
2263+ &my_charset_bin,
2264+ name,
2265+ name_len);
2266+ my_b_printf(&cache, "SET @");
2267+ my_b_printf(&cache, quoted_name.c_ptr());
2268
2269 if (is_null)
2270 {
2271@@ -6036,9 +6071,17 @@
2272 */
2273 my_b_printf(&cache, ":=???%s\n", print_event_info->delimiter);
2274 else
2275- my_b_printf(&cache, ":=_%s %s COLLATE `%s`%s\n",
2276- cs->csname, hex_str, cs->name,
2277+ {
2278+ QUOTED_IDENTIFIER(quoted_charset_name,
2279+ 512,
2280+ '`',
2281+ &my_charset_bin,
2282+ cs->name,
2283+ strlen(cs->name));
2284+ my_b_printf(&cache, ":=_%s %s COLLATE %s%s\n",
2285+ cs->csname, hex_str, quoted_charset_name.c_ptr(),
2286 print_event_info->delimiter);
2287+ }
2288 my_afree(hex_str);
2289 }
2290 break;
2291@@ -6184,7 +6227,7 @@
2292 #endif
2293
2294 #ifndef MYSQL_CLIENT
2295-void Slave_log_event::pack_info(Protocol *protocol)
2296+void Slave_log_event::pack_info(THD *thd, Protocol *protocol)
2297 {
2298 char buf[256+HOSTNAME_LENGTH], *pos;
2299 pos= strmov(buf, "host=");
2300@@ -6566,7 +6609,7 @@
2301 */
2302
2303 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2304-void Create_file_log_event::pack_info(Protocol *protocol)
2305+void Create_file_log_event::pack_info(THD *thd, Protocol *protocol)
2306 {
2307 char buf[NAME_LEN*2 + 30 + 21*2], *pos;
2308 pos= strmov(buf, "db=");
2309@@ -6751,7 +6794,7 @@
2310 */
2311
2312 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2313-void Append_block_log_event::pack_info(Protocol *protocol)
2314+void Append_block_log_event::pack_info(THD *thd, Protocol *protocol)
2315 {
2316 char buf[256];
2317 size_t length;
2318@@ -6908,7 +6951,7 @@
2319 */
2320
2321 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2322-void Delete_file_log_event::pack_info(Protocol *protocol)
2323+void Delete_file_log_event::pack_info(THD *thd, Protocol *protocol)
2324 {
2325 char buf[64];
2326 size_t length;
2327@@ -7006,7 +7049,7 @@
2328 */
2329
2330 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2331-void Execute_load_log_event::pack_info(Protocol *protocol)
2332+void Execute_load_log_event::pack_info(THD *thd, Protocol *protocol)
2333 {
2334 char buf[64];
2335 size_t length;
2336@@ -7267,27 +7310,26 @@
2337
2338
2339 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2340-void Execute_load_query_log_event::pack_info(Protocol *protocol)
2341+void Execute_load_query_log_event::pack_info(THD *thd, Protocol *protocol)
2342 {
2343- char *buf, *pos;
2344- if (!(buf= (char*) my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME))))
2345- return;
2346- pos= buf;
2347+ char buf_mem[1024];
2348+ char file_id_buf[22];
2349+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
2350+ buf.real_alloc(9 + db_len + q_len + 10 + 21);
2351 if (db && db_len)
2352 {
2353- pos= strmov(buf, "use `");
2354- memcpy(pos, db, db_len);
2355- pos= strmov(pos+db_len, "`; ");
2356- }
2357- if (query && q_len)
2358- {
2359- memcpy(pos, query, q_len);
2360- pos+= q_len;
2361- }
2362- pos= strmov(pos, " ;file_id=");
2363- pos= int10_to_str((long) file_id, pos, 10);
2364- protocol->store(buf, pos-buf, &my_charset_bin);
2365- my_free(buf);
2366+ if (buf.append("use ") ||
2367+ append_identifier(thd, &buf, db, db_len) ||
2368+ buf.append("; "))
2369+ return;
2370+ }
2371+ if (query && q_len && buf.append(query, q_len))
2372+ return;
2373+ int10_to_str((long) file_id, file_id_buf, 10);
2374+ if (buf.append(" ;file_id=") ||
2375+ buf.append(file_id_buf))
2376+ return;
2377+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
2378 }
2379
2380
2381@@ -8248,7 +8290,7 @@
2382 #endif
2383
2384 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2385-void Rows_log_event::pack_info(Protocol *protocol)
2386+void Rows_log_event::pack_info(THD *thd, Protocol *protocol)
2387 {
2388 char buf[256];
2389 char const *const flagstr=
2390@@ -8851,7 +8893,7 @@
2391 */
2392
2393 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2394-void Table_map_log_event::pack_info(Protocol *protocol)
2395+void Table_map_log_event::pack_info(THD *thd, Protocol *protocol)
2396 {
2397 char buf[256];
2398 size_t bytes= my_snprintf(buf, sizeof(buf),
2399@@ -8871,9 +8913,21 @@
2400 if (!print_event_info->short_form)
2401 {
2402 print_header(&print_event_info->head_cache, print_event_info, TRUE);
2403+ QUOTED_IDENTIFIER(db_nam,
2404+ 512,
2405+ '`',
2406+ &my_charset_bin,
2407+ m_dbnam,
2408+ strlen(m_dbnam));
2409+ QUOTED_IDENTIFIER(tbl_nam,
2410+ 512,
2411+ '`',
2412+ &my_charset_bin,
2413+ m_tblnam,
2414+ strlen(m_tblnam));
2415 my_b_printf(&print_event_info->head_cache,
2416- "\tTable_map: `%s`.`%s` mapped to number %lu\n",
2417- m_dbnam, m_tblnam, m_table_id);
2418+ "\tTable_map: %s.%s mapped to number %lu\n",
2419+ db_nam.c_ptr(), tbl_nam.c_ptr(), m_table_id);
2420 print_base64(&print_event_info->body_cache, print_event_info, TRUE);
2421 }
2422 }
2423@@ -10142,7 +10196,7 @@
2424
2425
2426 #ifndef MYSQL_CLIENT
2427-void Incident_log_event::pack_info(Protocol *protocol)
2428+void Incident_log_event::pack_info(THD *thd, Protocol *protocol)
2429 {
2430 char buf[256];
2431 size_t bytes;
2432
2433=== modified file 'Percona-Server/sql/log_event.h'
2434--- Percona-Server/sql/log_event.h 2012-09-17 13:08:32 +0000
2435+++ Percona-Server/sql/log_event.h 2012-10-10 20:41:51 +0000
2436@@ -1010,14 +1010,15 @@
2437 */
2438 static void init_show_field_list(List<Item>* field_list);
2439 #ifdef HAVE_REPLICATION
2440- int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
2441+ int net_send(THD *thd, Protocol *protocol, const char* log_name,
2442+ my_off_t pos);
2443
2444 /*
2445 pack_info() is used by SHOW BINLOG EVENTS; as print() it prepares and sends
2446 a string to display to the user, so it resembles print().
2447 */
2448
2449- virtual void pack_info(Protocol *protocol);
2450+ virtual void pack_info(THD *thd, Protocol *protocol);
2451
2452 #endif /* HAVE_REPLICATION */
2453 virtual const char* get_db()
2454@@ -1723,7 +1724,7 @@
2455 bool using_trans, bool direct, bool suppress_use, int error);
2456 const char* get_db() { return db; }
2457 #ifdef HAVE_REPLICATION
2458- void pack_info(Protocol* protocol);
2459+ void pack_info(THD *thd, Protocol* protocol);
2460 #endif /* HAVE_REPLICATION */
2461 #else
2462 void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
2463@@ -1853,7 +1854,7 @@
2464
2465 #ifdef MYSQL_SERVER
2466 Slave_log_event(THD* thd_arg, Relay_log_info* rli);
2467- void pack_info(Protocol* protocol);
2468+ void pack_info(THD *thd, Protocol* protocol);
2469 #else
2470 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2471 #endif
2472@@ -2086,9 +2087,11 @@
2473 const Format_description_log_event* description_event);
2474
2475 public:
2476- uint get_query_buffer_length();
2477- void print_query(bool need_db, const char *cs, char *buf, char **end,
2478- char **fn_start, char **fn_end);
2479+#ifndef MYSQL_CLIENT
2480+ void print_query(THD *thd, bool need_db, const char *cs, String *buf,
2481+ my_off_t *fn_start, my_off_t *fn_end,
2482+ const char *qualify_db);
2483+#endif
2484 ulong thread_id;
2485 ulong slave_proxy_id;
2486 uint32 table_name_len;
2487@@ -2149,7 +2152,7 @@
2488 Name_resolution_context *context);
2489 const char* get_db() { return db; }
2490 #ifdef HAVE_REPLICATION
2491- void pack_info(Protocol* protocol);
2492+ void pack_info(THD *thd, Protocol* protocol);
2493 #endif /* HAVE_REPLICATION */
2494 #else
2495 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2496@@ -2248,7 +2251,7 @@
2497 #ifdef MYSQL_SERVER
2498 Start_log_event_v3();
2499 #ifdef HAVE_REPLICATION
2500- void pack_info(Protocol* protocol);
2501+ void pack_info(THD *thd, Protocol* protocol);
2502 #endif /* HAVE_REPLICATION */
2503 #else
2504 Start_log_event_v3() {}
2505@@ -2400,7 +2403,7 @@
2506 :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
2507 {}
2508 #ifdef HAVE_REPLICATION
2509- void pack_info(Protocol* protocol);
2510+ void pack_info(THD *thd, Protocol* protocol);
2511 #endif /* HAVE_REPLICATION */
2512 #else
2513 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2514@@ -2476,7 +2479,7 @@
2515 :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
2516 {}
2517 #ifdef HAVE_REPLICATION
2518- void pack_info(Protocol* protocol);
2519+ void pack_info(THD *thd, Protocol* protocol);
2520 #endif /* HAVE_REPLICATION */
2521 #else
2522 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2523@@ -2520,7 +2523,7 @@
2524 #ifdef MYSQL_SERVER
2525 Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg, 0, TRUE), xid(x) {}
2526 #ifdef HAVE_REPLICATION
2527- void pack_info(Protocol* protocol);
2528+ void pack_info(THD *thd, Protocol* protocol);
2529 #endif /* HAVE_REPLICATION */
2530 #else
2531 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2532@@ -2576,7 +2579,7 @@
2533 val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg),
2534 flags(flags_arg), deferred(false)
2535 { is_null= !val; }
2536- void pack_info(Protocol* protocol);
2537+ void pack_info(THD *thd, Protocol* protocol);
2538 #else
2539 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2540 #endif
2541@@ -2714,7 +2717,7 @@
2542 uint ident_len_arg,
2543 ulonglong pos_arg, uint flags);
2544 #ifdef HAVE_REPLICATION
2545- void pack_info(Protocol* protocol);
2546+ void pack_info(THD *thd, Protocol* protocol);
2547 #endif /* HAVE_REPLICATION */
2548 #else
2549 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2550@@ -2775,7 +2778,7 @@
2551 uchar* block_arg, uint block_len_arg,
2552 bool using_trans);
2553 #ifdef HAVE_REPLICATION
2554- void pack_info(Protocol* protocol);
2555+ void pack_info(THD *thd, Protocol* protocol);
2556 #endif /* HAVE_REPLICATION */
2557 #else
2558 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2559@@ -2847,7 +2850,7 @@
2560 Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
2561 uint block_len_arg, bool using_trans);
2562 #ifdef HAVE_REPLICATION
2563- void pack_info(Protocol* protocol);
2564+ void pack_info(THD *thd, Protocol* protocol);
2565 virtual int get_create_or_append() const;
2566 #endif /* HAVE_REPLICATION */
2567 #else
2568@@ -2888,7 +2891,7 @@
2569 #ifdef MYSQL_SERVER
2570 Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
2571 #ifdef HAVE_REPLICATION
2572- void pack_info(Protocol* protocol);
2573+ void pack_info(THD *thd, Protocol* protocol);
2574 #endif /* HAVE_REPLICATION */
2575 #else
2576 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2577@@ -2929,7 +2932,7 @@
2578 #ifdef MYSQL_SERVER
2579 Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
2580 #ifdef HAVE_REPLICATION
2581- void pack_info(Protocol* protocol);
2582+ void pack_info(THD *thd, Protocol* protocol);
2583 #endif /* HAVE_REPLICATION */
2584 #else
2585 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2586@@ -3025,7 +3028,7 @@
2587 bool using_trans, bool direct,
2588 bool suppress_use, int errcode);
2589 #ifdef HAVE_REPLICATION
2590- void pack_info(Protocol* protocol);
2591+ void pack_info(THD *thd, Protocol* protocol);
2592 #endif /* HAVE_REPLICATION */
2593 #else
2594 void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2595@@ -3470,7 +3473,7 @@
2596 #endif
2597
2598 #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2599- virtual void pack_info(Protocol *protocol);
2600+ virtual void pack_info(THD *thd, Protocol *protocol);
2601 #endif
2602
2603 #ifdef MYSQL_CLIENT
2604@@ -3582,7 +3585,7 @@
2605 flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
2606
2607 #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2608- virtual void pack_info(Protocol *protocol);
2609+ virtual void pack_info(THD *thd, Protocol *protocol);
2610 #endif
2611
2612 #ifdef MYSQL_CLIENT
2613@@ -4021,7 +4024,7 @@
2614 #endif
2615
2616 #ifdef MYSQL_SERVER
2617- void pack_info(Protocol*);
2618+ void pack_info(THD *thd, Protocol*);
2619 #endif
2620
2621 Incident_log_event(const char *buf, uint event_len,
2622
2623=== modified file 'Percona-Server/sql/log_event_old.cc'
2624--- Percona-Server/sql/log_event_old.cc 2012-05-07 20:20:42 +0000
2625+++ Percona-Server/sql/log_event_old.cc 2012-10-10 20:41:51 +0000
2626@@ -1926,7 +1926,7 @@
2627
2628
2629 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
2630-void Old_rows_log_event::pack_info(Protocol *protocol)
2631+void Old_rows_log_event::pack_info(THD *thd, Protocol *protocol)
2632 {
2633 char buf[256];
2634 char const *const flagstr=
2635
2636=== modified file 'Percona-Server/sql/log_event_old.h'
2637--- Percona-Server/sql/log_event_old.h 2007-12-05 19:00:14 +0000
2638+++ Percona-Server/sql/log_event_old.h 2012-10-10 20:41:51 +0000
2639@@ -108,7 +108,7 @@
2640 flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
2641
2642 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2643- virtual void pack_info(Protocol *protocol);
2644+ virtual void pack_info(THD *thd, Protocol *protocol);
2645 #endif
2646
2647 #ifdef MYSQL_CLIENT
2648
2649=== modified file 'Percona-Server/sql/sql_base.cc'
2650--- Percona-Server/sql/sql_base.cc 2012-09-17 13:08:32 +0000
2651+++ Percona-Server/sql/sql_base.cc 2012-10-10 20:41:51 +0000
2652@@ -3855,22 +3855,22 @@
2653 entry->file->implicit_emptied= 0;
2654 if (mysql_bin_log.is_open())
2655 {
2656- char *query, *end;
2657- uint query_buf_size= 20 + share->db.length + share->table_name.length +1;
2658- if ((query= (char*) my_malloc(query_buf_size,MYF(MY_WME))))
2659+ char query_buf[2*FN_REFLEN + 21];
2660+ String query(query_buf, sizeof(query_buf), system_charset_info);
2661+ query.length(0);
2662+ if (query.ptr())
2663 {
2664 /* this DELETE FROM is needed even with row-based binlogging */
2665- end = strxmov(strmov(query, "DELETE FROM `"),
2666- share->db.str,"`.`",share->table_name.str,"`", NullS);
2667+ query.append("DELETE FROM ");
2668+ append_identifier(thd, &query, share->db.str, share->db.length);
2669+ query.append(".");
2670+ append_identifier(thd, &query, share->table_name.str,
2671+ share->table_name.length);
2672 int errcode= query_error_code(thd, TRUE);
2673 if (thd->binlog_query(THD::STMT_QUERY_TYPE,
2674- query, (ulong)(end-query),
2675+ query.ptr(), query.length(),
2676 FALSE, FALSE, FALSE, errcode))
2677- {
2678- my_free(query);
2679- return TRUE;
2680- }
2681- my_free(query);
2682+ return FALSE;
2683 }
2684 else
2685 {
2686@@ -3879,9 +3879,20 @@
2687 DBA on top of warning the client (which will automatically be done
2688 because of MYF(MY_WME) in my_malloc() above).
2689 */
2690+ char q_db_c[512];
2691+ char q_table_name_c[512];
2692+ String q_db(q_db_c, sizeof(q_db_c), system_charset_info);
2693+ String q_table_name(q_table_name_c, sizeof(q_table_name), system_charset_info);
2694+ q_db.length(0);
2695+ q_table_name.length(0);
2696+ append_identifier(thd, &q_db, share->db.str, share->db.length);
2697+ append_identifier(thd,
2698+ &q_table_name,
2699+ share->table_name.str,
2700+ share->table_name.length);
2701 sql_print_error("When opening HEAP table, could not allocate memory "
2702- "to write 'DELETE FROM `%s`.`%s`' to the binary log",
2703- share->db.str, share->table_name.str);
2704+ "to write 'DELETE FROM %s.%s' to the binary log",
2705+ q_db.c_ptr(), q_table_name.c_ptr());
2706 delete entry->triggers;
2707 return TRUE;
2708 }
2709
2710=== modified file 'Percona-Server/sql/sql_db.cc'
2711--- Percona-Server/sql/sql_db.cc 2011-07-03 23:48:19 +0000
2712+++ Percona-Server/sql/sql_db.cc 2012-10-10 20:41:51 +0000
2713@@ -542,7 +542,6 @@
2714 bool silent)
2715 {
2716 char path[FN_REFLEN+16];
2717- char tmp_query[FN_REFLEN+16];
2718 long result= 1;
2719 int error= 0;
2720 MY_STAT stat_info;
2721@@ -620,17 +619,9 @@
2722 char *query;
2723 uint query_length;
2724
2725- if (!thd->query()) // Only in replication
2726- {
2727- query= tmp_query;
2728- query_length= (uint) (strxmov(tmp_query,"create database `",
2729- db, "`", NullS) - tmp_query);
2730- }
2731- else
2732- {
2733- query= thd->query();
2734- query_length= thd->query_length();
2735- }
2736+ query= thd->query();
2737+ query_length= thd->query_length();
2738+ DBUG_ASSERT(query);
2739
2740 ha_binlog_log_query(thd, 0, LOGCOM_CREATE_DB,
2741 query, query_length,
2742@@ -883,18 +874,11 @@
2743 {
2744 const char *query;
2745 ulong query_length;
2746- if (!thd->query())
2747- {
2748- /* The client used the old obsolete mysql_drop_db() call */
2749- query= path;
2750- query_length= (uint) (strxmov(path, "drop database `", db, "`",
2751- NullS) - path);
2752- }
2753- else
2754- {
2755- query= thd->query();
2756- query_length= thd->query_length();
2757- }
2758+
2759+ query= thd->query();
2760+ query_length= thd->query_length();
2761+ DBUG_ASSERT(query);
2762+
2763 if (mysql_bin_log.is_open())
2764 {
2765 int errcode= query_error_code(thd, TRUE);
2766@@ -948,8 +932,16 @@
2767 if (exists)
2768 continue;
2769
2770- /* 3 for the quotes and the comma*/
2771- tbl_name_len= strlen(tbl->table_name) + 3;
2772+ char quoted_name_c[FN_REFLEN+3];
2773+ String quoted_name(quoted_name_c,
2774+ sizeof(quoted_name_c),
2775+ system_charset_info);
2776+ quoted_name.length(0);
2777+ quoted_name.append_identifier(tbl->table_name,
2778+ strlen(tbl->table_name),
2779+ system_charset_info,
2780+ '`');
2781+ tbl_name_len= quoted_name.length() + 1; /* +1 for the comma */
2782 if (query_pos + tbl_name_len + 1 >= query_end)
2783 {
2784 /*
2785@@ -964,9 +956,7 @@
2786 query_pos= query_data_start;
2787 }
2788
2789- *query_pos++ = '`';
2790- query_pos= strmov(query_pos,tbl->table_name);
2791- *query_pos++ = '`';
2792+ query_pos= strmov(query_pos, quoted_name.c_ptr());
2793 *query_pos++ = ',';
2794 }
2795
2796
2797=== modified file 'Percona-Server/sql/sql_load.cc'
2798--- Percona-Server/sql/sql_load.cc 2012-02-16 09:48:16 +0000
2799+++ Percona-Server/sql/sql_load.cc 2012-10-10 20:41:51 +0000
2800@@ -38,6 +38,7 @@
2801 #include "sql_repl.h"
2802 #include "sp_head.h"
2803 #include "sql_trigger.h"
2804+#include "sql_show.h"
2805
2806 class XML_TAG {
2807 public:
2808@@ -665,20 +666,28 @@
2809 bool transactional_table,
2810 int errcode)
2811 {
2812- char *load_data_query,
2813- *end,
2814- *fname_start,
2815- *fname_end,
2816- *p= NULL;
2817- size_t pl= 0;
2818+ char *load_data_query;
2819+ my_off_t fname_start,
2820+ fname_end;
2821 List<Item> fv;
2822 Item *item, *val;
2823- String pfield, pfields;
2824 int n;
2825- const char *tbl= table_name_arg;
2826 const char *tdb= (thd->db != NULL ? thd->db : db_arg);
2827- String string_buf;
2828-
2829+ const char *qualify_db= NULL;
2830+ char command_buffer[1024];
2831+ String query_str(command_buffer, sizeof(command_buffer),
2832+ system_charset_info);
2833+
2834+ Load_log_event lle(thd, ex, tdb, table_name_arg, fv, is_concurrent,
2835+ duplicates, ignore, transactional_table);
2836+
2837+ /*
2838+ force in a LOCAL if there was one in the original.
2839+ */
2840+ if (thd->lex->local_file)
2841+ lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
2842+
2843+ query_str.length(0);
2844 if (!thd->db || strcmp(db_arg, thd->db))
2845 {
2846 /*
2847@@ -686,23 +695,10 @@
2848 prefix table name with database name so that it
2849 becomes a FQ name.
2850 */
2851- string_buf.set_charset(system_charset_info);
2852- string_buf.append(db_arg);
2853- string_buf.append("`");
2854- string_buf.append(".");
2855- string_buf.append("`");
2856- string_buf.append(table_name_arg);
2857- tbl= string_buf.c_ptr_safe();
2858+ qualify_db= db_arg;
2859 }
2860-
2861- Load_log_event lle(thd, ex, tdb, tbl, fv, is_concurrent,
2862- duplicates, ignore, transactional_table);
2863-
2864- /*
2865- force in a LOCAL if there was one in the original.
2866- */
2867- if (thd->lex->local_file)
2868- lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
2869+ lle.print_query(thd, FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
2870+ &query_str, &fname_start, &fname_end, qualify_db);
2871
2872 /*
2873 prepare fields-list and SET if needed; print_query won't do that for us.
2874@@ -711,23 +707,23 @@
2875 {
2876 List_iterator<Item> li(thd->lex->field_list);
2877
2878- pfields.append(" (");
2879+ query_str.append(" (");
2880 n= 0;
2881
2882 while ((item= li++))
2883 {
2884 if (n++)
2885- pfields.append(", ");
2886+ query_str.append(", ");
2887 if (item->type() == Item::FIELD_ITEM)
2888+ append_identifier(thd, &query_str, item->name, strlen(item->name));
2889+ else
2890 {
2891- pfields.append("`");
2892- pfields.append(item->name);
2893- pfields.append("`");
2894+ /* Actually Item_user_var_as_out_param despite claiming STRING_ITEM. */
2895+ DBUG_ASSERT(item->type() == Item::STRING_ITEM);
2896+ ((Item_user_var_as_out_param *)item)->print_for_load(thd, &query_str);
2897 }
2898- else
2899- item->print(&pfields, QT_ORDINARY);
2900 }
2901- pfields.append(")");
2902+ query_str.append(")");
2903 }
2904
2905 if (!thd->lex->update_list.is_empty())
2906@@ -735,38 +731,25 @@
2907 List_iterator<Item> lu(thd->lex->update_list);
2908 List_iterator<Item> lv(thd->lex->value_list);
2909
2910- pfields.append(" SET ");
2911+ query_str.append(" SET ");
2912 n= 0;
2913
2914 while ((item= lu++))
2915 {
2916 val= lv++;
2917 if (n++)
2918- pfields.append(", ");
2919- pfields.append("`");
2920- pfields.append(item->name);
2921- pfields.append("`");
2922- pfields.append(val->name);
2923+ query_str.append(", ");
2924+ append_identifier(thd, &query_str, item->name, strlen(item->name));
2925+ query_str.append(val->name);
2926 }
2927 }
2928
2929- p= pfields.c_ptr_safe();
2930- pl= strlen(p);
2931-
2932- if (!(load_data_query= (char *)thd->alloc(lle.get_query_buffer_length() + 1 + pl)))
2933+ if (!(load_data_query= (char *)thd->strmake(query_str.ptr(), query_str.length())))
2934 return TRUE;
2935
2936- lle.print_query(FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
2937- load_data_query, &end,
2938- (char **)&fname_start, (char **)&fname_end);
2939-
2940- strcpy(end, p);
2941- end += pl;
2942-
2943 Execute_load_query_log_event
2944- e(thd, load_data_query, end-load_data_query,
2945- (uint) ((char*) fname_start - load_data_query - 1),
2946- (uint) ((char*) fname_end - load_data_query),
2947+ e(thd, load_data_query, query_str.length(),
2948+ (uint) (fname_start - 1), (uint) fname_end,
2949 (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
2950 (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
2951 transactional_table, FALSE, FALSE, errcode);
2952
2953=== modified file 'Percona-Server/sql/sql_repl.cc'
2954--- Percona-Server/sql/sql_repl.cc 2012-09-17 13:08:32 +0000
2955+++ Percona-Server/sql/sql_repl.cc 2012-10-10 20:41:51 +0000
2956@@ -1849,7 +1849,7 @@
2957 description_event)); )
2958 {
2959 if (event_count >= limit_start &&
2960- ev->net_send(protocol, linfo.log_file_name, pos))
2961+ ev->net_send(thd, protocol, linfo.log_file_name, pos))
2962 {
2963 errmsg = "Net error";
2964 delete ev;
2965
2966=== modified file 'Percona-Server/sql/sql_select.cc'
2967--- Percona-Server/sql/sql_select.cc 2012-09-17 13:08:32 +0000
2968+++ Percona-Server/sql/sql_select.cc 2012-10-10 20:41:51 +0000
2969@@ -48,6 +48,7 @@
2970 #include "filesort.h" // filesort_free_buffers
2971 #include "sql_union.h" // mysql_union
2972 #include "debug_sync.h" // DEBUG_SYNC
2973+#include "sql_string.h"
2974 #include <m_ctype.h>
2975 #include <my_bit.h>
2976 #include <hash.h>
2977@@ -12125,8 +12126,16 @@
2978 */
2979 if (error != HA_ERR_LOCK_DEADLOCK && error != HA_ERR_LOCK_WAIT_TIMEOUT
2980 && !table->in_use->killed)
2981- sql_print_error("Got error %d when reading table '%s'",
2982- error, table->s->path.str);
2983+ {
2984+ QUOTED_IDENTIFIER(tbl_nam,
2985+ 512,
2986+ '`',
2987+ &my_charset_bin,
2988+ table->s->path.str,
2989+ table->s->path.length);
2990+ sql_print_error("Got error %d when reading table %s",
2991+ error, tbl_nam.c_ptr());
2992+ }
2993 table->file->print_error(error,MYF(0));
2994 return 1;
2995 }
2996
2997=== modified file 'Percona-Server/sql/sql_show.cc'
2998--- Percona-Server/sql/sql_show.cc 2012-09-17 13:08:32 +0000
2999+++ Percona-Server/sql/sql_show.cc 2012-10-10 20:41:51 +0000
3000@@ -984,48 +984,17 @@
3001 packet target string
3002 name the identifier to be appended
3003 name_length length of the appending identifier
3004+
3005+ RETURN VALUES
3006+ true Error
3007+ false Ok
3008 */
3009
3010-void
3011+bool
3012 append_identifier(THD *thd, String *packet, const char *name, uint length)
3013 {
3014- const char *name_end;
3015- char quote_char;
3016 int q= get_quote_char_for_identifier(thd, name, length);
3017-
3018- if (q == EOF)
3019- {
3020- packet->append(name, length, packet->charset());
3021- return;
3022- }
3023-
3024- /*
3025- The identifier must be quoted as it includes a quote character or
3026- it's a keyword
3027- */
3028-
3029- (void) packet->reserve(length*2 + 2);
3030- quote_char= (char) q;
3031- packet->append(&quote_char, 1, system_charset_info);
3032-
3033- for (name_end= name+length ; name < name_end ; name+= length)
3034- {
3035- uchar chr= (uchar) *name;
3036- length= my_mbcharlen(system_charset_info, chr);
3037- /*
3038- my_mbcharlen can return 0 on a wrong multibyte
3039- sequence. It is possible when upgrading from 4.0,
3040- and identifier contains some accented characters.
3041- The manual says it does not work. So we'll just
3042- change length to 1 not to hang in the endless loop.
3043- */
3044- if (!length)
3045- length= 1;
3046- if (length == 1 && chr == (uchar) quote_char)
3047- packet->append(&quote_char, 1, system_charset_info);
3048- packet->append(name, length, system_charset_info);
3049- }
3050- packet->append(&quote_char, 1, system_charset_info);
3051+ return packet->append_identifier(name, length, system_charset_info, q);
3052 }
3053
3054
3055
3056=== modified file 'Percona-Server/sql/sql_show.h'
3057--- Percona-Server/sql/sql_show.h 2011-06-30 15:46:53 +0000
3058+++ Percona-Server/sql/sql_show.h 2012-10-10 20:41:51 +0000
3059@@ -90,7 +90,7 @@
3060
3061 int copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table);
3062
3063-void append_identifier(THD *thd, String *packet, const char *name,
3064+bool append_identifier(THD *thd, String *packet, const char *name,
3065 uint length);
3066 void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
3067 int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
3068
3069=== modified file 'Percona-Server/sql/sql_string.cc'
3070--- Percona-Server/sql/sql_string.cc 2012-05-10 07:49:14 +0000
3071+++ Percona-Server/sql/sql_string.cc 2012-10-10 20:41:51 +0000
3072@@ -519,6 +519,49 @@
3073 return FALSE;
3074 }
3075
3076+bool String::append_identifier(const char *name,
3077+ uint length,
3078+ CHARSET_INFO *ci,
3079+ int quote_char)
3080+{
3081+ const char *name_end;
3082+ char q= (char)quote_char;
3083+ CHARSET_INFO *lci = ci ? ci : charset();
3084+
3085+ if (quote_char == EOF)
3086+ return append(name, length, charset());
3087+
3088+ /*
3089+ The identifier must be quoted as it includes a quote character or
3090+ it's a keyword
3091+ */
3092+
3093+ (void)reserve(length*2 + 2);
3094+ if (append(&q, 1, lci))
3095+ return true;
3096+
3097+ for (name_end= name+length ; name < name_end ; name+= length)
3098+ {
3099+ uchar chr= (uchar) *name;
3100+ length= my_mbcharlen(lci, chr);
3101+ /*
3102+ my_mbcharlen can return 0 on a wrong multibyte
3103+ sequence. It is possible when upgrading from 4.0,
3104+ and identifier contains some accented characters.
3105+ The manual says it does not work. So we'll just
3106+ change length to 1 not to hang in the endless loop.
3107+ */
3108+ if (!length)
3109+ length= 1;
3110+ if (length == 1 && chr == (uchar) q &&
3111+ append(&q, 1, lci))
3112+ return true;
3113+ if (append(name, length, lci))
3114+ return true;
3115+ }
3116+ return append(&q, 1, lci);
3117+}
3118+
3119 uint32 String::numchars()
3120 {
3121 return str_charset->cset->numchars(str_charset, Ptr, Ptr+str_length);
3122@@ -1120,39 +1163,47 @@
3123
3124
3125
3126-
3127-void String::print(String *str)
3128+/*
3129+ Append characters to a single-quoted string '...', escaping special
3130+ characters as necessary.
3131+ Does not add the enclosing quotes, this is left up to caller.
3132+*/
3133+void String::append_for_single_quote(const char *st, uint len)
3134 {
3135- char *st= (char*)Ptr, *end= st+str_length;
3136+ const char *end= st+len;
3137 for (; st < end; st++)
3138 {
3139 uchar c= *st;
3140 switch (c)
3141 {
3142 case '\\':
3143- str->append(STRING_WITH_LEN("\\\\"));
3144+ append(STRING_WITH_LEN("\\\\"));
3145 break;
3146 case '\0':
3147- str->append(STRING_WITH_LEN("\\0"));
3148+ append(STRING_WITH_LEN("\\0"));
3149 break;
3150 case '\'':
3151- str->append(STRING_WITH_LEN("\\'"));
3152+ append(STRING_WITH_LEN("\\'"));
3153 break;
3154 case '\n':
3155- str->append(STRING_WITH_LEN("\\n"));
3156+ append(STRING_WITH_LEN("\\n"));
3157 break;
3158 case '\r':
3159- str->append(STRING_WITH_LEN("\\r"));
3160+ append(STRING_WITH_LEN("\\r"));
3161 break;
3162 case '\032': // Ctrl-Z
3163- str->append(STRING_WITH_LEN("\\Z"));
3164+ append(STRING_WITH_LEN("\\Z"));
3165 break;
3166 default:
3167- str->append(c);
3168+ append(c);
3169 }
3170 }
3171 }
3172
3173+void String::print(String *str)
3174+{
3175+ str->append_for_single_quote(Ptr, str_length);
3176+}
3177
3178 /*
3179 Exchange state of this object and argument.
3180
3181=== modified file 'Percona-Server/sql/sql_string.h'
3182--- Percona-Server/sql/sql_string.h 2012-05-10 07:49:14 +0000
3183+++ Percona-Server/sql/sql_string.h 2012-10-10 20:41:51 +0000
3184@@ -26,6 +26,12 @@
3185 #include "my_sys.h" /* alloc_root, my_free, my_realloc */
3186 #include "m_string.h" /* TRASH */
3187
3188+#define QUOTED_IDENTIFIER(str_name, buf_size, q, cs, id_name, id_size) \
3189+ char buf_##str_name[(buf_size)]; \
3190+ String str_name((buf_##str_name), (buf_size), (cs)); \
3191+ str_name.length(0); \
3192+ str_name.append_identifier((id_name), (id_size), (cs), (q));
3193+
3194 class String;
3195 typedef struct charset_info_st CHARSET_INFO;
3196 typedef struct st_io_cache IO_CACHE;
3197@@ -292,6 +298,10 @@
3198 bool append(IO_CACHE* file, uint32 arg_length);
3199 bool append_with_prefill(const char *s, uint32 arg_length,
3200 uint32 full_length, char fill_char);
3201+ bool append_identifier(const char *name,
3202+ uint length,
3203+ CHARSET_INFO *ci,
3204+ int quote_char);
3205 int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
3206 int strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
3207 bool replace(uint32 offset,uint32 arg_length,const char *to,uint32 length);
3208@@ -395,6 +405,7 @@
3209 return FALSE;
3210 }
3211 void print(String *print);
3212+ void append_for_single_quote(const char *st, uint len);
3213
3214 /* Swap two string objects. Efficient way to exchange data without memcpy. */
3215 void swap(String &s);
3216
3217=== modified file 'Percona-Server/sql/sql_table.cc'
3218--- Percona-Server/sql/sql_table.cc 2012-08-07 06:10:00 +0000
3219+++ Percona-Server/sql/sql_table.cc 2012-10-10 20:41:51 +0000
3220@@ -2053,6 +2053,7 @@
3221 {
3222 bool is_trans;
3223 char *db=table->db;
3224+ size_t db_length= table->db_length;
3225 handlerton *table_type;
3226 enum legacy_db_type frm_db_type= DB_TYPE_UNKNOWN;
3227
3228@@ -2114,14 +2115,14 @@
3229 Don't write the database name if it is the current one (or if
3230 thd->db is NULL).
3231 */
3232- built_ptr_query->append("`");
3233 if (thd->db == NULL || strcmp(db,thd->db) != 0)
3234 {
3235- built_ptr_query->append(db);
3236- built_ptr_query->append("`.`");
3237+ append_identifier(thd, built_ptr_query, db, db_length);
3238+ built_ptr_query->append(".");
3239 }
3240- built_ptr_query->append(table->table_name);
3241- built_ptr_query->append("`,");
3242+ append_identifier(thd, built_ptr_query, table->table_name,
3243+ table->table_name_length);
3244+ built_ptr_query->append(",");
3245 }
3246 /*
3247 This means that a temporary table was droped and as such there
3248@@ -2180,15 +2181,15 @@
3249 Don't write the database name if it is the current one (or if
3250 thd->db is NULL).
3251 */
3252- built_query.append("`");
3253 if (thd->db == NULL || strcmp(db,thd->db) != 0)
3254 {
3255- built_query.append(db);
3256- built_query.append("`.`");
3257+ append_identifier(thd, &built_query, db, db_length);
3258+ built_query.append(".");
3259 }
3260
3261- built_query.append(table->table_name);
3262- built_query.append("`,");
3263+ append_identifier(thd, &built_query, table->table_name,
3264+ table->table_name_length);
3265+ built_query.append(",");
3266 }
3267 }
3268 DEBUG_SYNC(thd, "rm_table_no_locks_before_delete_table");
3269
3270=== modified file 'Percona-Server/sql/sql_truncate.cc'
3271--- Percona-Server/sql/sql_truncate.cc 2011-03-07 09:08:10 +0000
3272+++ Percona-Server/sql/sql_truncate.cc 2012-10-10 20:41:51 +0000
3273@@ -24,6 +24,7 @@
3274 #include "sql_acl.h" // DROP_ACL
3275 #include "sql_parse.h" // check_one_table_access()
3276 #include "sql_truncate.h"
3277+#include "sql_show.h"
3278
3279
3280 /**
3281@@ -35,7 +36,8 @@
3282 @return TRUE on failure, FALSE otherwise.
3283 */
3284
3285-static bool fk_info_append_fields(String *str, List<LEX_STRING> *fields)
3286+static bool fk_info_append_fields(THD *thd, String *str,
3287+ List<LEX_STRING> *fields)
3288 {
3289 bool res= FALSE;
3290 LEX_STRING *field;
3291@@ -43,9 +45,8 @@
3292
3293 while ((field= it++))
3294 {
3295- res|= str->append("`");
3296- res|= str->append(field);
3297- res|= str->append("`, ");
3298+ res|= append_identifier(thd, str, field->str, field->length);
3299+ res|= str->append(", ");
3300 }
3301
3302 str->chop();
3303@@ -76,20 +77,24 @@
3304 `db`.`tbl`, CONSTRAINT `id` FOREIGN KEY (`fk`) REFERENCES `db`.`tbl` (`fk`)
3305 */
3306
3307- res|= str.append('`');
3308- res|= str.append(fk_info->foreign_db);
3309- res|= str.append("`.`");
3310- res|= str.append(fk_info->foreign_table);
3311- res|= str.append("`, CONSTRAINT `");
3312- res|= str.append(fk_info->foreign_id);
3313- res|= str.append("` FOREIGN KEY (");
3314- res|= fk_info_append_fields(&str, &fk_info->foreign_fields);
3315- res|= str.append(") REFERENCES `");
3316- res|= str.append(fk_info->referenced_db);
3317- res|= str.append("`.`");
3318- res|= str.append(fk_info->referenced_table);
3319- res|= str.append("` (");
3320- res|= fk_info_append_fields(&str, &fk_info->referenced_fields);
3321+ res|= append_identifier(thd, &str, fk_info->foreign_db->str,
3322+ fk_info->foreign_db->length);
3323+ res|= str.append(".");
3324+ res|= append_identifier(thd, &str, fk_info->foreign_table->str,
3325+ fk_info->foreign_table->length);
3326+ res|= str.append(", CONSTRAINT ");
3327+ res|= append_identifier(thd, &str, fk_info->foreign_id->str,
3328+ fk_info->foreign_id->length);
3329+ res|= str.append(" FOREIGN KEY (");
3330+ res|= fk_info_append_fields(thd, &str, &fk_info->foreign_fields);
3331+ res|= str.append(") REFERENCES ");
3332+ res|= append_identifier(thd, &str, fk_info->referenced_db->str,
3333+ fk_info->referenced_db->length);
3334+ res|= str.append(".");
3335+ res|= append_identifier(thd, &str, fk_info->referenced_table->str,
3336+ fk_info->referenced_table->length);
3337+ res|= str.append(" (");
3338+ res|= fk_info_append_fields(thd, &str, &fk_info->referenced_fields);
3339 res|= str.append(')');
3340
3341 return res ? NULL : thd->strmake(str.ptr(), str.length());
3342
3343=== modified file 'Percona-Server/sql/sql_yacc.yy'
3344--- Percona-Server/sql/sql_yacc.yy 2012-09-17 13:08:32 +0000
3345+++ Percona-Server/sql/sql_yacc.yy 2012-10-10 20:41:51 +0000
3346@@ -11735,7 +11735,7 @@
3347 if (lex->update_list.push_back($1) ||
3348 lex->value_list.push_back($4))
3349 MYSQL_YYABORT;
3350- $4->set_name($3, (uint) ($5 - $3), YYTHD->charset());
3351+ $4->set_name_no_truncate($3, (uint) ($5 - $3), YYTHD->charset());
3352 }
3353 ;
3354

Subscribers

People subscribed via source and target branches