1
-- source include/have_ndb.inc
2
-- source include/not_embedded.inc
5
# Test of REPLACE with NDB
9
drop table if exists t1,t2;
13
gesuchnr int(11) DEFAULT '0' NOT NULL,
14
benutzer_id int(11) DEFAULT '0' NOT NULL,
15
PRIMARY KEY (gesuchnr,benutzer_id)
18
replace into t1 (gesuchnr,benutzer_id) values (2,1);
19
replace into t1 (gesuchnr,benutzer_id) values (1,1);
20
replace into t1 (gesuchnr,benutzer_id) values (1,1);
21
insert into t1 (gesuchnr, benutzer_id) value (3,2);
22
replace into t1 (gesuchnr,benutzer_id) values (1,1);
23
replace into t1 (gesuchnr,benutzer_id) values (1,1);
25
insert into t1 (gesuchnr,benutzer_id) values (1,1);
26
replace into t1 (gesuchnr,benutzer_id) values (1,1);
27
select * from t1 order by gesuchnr;
33
CREATE TABLE t1(i INT PRIMARY KEY AUTO_INCREMENT,
38
INSERT INTO t1 VALUES (1,1,23),(2,2,24);
39
REPLACE INTO t1 (j,k) VALUES (1,42);
40
REPLACE INTO t1 (i,j) VALUES (17,2);
41
SELECT * from t1 ORDER BY i;
45
CREATE TABLE t2 (a INT(11) NOT NULL,
51
id INT(10) unsigned NOT NULL AUTO_INCREMENT,
52
i INT(11) DEFAULT NULL,
57
REPLACE INTO t2 (a,b,c,x,y,z,i) VALUES (1,1,1,'a','a','a',1),(1,1,1,'b','b','b',2), (1,1,1,'c','c','c',3);
59
SELECT * FROM t2 ORDER BY id;
61
REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'a','a','a',1);
62
REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'b','b','b',2);
64
SELECT * FROM t2 ORDER BY id;
69
# Bug #20728 "REPLACE does not work correctly for NDB table with PK and
73
drop table if exists t1;
75
create table t1 (pk int primary key, apk int unique, data int) engine=ndbcluster;
76
# Test for plain replace which updates pk
77
insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3);
78
replace into t1 (pk, apk) values (4, 1), (5, 2);
79
select * from t1 order by pk;
81
# Another test for plain replace which doesn't touch pk
82
insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3);
83
replace into t1 (pk, apk) values (1, 4), (2, 5);
84
select * from t1 order by pk;
86
# Test for load data replace which updates pk
87
insert into t1 values (1, 1, 1), (4, 4, 4), (6, 6, 6);
88
load data infile '../../../std_data/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk);
89
select * from t1 order by pk;
91
# Now test for load data replace which doesn't touch pk
92
insert into t1 values (1, 1, 1), (3, 3, 3), (5, 5, 5);
93
load data infile '../../../std_data/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk);
94
select * from t1 order by pk;
96
# Finally test for both types of replace ... select
97
insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3);
98
replace into t1 (pk, apk) select 4, 1;
99
replace into t1 (pk, apk) select 2, 4;
100
select * from t1 order by pk;
104
--echo End of 5.0 tests.