blob: 167c8f5a96d79ecbe1fe4885585f3ec9416c2974 (
plain)
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
|
# ==== Purpose ====
#
# Test that sql_mode can correct restore before generating the binlog event
# when creating CREATEable objects.
#
# ==== Method ====
#
# Scan binlog file to check if the sql_mode is still set to 0 before generating binlog event
#
-- source include/have_log_bin.inc
# BUG#39526 sql_mode not retained in binary log for CREATE PROCEDURE
SET @old_sql_mode= @@global.sql_mode;
SET @old_binlog_format=@@session.binlog_format;
let $MYSQLD_DATADIR= `select @@datadir`;
SET SESSION sql_mode=8;
--echo Initialization
RESET MASTER;
CREATE TABLE t1 (id INT);
CREATE PROCEDURE testProc() SELECT * FROM t1;
CREATE VIEW testView as SELECT * from t1;
DELIMITER |;
CREATE FUNCTION testFunc()
RETURNS INT
BEGIN
return 1;
END;|
DELIMITER ;|
DELIMITER |;
CREATE TRIGGER testTrig BEFORE INSERT ON t1
FOR EACH ROW BEGIN
UPDATE t1 SET id = id +1;
END;|
DELIMITER ;|
DELIMITER |;
CREATE EVENT testEvent ON SCHEDULE
EVERY 1 DAY
DO
BEGIN
UPDATE t1 SET id = id +1;
END;|
DELIMITER ;|
--echo Check Result
let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog"))
is not null;
let $s_mode_unsigned= `select @a like "%@@session.sql_mode=0%" /* must return 0 */`;
echo *** String sql_mode=0 is found: $s_mode_unsigned ***;
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog
--echo Clean Up
DROP PROCEDURE testProc;
DROP FUNCTION testFunc;
DROP TRIGGER testTrig;
DROP EVENT testEvent;
DROP VIEW testView;
DROP TABLE t1;
SET @@global.sql_mode= @old_sql_mode;
SET @@session.binlog_format=@old_binlog_format;
--echo
--echo #
--echo # Test for Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES
--echo # IGNORED AND BREAKS REPLICATION
--echo #
--disable_warnings
DROP DATABASE IF EXISTS mysqltest_db;
DROP TABLE IF EXISTS test_table;
--enable_warnings
CREATE DATABASE mysqltest_db;
USE mysqltest_db;
CREATE TABLE test_table (c1 CHAR(50));
SET @org_mode=@@sql_mode;
SET @@sql_mode='';
DELIMITER $;
CREATE PROCEDURE proc_without_sql_mode (IN param1 CHAR(50), IN param2 CHAR(50))
BEGIN
DECLARE var1 CHAR(50) DEFAULT param1;
DECLARE var2 CHAR(50) DEFAULT param2;
DECLARE var3 CHAR(50) DEFAULT 'abcd\bef';
DECLARE var4 CHAR(50) DEFAULT 'abcd\nef';
DECLARE var5 CHAR(50) DEFAULT 'abcd\ref';
DECLARE var6 CHAR(50) DEFAULT 'abcd\tef';
DECLARE var7 CHAR(50) DEFAULT 'abcd\\ef';
DECLARE var8 CHAR(50) DEFAULT 'abcd\%ef';
DECLARE var9 CHAR(50) DEFAULT 'abcd\_ef';
INSERT INTO test_table VALUES (var1);
INSERT INTO test_table VALUES (var2);
INSERT INTO test_table VALUES (var3);
INSERT INTO test_table VALUES (var4);
INSERT INTO test_table VALUES (var5);
INSERT INTO test_table VALUES (var6);
INSERT INTO test_table VALUES (var7);
INSERT INTO test_table VALUES (var8);
INSERT INTO test_table VALUES (var9);
END
$
SET @@sql_mode='NO_BACKSLASH_ESCAPES'$
CREATE PROCEDURE proc_with_sql_mode (IN param1 CHAR(50), IN param2 CHAR(50))
BEGIN
DECLARE var1 CHAR(50) DEFAULT param1;
DECLARE var2 CHAR(50) DEFAULT param2;
DECLARE var3 CHAR(50) DEFAULT 'wxyz\bef';
DECLARE var4 CHAR(50) DEFAULT 'wxyz\nef';
DECLARE var5 CHAR(50) DEFAULT 'wxyz\ref';
DECLARE var6 CHAR(50) DEFAULT 'wxyz\tef';
DECLARE var7 CHAR(50) DEFAULT 'wxyz\\ef';
DECLARE var8 CHAR(50) DEFAULT 'wxyz\%ef';
DECLARE var9 CHAR(50) DEFAULT 'wxyz\_ef';
INSERT INTO test_table VALUES (var1);
INSERT INTO test_table VALUES (var2);
INSERT INTO test_table VALUES (var3);
INSERT INTO test_table VALUES (var4);
INSERT INTO test_table VALUES (var5);
INSERT INTO test_table VALUES (var6);
INSERT INTO test_table VALUES (var7);
INSERT INTO test_table VALUES (var8);
INSERT INTO test_table VALUES (var9);
END
$
DELIMITER ;$
SET @@sql_mode='';
CALL proc_without_sql_mode('abcd\'ef', 'abcd\"ef');
CALL proc_with_sql_mode('wxyz\'ef', 'wxyz\"ef');
SELECT * FROM test_table;
let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYSQL_BINLOG --force-if-open -d mysqltest_db $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug12601974.binlog
--echo "Dropping table test_table"
DROP TABLE test_table;
--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug12601974.binlog"
--echo #"test_table" content after replaying the binlog
SELECT * FROM test_table;
--echo #Clean up
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug12601974.binlog
DROP DATABASE mysqltest_db;
SET @@sql_mode= @org_mode;
use test;
--echo
--echo #End of Test for Bug#12601974
|