2
# Test of auto_increment in CRBR
4
#####################################
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
13
--echo ***************** Test 1 ************************
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 *************
19
select * from t1 ORDER BY a;
22
sync_slave_with_master;
23
--echo ******* Select from Slave *************
25
select * from t1 ORDER BY a;
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 *************
35
select * from t1 ORDER BY a;
37
sync_slave_with_master;
38
--echo ******* Select from Slave *************
40
select * from t1 ORDER BY a;
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 *************
51
select * from t1 ORDER BY a;
52
insert into t1 values (1000);
54
insert into t1 values(NULL),(NULL);
55
--echo ******* Select from Master *************
57
select * from t1 ORDER BY a;
59
sync_slave_with_master;
60
--echo ******* Select from Slave *************
62
select * from t1 ORDER BY a;
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 *************
72
select * from t1 ORDER BY a;
74
# We expect a duplicate key error that we will ignore below
76
insert into t1 values(600),(NULL),(NULL);
78
insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL);
79
--echo ******* Select from Master *************
81
select * from t1 ORDER BY a;
83
sync_slave_with_master;
84
--echo ******* Select from Slave *************
86
select * from t1 ORDER BY a;
91
# Test that auto-increment works when slave has rows in the table
94
create table t1 (a int not null auto_increment, primary key (a)) engine=NDB;
96
sync_slave_with_master;
97
insert into t1 values(2),(12),(22),(32),(42);
100
insert into t1 values (NULL),(NULL);
101
insert into t1 values (3),(NULL),(NULL);
102
--echo ******* Select from Master *************
104
select * from t1 ORDER BY a;
106
sync_slave_with_master;
107
--echo ******* Select from Slave *************
109
--echo ** Slave should have 2, 12, 22, 32, 42 **
110
--echo ** Master will have 2 but not 12, 22, 32, 42 **
112
select * from t1 ORDER BY a;
118
sync_slave_with_master;