This file is indexed.

/usr/lib/mysql-testsuite/r/sql_mode.result is in percona-server-test-5.6 5.6.22-rel71.0-0ubuntu4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
drop table if exists t1,t2,v1,v2;
drop view if exists t1,t2,v1,v2;
CREATE TABLE `t1` (
a int not null auto_increment,
`pseudo` varchar(35) character set latin2 NOT NULL default '',
`email` varchar(60) character set latin2 NOT NULL default '',
PRIMARY KEY  (a),
UNIQUE KEY `email` USING BTREE (`email`) 
) ENGINE=HEAP CHARSET=latin1 ROW_FORMAT DYNAMIC;
set @@sql_mode="";
show variables like 'sql_mode';
Variable_name	Value
sql_mode	
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `pseudo` varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '',
  `email` varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '',
  PRIMARY KEY (`a`),
  UNIQUE KEY `email` (`email`) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
set @@sql_mode="ansi_quotes";
show variables like 'sql_mode';
Variable_name	Value
sql_mode	ANSI_QUOTES
show create table t1;
Table	Create Table
t1	CREATE TABLE "t1" (
  "a" int(11) NOT NULL AUTO_INCREMENT,
  "pseudo" varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '',
  "email" varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '',
  PRIMARY KEY ("a"),
  UNIQUE KEY "email" ("email") USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
set @@sql_mode="no_table_options";
show variables like 'sql_mode';
Variable_name	Value
sql_mode	NO_TABLE_OPTIONS
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `pseudo` varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '',
  `email` varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '',
  PRIMARY KEY (`a`),
  UNIQUE KEY `email` (`email`) USING BTREE
)
set @@sql_mode="no_key_options";
show variables like 'sql_mode';
Variable_name	Value
sql_mode	NO_KEY_OPTIONS
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `pseudo` varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '',
  `email` varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '',
  PRIMARY KEY (`a`),
  UNIQUE KEY `email` (`email`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
set @@sql_mode="no_field_options,mysql323,mysql40";
show variables like 'sql_mode';
Variable_name	Value
sql_mode	NO_FIELD_OPTIONS,MYSQL323,MYSQL40,HIGH_NOT_PRECEDENCE
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) NOT NULL,
  `pseudo` varchar(35) NOT NULL DEFAULT '',
  `email` varchar(60) NOT NULL DEFAULT '',
  PRIMARY KEY (`a`),
  UNIQUE KEY `email` (`email`)
) TYPE=HEAP ROW_FORMAT=DYNAMIC
set sql_mode="postgresql,oracle,mssql,db2,maxdb";
select @@sql_mode;
@@sql_mode
PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,POSTGRESQL,ORACLE,MSSQL,DB2,MAXDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER
show create table t1;
Table	Create Table
t1	CREATE TABLE "t1" (
  "a" int(11) NOT NULL,
  "pseudo" varchar(35) CHARACTER SET latin2 NOT NULL DEFAULT '',
  "email" varchar(60) CHARACTER SET latin2 NOT NULL DEFAULT '',
  PRIMARY KEY ("a"),
  UNIQUE KEY "email" ("email")
)
drop table t1;
CREATE TABLE t1 (
a char(10),
b char(10) collate latin1_bin,
c binary(10)
) character set latin1;
set @@sql_mode="";
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` char(10) DEFAULT NULL,
  `b` char(10) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
  `c` binary(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
set @@sql_mode="mysql323";
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` char(10) DEFAULT NULL,
  `b` char(10) binary DEFAULT NULL,
  `c` binary(10) DEFAULT NULL
) TYPE=MyISAM
set @@sql_mode="mysql40";
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` char(10) DEFAULT NULL,
  `b` char(10) binary DEFAULT NULL,
  `c` binary(10) DEFAULT NULL
) TYPE=MyISAM
drop table t1;
set session sql_mode = '';
create table t1 ( min_num   dec(6,6)     default .000001);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `min_num` decimal(6,6) DEFAULT '0.000001'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1 ;
set session sql_mode = 'IGNORE_SPACE';
create table t1 ( min_num   dec(6,6)     default 0.000001);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `min_num` decimal(6,6) DEFAULT '0.000001'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1 ;
create table t1 ( min_num   dec(6,6)     default .000001);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `min_num` decimal(6,6) DEFAULT '0.000001'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1 ;
set @@SQL_MODE=NULL;
ERROR 42000: Variable 'sql_mode' can't be set to the value of 'NULL'
set session sql_mode=ansi;
create table t1
(f1 integer auto_increment primary key,
f2 timestamp not null default current_timestamp on update current_timestamp);
show create table t1;
Table	Create Table
t1	CREATE TABLE "t1" (
  "f1" int(11) NOT NULL AUTO_INCREMENT,
  "f2" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY ("f1")
)
set session sql_mode=no_field_options;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `f1` int(11) NOT NULL,
  `f2` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`f1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='';
show local variables like 'SQL_MODE';
Variable_name	Value
sql_mode	
CREATE TABLE t1 (p int not null auto_increment, a varchar(20), primary key(p));
INSERT t1 (a) VALUES 
('\\'),
('\n'),
('\b'),
('\r'),
('\t'),
('\x'),
('\a'),
('\aa'),
('\\a'),
('\\aa'),
('_'),
('\_'),
('\\_'),
('\\\_'),
('\\\\_'),
('%'),
('\%'),
('\\%'),
('\\\%'),
('\\\\%')
;
SELECT p, hex(a) FROM t1;
p	hex(a)
1	5C
2	0A
3	08
4	0D
5	09
6	78
7	61
8	6161
9	5C61
10	5C6161
11	5F
12	5C5F
13	5C5F
14	5C5C5F
15	5C5C5F
16	25
17	5C25
18	5C25
19	5C5C25
20	5C5C25
delete from t1 where a in ('\n','\r','\t', '\b');
select
masks.p,
masks.a as mask,
examples.a as example
from
t1 as masks
left join t1 as examples on examples.a LIKE masks.a
order by masks.p, example;
p	mask	example
1	\	\
6	x	x
7	a	a
8	aa	aa
9	\a	a
10	\aa	aa
11	_	%
11	_	a
11	_	x
11	_	\
11	_	_
12	\_	_
13	\_	_
14	\\_	\%
14	\\_	\%
14	\\_	\a
14	\\_	\_
14	\\_	\_
15	\\_	\%
15	\\_	\%
15	\\_	\a
15	\\_	\_
15	\\_	\_
16	%	%
16	%	a
16	%	aa
16	%	x
16	%	\
16	%	\%
16	%	\%
16	%	\a
16	%	\aa
16	%	\\%
16	%	\\%
16	%	\\_
16	%	\\_
16	%	\_
16	%	\_
16	%	_
17	\%	%
18	\%	%
19	\\%	\
19	\\%	\%
19	\\%	\%
19	\\%	\a
19	\\%	\aa
19	\\%	\\%
19	\\%	\\%
19	\\%	\\_
19	\\%	\\_
19	\\%	\_
19	\\%	\_
20	\\%	\
20	\\%	\%
20	\\%	\%
20	\\%	\a
20	\\%	\aa
20	\\%	\\%
20	\\%	\\%
20	\\%	\\_
20	\\%	\\_
20	\\%	\_
20	\\%	\_
DROP TABLE t1;
SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
show local variables like 'SQL_MODE';
Variable_name	Value
sql_mode	NO_BACKSLASH_ESCAPES
CREATE TABLE t1 (p int not null auto_increment, a varchar(20), primary key(p));
INSERT t1 (a) VALUES 
('\\'),
('\n'),
('\b'),
('\r'),
('\t'),
('\x'),
('\a'),
('\aa'),
('\\a'),
('\\aa'),
('_'),
('\_'),
('\\_'),
('\\\_'),
('\\\\_'),
('%'),
('\%'),
('\\%'),
('\\\%'),
('\\\\%')
;
SELECT p, hex(a) FROM t1;
p	hex(a)
1	5C5C
2	5C6E
3	5C62
4	5C72
5	5C74
6	5C78
7	5C61
8	5C6161
9	5C5C61
10	5C5C6161
11	5F
12	5C5F
13	5C5C5F
14	5C5C5C5F
15	5C5C5C5C5F
16	25
17	5C25
18	5C5C25
19	5C5C5C25
20	5C5C5C5C25
delete from t1 where a in ('\n','\r','\t', '\b');
select 
masks.p,
masks.a as mask,
examples.a as example
from
t1 as masks
left join t1 as examples on examples.a LIKE masks.a
order by masks.p, example;
p	mask	example
1	\\	\\
6	\x	\x
7	\a	\a
8	\aa	\aa
9	\\a	\\a
10	\\aa	\\aa
11	_	%
11	_	_
12	\_	\%
12	\_	\a
12	\_	\x
12	\_	\\
12	\_	\_
13	\\_	\\%
13	\\_	\\a
13	\\_	\\_
14	\\\_	\\\%
14	\\\_	\\\_
15	\\\\_	\\\\%
15	\\\\_	\\\\_
16	%	%
16	%	\%
16	%	\a
16	%	\aa
16	%	\x
16	%	\\
16	%	\\%
16	%	\\a
16	%	\\aa
16	%	\\\%
16	%	\\\\%
16	%	\\\\_
16	%	\\\_
16	%	\\_
16	%	\_
16	%	_
17	\%	\%
17	\%	\a
17	\%	\aa
17	\%	\x
17	\%	\\
17	\%	\\%
17	\%	\\a
17	\%	\\aa
17	\%	\\\%
17	\%	\\\\%
17	\%	\\\\_
17	\%	\\\_
17	\%	\\_
17	\%	\_
18	\\%	\\
18	\\%	\\%
18	\\%	\\a
18	\\%	\\aa
18	\\%	\\\%
18	\\%	\\\\%
18	\\%	\\\\_
18	\\%	\\\_
18	\\%	\\_
19	\\\%	\\\%
19	\\\%	\\\\%
19	\\\%	\\\\_
19	\\\%	\\\_
20	\\\\%	\\\\%
20	\\\\%	\\\\_
DROP TABLE t1;
SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b';
a\\b	a\\\"b	a'\\b	a'\\\"b
a\\b	a\\\"b	a'\\b	a'\\\"b
SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";
a\\b	a\\\'b	a"\\b	a"\\\'b
a\\b	a\\\'b	a"\\b	a"\\\'b
SET @@SQL_MODE='';
SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b';
a\b	a\"b	a'\b	a'\"b
a\b	a\"b	a'\b	a'\"b
SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";
a\b	a\'b	a"\b	a"\'b
a\b	a\'b	a"\b	a"\'b
SET @@SQL_MODE='';
create function `foo` () returns int return 5;
show create function `foo`;
Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
foo		CREATE DEFINER=`root`@`localhost` FUNCTION `foo`() RETURNS int(11)
return 5	latin1	latin1_swedish_ci	latin1_swedish_ci
SET @@SQL_MODE='ANSI_QUOTES';
show create function `foo`;
Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
foo		CREATE DEFINER=`root`@`localhost` FUNCTION `foo`() RETURNS int(11)
return 5	latin1	latin1_swedish_ci	latin1_swedish_ci
drop function `foo`;
create function `foo` () returns int return 5;
show create function `foo`;
Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
foo	ANSI_QUOTES	CREATE DEFINER="root"@"localhost" FUNCTION "foo"() RETURNS int(11)
return 5	latin1	latin1_swedish_ci	latin1_swedish_ci
SET @@SQL_MODE='';
show create function `foo`;
Function	sql_mode	Create Function	character_set_client	collation_connection	Database Collation
foo	ANSI_QUOTES	CREATE DEFINER="root"@"localhost" FUNCTION "foo"() RETURNS int(11)
return 5	latin1	latin1_swedish_ci	latin1_swedish_ci
drop function `foo`;
SET @@SQL_MODE='';
create table t1 (a int);
create table t2 (a int);
create view v1 as select a from t1;
show create view v1;
View	Create View	character_set_client	collation_connection
v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1`	latin1	latin1_swedish_ci
SET @@SQL_MODE='ANSI_QUOTES';
show create view v1;
View	Create View	character_set_client	collation_connection
v1	CREATE ALGORITHM=UNDEFINED DEFINER="root"@"localhost" SQL SECURITY DEFINER VIEW "v1" AS select "t1"."a" AS "a" from "t1"	latin1	latin1_swedish_ci
create view v2 as select a from t2 where a in (select a from v1);
drop view v2, v1;
drop table t1, t2;
select @@sql_mode;
@@sql_mode
ANSI_QUOTES
set sql_mode=2097152;
select @@sql_mode;
@@sql_mode
STRICT_TRANS_TABLES
set sql_mode=4194304;
select @@sql_mode;
@@sql_mode
STRICT_ALL_TABLES
set sql_mode=16384+(65536*4);
select @@sql_mode;
@@sql_mode
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_TABLE_OPTIONS,ANSI
set sql_mode=2147483648*2;
ERROR 42000: Variable 'sql_mode' can't be set to the value of '4294967296'
select @@sql_mode;
@@sql_mode
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_TABLE_OPTIONS,ANSI
set sql_mode=PAD_CHAR_TO_FULL_LENGTH;
create table t1 (a int auto_increment primary key, b char(5));
insert into t1 (b) values('a'),('b\t'),('c ');
select concat('x',b,'x') from t1;
concat('x',b,'x')
xa    x
xb	   x
xc    x
set sql_mode=0;
select concat('x',b,'x') from t1;
concat('x',b,'x')
xax
xb	x
xcx
drop table t1;
SET @@SQL_MODE=@OLD_SQL_MODE;
create user mysqltest_32753@localhost;
set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
set session sql_mode='PAD_CHAR_TO_FULL_LENGTH';
flush privileges;
select current_user();
current_user()
mysqltest_32753@localhost
set session sql_mode=@OLD_SQL_MODE;
flush privileges;
drop user mysqltest_32753@localhost;
SET @org_mode=@@sql_mode;
SET @@sql_mode='traditional';
SELECT @@sql_mode LIKE '%NO_ENGINE_SUBSTITUTION%';
@@sql_mode LIKE '%NO_ENGINE_SUBSTITUTION%'
1
SET sql_mode=@org_mode;
DROP TABLE IF EXISTS t1,t2;
CREATE USER 'user_PCTFL'@'localhost' identified by 'PWD';
CREATE USER 'user_no_PCTFL'@'localhost' identified by 'PWD';
CREATE TABLE t1 (f1 BIGINT);
CREATE TABLE t2 (f1 CHAR(3) NOT NULL, f2 CHAR(20));
GRANT ALL ON t1 TO 'user_PCTFL'@'localhost','user_no_PCTFL'@'localhost';
GRANT SELECT(f1) ON t2 TO 'user_PCTFL'@'localhost','user_no_PCTFL'@'localhost';
SET @OLD_SQL_MODE = @@SESSION.SQL_MODE;
SET SESSION SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH';
DROP USER 'user_PCTFL'@'localhost';
SET SESSION SQL_MODE = @OLD_SQL_MODE;
DROP USER 'user_no_PCTFL'@'localhost';
FLUSH PRIVILEGES;
SELECT * FROM mysql.db WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL';
Host	Db	User	Select_priv	Insert_priv	Update_priv	Delete_priv	Create_priv	Drop_priv	Grant_priv	References_priv	Index_priv	Alter_priv	Create_tmp_table_priv	Lock_tables_priv	Create_view_priv	Show_view_priv	Create_routine_priv	Alter_routine_priv	Execute_priv	Event_priv	Trigger_priv
SELECT * FROM mysql.tables_priv WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL';
Host	Db	User	Table_name	Grantor	Timestamp	Table_priv	Column_priv
SELECT * FROM mysql.columns_priv WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL';
Host	Db	User	Table_name	Column_name	Timestamp	Column_priv
DROP TABLE t1;
DROP TABLE t2;

#
# Test for Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES
# IGNORED AND BREAKS REPLICATION
#
DROP TABLE IF EXISTS test_table;
DROP FUNCTION IF EXISTS test_function;
CREATE TABLE test_table (c1 CHAR(50));
SET @org_mode=@@sql_mode;
SET @@sql_mode='';
PREPARE insert_stmt FROM 'INSERT INTO test_table VALUES (?)';
PREPARE update_stmt FROM 'UPDATE test_table SET c1= ? WHERE c1= ?';
CREATE FUNCTION test_function(var CHAR(50)) RETURNS CHAR(50)
BEGIN
DECLARE char_val CHAR(50);
SELECT c1 INTO char_val FROM test_table WHERE c1=var;
RETURN char_val;
END
$
SET @var1='abcd\'ef';
SET @var2='abcd\"ef';
SET @var3='abcd\bef';
SET @var4='abcd\nef';
SET @var5='abcd\ref';
SET @var6='abcd\tef';
SET @var7='abcd\\ef';
SET @var8='abcd\%ef';
SET @var9='abcd\_ef';
SET @to_var1='wxyz\'ef';
SET @to_var2='wxyz\"ef';
SET @to_var3='wxyz\bef';
SET @to_var4='wxyz\nef';
SET @to_var5='wxyz\ref';
SET @to_var6='wxyz\tef';
SET @to_var7='wxyz\\ef';
SET @to_var8='wxyz\%ef';
SET @to_var9='wxyz\_ef';
# STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
EXECUTE insert_stmt USING @var1;
EXECUTE insert_stmt USING @var2;
EXECUTE insert_stmt USING @var3;
EXECUTE insert_stmt USING @var4;
EXECUTE insert_stmt USING @var5;
EXECUTE insert_stmt USING @var6;
EXECUTE insert_stmt USING @var7;
EXECUTE insert_stmt USING @var8;
EXECUTE insert_stmt USING @var9;
SELECT * FROM test_table;
c1
abcd'ef
abcd"ef
abcdef
abcd
ef
abcd
ef
abcd	ef
abcd\ef
abcd\%ef
abcd\_ef
EXECUTE update_stmt USING @to_var1, @var1;
EXECUTE update_stmt USING @to_var2, @var2;
EXECUTE update_stmt USING @to_var3, @var3;
EXECUTE update_stmt USING @to_var4, @var4;
EXECUTE update_stmt USING @to_var5, @var5;
EXECUTE update_stmt USING @to_var6, @var6;
EXECUTE update_stmt USING @to_var7, @var7;
EXECUTE update_stmt USING @to_var8, @var8;
EXECUTE update_stmt USING @to_var9, @var9;
SELECT * FROM test_table;
c1
wxyz'ef
wxyz"ef
wxyzef
wxyz
ef
wxyz
ef
wxyz	ef
wxyz\ef
wxyz\%ef
wxyz\_ef

# END OF CASE - STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
# STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
select test_function(@to_var1);
test_function(@to_var1)
wxyz'ef
SELECT test_function(@to_var2);
test_function(@to_var2)
wxyz"ef
SELECT test_function(@to_var3);
test_function(@to_var3)
wxyzef
SELECT test_function(@to_var4);
test_function(@to_var4)
wxyz
ef
SELECT test_function(@to_var5);
test_function(@to_var5)
wxyz
ef
SELECT test_function(@to_var6);
test_function(@to_var6)
wxyz	ef
SELECT test_function(@to_var7);
test_function(@to_var7)
wxyz\ef
SELECT test_function(@to_var8);
test_function(@to_var8)
wxyz\%ef
SELECT test_function(@to_var9);
test_function(@to_var9)
wxyz\_ef

# END OF CASE - STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
DELETE FROM test_table;
DROP FUNCTION test_function;
SET @@sql_mode='NO_BACKSLASH_ESCAPES';
CREATE FUNCTION test_function(var CHAR(50)) RETURNS CHAR(50)
BEGIN
DECLARE char_val CHAR(50);
SELECT c1 INTO char_val FROM test_table WHERE c1=var;
RETURN char_val;
END
$
# STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
EXECUTE insert_stmt USING @var1;
EXECUTE insert_stmt USING @var2;
EXECUTE insert_stmt USING @var3;
EXECUTE insert_stmt USING @var4;
EXECUTE insert_stmt USING @var5;
EXECUTE insert_stmt USING @var6;
EXECUTE insert_stmt USING @var7;
EXECUTE insert_stmt USING @var8;
EXECUTE insert_stmt USING @var9;
SELECT * FROM test_table;
c1
abcd'ef
abcd"ef
abcdef
abcd
ef
abcd
ef
abcd	ef
abcd\ef
abcd\%ef
abcd\_ef
EXECUTE update_stmt USING @to_var1, @var1;
EXECUTE update_stmt USING @to_var2, @var2;
EXECUTE update_stmt USING @to_var3, @var3;
EXECUTE update_stmt USING @to_var4, @var4;
EXECUTE update_stmt USING @to_var5, @var5;
EXECUTE update_stmt USING @to_var6, @var6;
EXECUTE update_stmt USING @to_var7, @var7;
EXECUTE update_stmt USING @to_var8, @var8;
EXECUTE update_stmt USING @to_var9, @var9;
SELECT * FROM test_table;
c1
wxyz'ef
wxyz"ef
wxyzef
wxyz
ef
wxyz
ef
wxyz	ef
wxyz\ef
wxyz\%ef
wxyz\_ef

# END OF CASE - STRING LILTERAL WITH BACKSLASH IN PREPARE STATEMENT
# STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
select test_function(@to_var1);
test_function(@to_var1)
wxyz'ef
SELECT test_function(@to_var2);
test_function(@to_var2)
wxyz"ef
SELECT test_function(@to_var3);
test_function(@to_var3)
wxyzef
SELECT test_function(@to_var4);
test_function(@to_var4)
wxyz
ef
SELECT test_function(@to_var5);
test_function(@to_var5)
wxyz
ef
SELECT test_function(@to_var6);
test_function(@to_var6)
wxyz	ef
SELECT test_function(@to_var7);
test_function(@to_var7)
wxyz\ef
SELECT test_function(@to_var8);
test_function(@to_var8)
wxyz\%ef
SELECT test_function(@to_var9);
test_function(@to_var9)
wxyz\_ef

# END OF CASE - STRING LILTERAL WITH BACKSLASH IN FUNCTION RETURNING STRING
DROP TABLE test_table;
DROP FUNCTION test_function;
SET @@sql_mode= @org_mode;

#End of Test for Bug#12601974