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

Proposed by Vlad Lesin on 2012-09-25
Status: Merged
Approved by: Stewart Smith on 2013-01-03
Approved revision: 484
Merged at revision: 510
Proposed branch: lp:~vlad-lesin/percona-server/5.1-bug1049871-injections-gca
Merge into: lp:percona-server/5.1
Diff against target: 3096 lines (+1134/-485)
37 files modified
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/mysqlbinlog.result (+12/-12)
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 (+275/-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 (+249/-0)
Percona-Server/sql/ha_ndbcluster_binlog.cc (+17/-8)
Percona-Server/sql/item.cc (+2/-1)
Percona-Server/sql/item_func.cc (+3/-3)
Percona-Server/sql/item_func.h (+1/-1)
Percona-Server/sql/log.cc (+5/-6)
Percona-Server/sql/log_event.cc (+251/-203)
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/mysql_priv.h (+1/-1)
Percona-Server/sql/sql_base.cc (+23/-12)
Percona-Server/sql/sql_db.cc (+19/-30)
Percona-Server/sql/sql_insert.cc (+7/-7)
Percona-Server/sql/sql_load.cc (+35/-56)
Percona-Server/sql/sql_repl.cc (+1/-1)
Percona-Server/sql/sql_show.cc (+6/-37)
Percona-Server/sql/sql_string.cc (+61/-10)
Percona-Server/sql/sql_string.h (+11/-0)
Percona-Server/sql/sql_table.cc (+11/-10)
To merge this branch: bzr merge lp:~vlad-lesin/percona-server/5.1-bug1049871-injections-gca
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve on 2013-01-03
Laurynas Biveinis (community) 2012-09-25 Approve on 2012-10-12
Review via email: mp+126236@code.launchpad.net

Description of the change

The fix for bug #1049871.

Test results can be found here http://jenkins.percona.com/view/PS%205.1/job/percona-server-5.1-param/426/ .

Each failed test was ran separately on same hosts at least 100 times. Only rpl_stop_slave test fail was repeated that way. Except that here http://jenkins.percona.com/view/PS%205.1/job/percona-server-5.1-param/427/ are test results for clean 5.1. As we can see there is almost the same failed tests set. That allows me suppose failed tests are not connected with the new code.

To post a comment you must log in.
Stewart Smith (stewart) wrote :

This will need a 5.5 branch before we can merge.

Vlad Lesin (vlad-lesin) wrote :

> This will need a 5.5 branch before we can merge.

Yes, I've just pushed 5.5 version and it is under testing now.

   - QUOTED_IDENTIFIED macro definition should use the do { ... }
     while(0) idiom. Also, it is duplicated three times in the
     patch.
   - Lines 1074--1075 formatting issue.
   - The patch is missing
     mysql-test/suite/rpl/t/rpl_mdev382.test|result. Is this intentional?

review: Needs Fixing

This was only a partial review.

Vlad Lesin (vlad-lesin) wrote :

> - QUOTED_IDENTIFIED macro definition should use the do { ... }
> while(0) idiom.
The idea of this macros is to use allocation on stack for string operation. That is why that idiom does not suite for the macros.

> Also, it is duplicated three times in the patch.
IMHO the macros is repeated twice as the whole sql_string.* for client and server parts. Logically this macros should be in sql_string.h header. I decided it is not a good idea to make new header file just for that macros.

> - Lines 1074--1075 formatting issue.
Fixed.

> - The patch is missing
> mysql-test/suite/rpl/t/rpl_mdev382.test|result. Is this intentional?
I missed it. Thanks. I relaunched jenkins testing to be sure this test is passed.

> > - QUOTED_IDENTIFIED macro definition should use the do { ... }
> > while(0) idiom.
> The idea of this macros is to use allocation on stack for string operation.
> That is why that idiom does not suite for the macros.

Ah, correct, sorry. And declaring the var outside the macro, then passing its address will not be optimal due to constructor initialization.

>
> > Also, it is duplicated three times in the patch.
> IMHO the macros is repeated twice as the whole sql_string.* for client and
> server parts. Logically this macros should be in sql_string.h header. I
> decided it is not a good idea to make new header file just for that macros.

OK, especially given the nature of the patch.

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

review: Approve
Stewart Smith (stewart) wrote :

http://jenkins.percona.com/job/merge-PS-5.1-staging/16/BUILD_TYPE=release,Host=centos6-64/testReport/junit/%28root%29/rpl/rpl_mdev382__stmt_/

CURRENT_TEST: rpl.rpl_mdev382
--- /home/jenkins/workspace/merge-PS-5.1-staging/BUILD_TYPE/release/Host/centos6-64/Percona-Server/mysql-test/suite/rpl/r/rpl_mdev382.result 2012-12-21 01:34:50.044464000 +0300
+++ /home/jenkins/workspace/merge-PS-5.1-staging/BUILD_TYPE/release/Host/centos6-64/Percona-Server/mysql-test/suite/rpl/r/rpl_mdev382.reject 2012-12-21 01:40:08.249617163 +0300
@@ -206,7 +206,7 @@
 master-bin.000001 # User var # # @`a``2`=42
 master-bin.000001 # User var # # @`a``3`=9223372036854775807
 master-bin.000001 # User var # # @`a``4`=-1
-master-bin.000001 # User var # # @`b```=-1.2345601234568e+125
+master-bin.000001 # User var # # @`b```=%
 master-bin.000001 # User var # # @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789
 master-bin.000001 # User var # # @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE latin1_swedish_ci
 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))

mysqltest: Result content mismatch
------------

review: Needs Fixing
Vlad Lesin (vlad-lesin) wrote :

Fixed in last revision (http://jenkins.percona.com/view/PS%205.1/job/percona-server-5.1-param/479/ )

> http://jenkins.percona.com/job/merge-PS-5.1-staging/16/BUILD_TYPE=release,Host
> =centos6-64/testReport/junit/%28root%29/rpl/rpl_mdev382__stmt_/
>
> CURRENT_TEST: rpl.rpl_mdev382
> --- /home/jenkins/workspace/merge-
> PS-5.1-staging/BUILD_TYPE/release/Host/centos6-64/Percona-Server/mysql-
> test/suite/rpl/r/rpl_mdev382.result 2012-12-21 01:34:50.044464000 +0300
> +++ /home/jenkins/workspace/merge-
> PS-5.1-staging/BUILD_TYPE/release/Host/centos6-64/Percona-Server/mysql-
> test/suite/rpl/r/rpl_mdev382.reject 2012-12-21 01:40:08.249617163 +0300
> @@ -206,7 +206,7 @@
> master-bin.000001 # User var # # @`a``2`=42
> master-bin.000001 # User var # #
> @`a``3`=9223372036854775807
> master-bin.000001 # User var # # @`a``4`=-1
> -master-bin.000001 # User var # #
> @`b```=-1.2345601234568e+125
> +master-bin.000001 # User var # # @`b```=%
> master-bin.000001 # User var # #
> @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789
> master-bin.000001 # User var # #
> @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787
> 878787878787878787878787878787878787878787878787878787878787878787878787878787
> 878787878787878787878787878787878787878787878787878787878787878 COLLATE
> latin1_swedish_ci
> 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))
>
> mysqltest: Result content mismatch
> ------------

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

Subscribers

People subscribed via source and target branches