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

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl_ndb/t/rpl_ndb_auto_inc.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
#
 
2
# Test of auto_increment in CRBR
 
3
#
 
4
#####################################
 
5
# By: JBM
 
6
# Date: 2006-02-10
 
7
# Change: Augmented test to use with cluster
 
8
#####################################
 
9
--source include/have_ndb.inc
 
10
--source include/have_binlog_format_mixed_or_row.inc
 
11
--source include/ndb_master-slave.inc
 
12
 
 
13
--echo ***************** Test 1 ************************
 
14
--echo
 
15
CREATE TABLE t1 (a INT NOT NULL auto_increment,b INT, PRIMARY KEY (a)) ENGINE=NDB auto_increment=3;
 
16
insert into t1 values (NULL,1),(NULL,2),(NULL,3);
 
17
--echo ******* Select from Master *************
 
18
--echo
 
19
select * from t1 ORDER BY a;
 
20
 
 
21
 
 
22
sync_slave_with_master;
 
23
--echo ******* Select from Slave *************
 
24
--echo
 
25
select * from t1 ORDER BY a;
 
26
connection master;
 
27
drop table t1;
 
28
 
 
29
create table t1 (a int not null auto_increment,b int, primary key (a)) engine=NDB;
 
30
insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4);
 
31
delete from t1 where b=4;
 
32
insert into t1 values (NULL,5),(NULL,6);
 
33
--echo ******* Select from Master *************
 
34
--echo
 
35
select * from t1 ORDER BY a;
 
36
 
 
37
sync_slave_with_master;
 
38
--echo ******* Select from Slave *************
 
39
--echo
 
40
select * from t1 ORDER BY a;
 
41
connection master;
 
42
 
 
43
drop table t1;
 
44
 
 
45
create table t1 (a int not null auto_increment, primary key (a)) engine=NDB;
 
46
# Insert with 2 insert statements to get better testing of logging
 
47
insert into t1 values (NULL),(5),(NULL);
 
48
insert into t1 values (250),(NULL);
 
49
--echo ******* Select from Master *************
 
50
--echo
 
51
select * from t1 ORDER BY a;
 
52
insert into t1 values (1000);
 
53
set @@insert_id=400;
 
54
insert into t1 values(NULL),(NULL);
 
55
--echo ******* Select from Master *************
 
56
--echo
 
57
select * from t1 ORDER BY a;
 
58
 
 
59
sync_slave_with_master;
 
60
--echo ******* Select from Slave *************
 
61
--echo
 
62
select * from t1 ORDER BY a;
 
63
connection master;
 
64
drop table t1;
 
65
 
 
66
create table t1 (a int not null auto_increment, primary key (a)) engine=NDB;
 
67
# Insert with 2 insert statements to get better testing of logging
 
68
insert into t1 values (NULL),(5),(NULL),(NULL);
 
69
insert into t1 values (500),(NULL),(502),(NULL),(600);
 
70
--echo ******* Select from Master *************
 
71
--echo
 
72
select * from t1 ORDER BY a;
 
73
set @@insert_id=600;
 
74
# We expect a duplicate key error that we will ignore below
 
75
--error 1022
 
76
insert into t1 values(600),(NULL),(NULL);
 
77
set @@insert_id=600;
 
78
insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL);
 
79
--echo ******* Select from Master *************
 
80
--echo
 
81
select * from t1 ORDER BY a;
 
82
 
 
83
sync_slave_with_master;
 
84
--echo ******* Select from Slave *************
 
85
--echo
 
86
select * from t1 ORDER BY a;
 
87
connection master;
 
88
drop table t1;
 
89
 
 
90
#
 
91
# Test that auto-increment works when slave has rows in the table
 
92
#
 
93
 
 
94
create table t1 (a int not null auto_increment, primary key (a)) engine=NDB;
 
95
 
 
96
sync_slave_with_master;
 
97
insert into t1 values(2),(12),(22),(32),(42);
 
98
connection master;
 
99
 
 
100
insert into t1 values (NULL),(NULL);
 
101
insert into t1 values (3),(NULL),(NULL);
 
102
--echo ******* Select from Master *************
 
103
--echo
 
104
select * from t1 ORDER BY a;
 
105
 
 
106
sync_slave_with_master;
 
107
--echo ******* Select from Slave *************
 
108
--echo
 
109
--echo ** Slave should have 2, 12, 22, 32, 42 **
 
110
--echo ** Master will have 2 but not 12, 22, 32, 42 **
 
111
--echo
 
112
select * from t1 ORDER BY a;
 
113
connection master;
 
114
 
 
115
drop table t1;
 
116
 
 
117
# End cleanup
 
118
sync_slave_with_master;