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
|
# transaction_log_update
# test of various REPLACE statements and
# how the transaction_log captures the relevant data
# Ignore startup/shutdown events
--disable_query_log
--source ../plugin/transaction_log/tests/t/truncate_log.inc
--enable_query_log
--echo Testing REPLACE basic
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
INSERT INTO t1 (b) VALUES (10),(20),(30),(40),(50),(60);
REPLACE INTO t1 VALUES (1,100),(3,300);
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
--echo
DROP TABLE t1;
# Truncate the log file to reset for the next test
--source ../plugin/transaction_log/tests/t/truncate_log.inc
--echo
--echo Testing REPLACE SET
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, c CHAR(100), PRIMARY KEY(a));
INSERT INTO t1 (b,c) VALUES (10,'a'),(20,'b'),(30,'c'),(40,'d'),(50,'e'),(60,'f');
REPLACE INTO t1 SET a=1,b=42,c='I have been replaced' ;
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
--echo
DROP TABLE t1;
# Truncate the log file to reset for the next test
--source ../plugin/transaction_log/tests/t/truncate_log.inc
--echo
--echo Testing REPLACE...SELECT
--disable_warnings
DROP TABLE IF EXISTS t1, t2 ;
--enable_warnings
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, c CHAR(100), d CHAR(20), PRIMARY KEY(a));
INSERT INTO t1 (b,c,d) VALUES (10,'a','f'),(20,'b','e'),(30,'c','d'),(40,'d','c'),(50,'e','b'),(60,'f','a');
CREATE TABLE t2 LIKE t1;
INSERT INTO t2 SELECT a, b*20, CONCAT(c,'replace'), CONCAT(d, 'replace_too') FROM t1;
REPLACE INTO t1 SELECT * FROM t2;
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
--echo
DROP TABLE t1, t2;
# Truncate the log file to reset for the next test
--source ../plugin/transaction_log/tests/t/truncate_log.inc
--echo
--echo Testing multi-row REPLACE
--disable_warnings
DROP TABLE IF EXISTS t1 ;
--enable_warnings
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, c CHAR(100), d CHAR(20), PRIMARY KEY(a), UNIQUE KEY(b), UNIQUE KEY(c));
INSERT INTO t1 (b,c,d) VALUES (10,'a','f'),(20,'b','e'),(30,'c','d'),(40,'d','c'),(50,'e','b'),(60,'f','a');
SELECT * FROM t1;
REPLACE INTO t1 VALUES (1, 20, 'd','x');
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
--echo
SELECT * FROM t1;
DROP TABLE t1;
# Truncate the log file to reset for the next test
--source ../plugin/transaction_log/tests/t/truncate_log.inc
--echo
|