~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/ndb/t/ndb_replace.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- source include/have_ndb.inc
 
2
-- source include/not_embedded.inc
 
3
 
 
4
#
 
5
# Test of REPLACE with NDB
 
6
#
 
7
 
 
8
--disable_warnings
 
9
drop table if exists t1,t2;
 
10
--enable_warnings
 
11
 
 
12
CREATE TABLE t1 (
 
13
  gesuchnr int(11) DEFAULT '0' NOT NULL,
 
14
  benutzer_id int(11) DEFAULT '0' NOT NULL,
 
15
  PRIMARY KEY (gesuchnr,benutzer_id)
 
16
) engine=ndbcluster;
 
17
 
 
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);
 
24
--error ER_DUP_ENTRY
 
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;
 
28
drop table t1;
 
29
 
 
30
# End of 4.1 tests
 
31
 
 
32
# bug#17431
 
33
CREATE TABLE t1(i INT PRIMARY KEY AUTO_INCREMENT, 
 
34
                j INT, 
 
35
                k INT, 
 
36
                UNIQUE INDEX(j)
 
37
               ) ENGINE = ndb;
 
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;
 
42
DROP TABLE t1;
 
43
 
 
44
# bug#19906
 
45
CREATE TABLE t2 (a INT(11) NOT NULL,
 
46
                 b INT(11) NOT NULL,
 
47
                 c INT(11) NOT NULL,
 
48
                 x TEXT,
 
49
                 y TEXT,
 
50
                 z TEXT,
 
51
                 id INT(10) unsigned NOT NULL AUTO_INCREMENT,
 
52
                 i INT(11) DEFAULT NULL,
 
53
                 PRIMARY KEY (id),
 
54
                 UNIQUE KEY a (a,b,c)
 
55
) ENGINE=ndbcluster;
 
56
 
 
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);
 
58
 
 
59
SELECT * FROM t2 ORDER BY id;
 
60
 
 
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);
 
63
 
 
64
SELECT * FROM t2 ORDER BY id;
 
65
 
 
66
DROP TABLE t2;
 
67
 
 
68
#
 
69
# Bug #20728 "REPLACE does not work correctly for NDB table with PK and
 
70
#             unique index"
 
71
#
 
72
--disable_warnings
 
73
drop table if exists t1;
 
74
--enable_warnings
 
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;
 
80
delete from t1;
 
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;
 
85
delete from t1;
 
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;
 
90
delete from t1;
 
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;
 
95
delete from t1;
 
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;
 
101
# Clean-up
 
102
drop table t1;
 
103
 
 
104
--echo End of 5.0 tests.