| 1 |
SET @old_sql_mode= @@global.sql_mode; |
| 2 |
SET @old_binlog_format=@@session.binlog_format; |
| 3 |
Warnings: |
| 4 |
Warning 1287 '@@binlog_format' is deprecated and will be removed in a future release. |
| 5 |
SET SESSION sql_mode=8; |
| 6 |
Initialization |
| 7 |
RESET MASTER; |
| 8 |
CREATE TABLE t1 (id INT); |
| 9 |
CREATE PROCEDURE testProc() SELECT * FROM t1; |
| 10 |
CREATE VIEW testView as SELECT * from t1; |
| 11 |
CREATE FUNCTION testFunc() |
| 12 |
RETURNS INT |
| 13 |
BEGIN |
| 14 |
return 1; |
| 15 |
END;| |
| 16 |
CREATE TRIGGER testTrig BEFORE INSERT ON t1 |
| 17 |
FOR EACH ROW BEGIN |
| 18 |
UPDATE t1 SET id = id +1; |
| 19 |
END;| |
| 20 |
CREATE EVENT testEvent ON SCHEDULE |
| 21 |
EVERY 1 DAY |
| 22 |
DO |
| 23 |
BEGIN |
| 24 |
UPDATE t1 SET id = id +1; |
| 25 |
END;| |
| 26 |
Check Result |
| 27 |
select |
| 28 |
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog")) |
| 29 |
is not null AS Loaded; |
| 30 |
Loaded |
| 31 |
1 |
| 32 |
Warnings: |
| 33 |
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. |
| 34 |
*** String sql_mode=0 is found: 0 *** |
| 35 |
Clean Up |
| 36 |
DROP PROCEDURE testProc; |
| 37 |
DROP FUNCTION testFunc; |
| 38 |
DROP TRIGGER testTrig; |
| 39 |
DROP EVENT testEvent; |
| 40 |
DROP VIEW testView; |
| 41 |
DROP TABLE t1; |
| 42 |
SET @@global.sql_mode= @old_sql_mode; |
| 43 |
SET @@session.binlog_format=@old_binlog_format; |
| 44 |
Warnings: |
| 45 |
Warning 1287 '@@binlog_format' is deprecated and will be removed in a future release. |
| 46 |
|
| 47 |
# |
| 48 |
# Test for Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES |
| 49 |
# IGNORED AND BREAKS REPLICATION |
| 50 |
# |
| 51 |
DROP DATABASE IF EXISTS mysqltest_db; |
| 52 |
DROP TABLE IF EXISTS test_table; |
| 53 |
CREATE DATABASE mysqltest_db; |
| 54 |
USE mysqltest_db; |
| 55 |
CREATE TABLE test_table (c1 CHAR(50)); |
| 56 |
SET @org_mode=@@sql_mode; |
| 57 |
SET @@sql_mode=''; |
| 58 |
CREATE PROCEDURE proc_without_sql_mode (IN param1 CHAR(50), IN param2 CHAR(50)) |
| 59 |
BEGIN |
| 60 |
DECLARE var1 CHAR(50) DEFAULT param1; |
| 61 |
DECLARE var2 CHAR(50) DEFAULT param2; |
| 62 |
DECLARE var3 CHAR(50) DEFAULT 'abcd\bef'; |
| 63 |
DECLARE var4 CHAR(50) DEFAULT 'abcd\nef'; |
| 64 |
DECLARE var5 CHAR(50) DEFAULT 'abcd\ref'; |
| 65 |
DECLARE var6 CHAR(50) DEFAULT 'abcd\tef'; |
| 66 |
DECLARE var7 CHAR(50) DEFAULT 'abcd\\ef'; |
| 67 |
DECLARE var8 CHAR(50) DEFAULT 'abcd\%ef'; |
| 68 |
DECLARE var9 CHAR(50) DEFAULT 'abcd\_ef'; |
| 69 |
INSERT INTO test_table VALUES (var1); |
| 70 |
INSERT INTO test_table VALUES (var2); |
| 71 |
INSERT INTO test_table VALUES (var3); |
| 72 |
INSERT INTO test_table VALUES (var4); |
| 73 |
INSERT INTO test_table VALUES (var5); |
| 74 |
INSERT INTO test_table VALUES (var6); |
| 75 |
INSERT INTO test_table VALUES (var7); |
| 76 |
INSERT INTO test_table VALUES (var8); |
| 77 |
INSERT INTO test_table VALUES (var9); |
| 78 |
END |
| 79 |
$ |
| 80 |
SET @@sql_mode='NO_BACKSLASH_ESCAPES'$ |
| 81 |
CREATE PROCEDURE proc_with_sql_mode (IN param1 CHAR(50), IN param2 CHAR(50)) |
| 82 |
BEGIN |
| 83 |
DECLARE var1 CHAR(50) DEFAULT param1; |
| 84 |
DECLARE var2 CHAR(50) DEFAULT param2; |
| 85 |
DECLARE var3 CHAR(50) DEFAULT 'wxyz\bef'; |
| 86 |
DECLARE var4 CHAR(50) DEFAULT 'wxyz\nef'; |
| 87 |
DECLARE var5 CHAR(50) DEFAULT 'wxyz\ref'; |
| 88 |
DECLARE var6 CHAR(50) DEFAULT 'wxyz\tef'; |
| 89 |
DECLARE var7 CHAR(50) DEFAULT 'wxyz\\ef'; |
| 90 |
DECLARE var8 CHAR(50) DEFAULT 'wxyz\%ef'; |
| 91 |
DECLARE var9 CHAR(50) DEFAULT 'wxyz\_ef'; |
| 92 |
INSERT INTO test_table VALUES (var1); |
| 93 |
INSERT INTO test_table VALUES (var2); |
| 94 |
INSERT INTO test_table VALUES (var3); |
| 95 |
INSERT INTO test_table VALUES (var4); |
| 96 |
INSERT INTO test_table VALUES (var5); |
| 97 |
INSERT INTO test_table VALUES (var6); |
| 98 |
INSERT INTO test_table VALUES (var7); |
| 99 |
INSERT INTO test_table VALUES (var8); |
| 100 |
INSERT INTO test_table VALUES (var9); |
| 101 |
END |
| 102 |
$ |
| 103 |
SET @@sql_mode=''; |
| 104 |
CALL proc_without_sql_mode('abcd\'ef', 'abcd\"ef'); |
| 105 |
CALL proc_with_sql_mode('wxyz\'ef', 'wxyz\"ef'); |
| 106 |
SELECT * FROM test_table; |
| 107 |
c1 |
| 108 |
abcd'ef |
| 109 |
abcd"ef |
| 110 |
abcdef |
| 111 |
abcd |
| 112 |
ef |
| 113 |
abcd
ef |
| 114 |
abcd ef |
| 115 |
abcd\ef |
| 116 |
abcd\%ef |
| 117 |
abcd\_ef |
| 118 |
wxyz'ef |
| 119 |
wxyz"ef |
| 120 |
wxyz\bef |
| 121 |
wxyz\nef |
| 122 |
wxyz\ref |
| 123 |
wxyz\tef |
| 124 |
wxyz\\ef |
| 125 |
wxyz\%ef |
| 126 |
wxyz\_ef |
| 127 |
"Dropping table test_table" |
| 128 |
DROP TABLE test_table; |
| 129 |
RESET MASTER; |
| 130 |
#"test_table" content after replaying the binlog |
| 131 |
SELECT * FROM test_table; |
| 132 |
c1 |
| 133 |
abcd'ef |
| 134 |
abcd"ef |
| 135 |
abcdef |
| 136 |
abcd |
| 137 |
ef |
| 138 |
abcd
ef |
| 139 |
abcd ef |
| 140 |
abcd\ef |
| 141 |
abcd\%ef |
| 142 |
abcd\_ef |
| 143 |
wxyz'ef |
| 144 |
wxyz"ef |
| 145 |
wxyz\bef |
| 146 |
wxyz\nef |
| 147 |
wxyz\ref |
| 148 |
wxyz\tef |
| 149 |
wxyz\\ef |
| 150 |
wxyz\%ef |
| 151 |
wxyz\_ef |
| 152 |
#Clean up |
| 153 |
DROP DATABASE mysqltest_db; |
| 154 |
SET @@sql_mode= @org_mode; |
| 155 |
use test; |
| 156 |
RESET MASTER; |
| 157 |
|
| 158 |
#End of Test for Bug#12601974 |