| 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 suite/ndb_rpl/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 ER_DUP_ENTRY |
| 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 |
drop table t1; |
| 115 |
|
| 116 |
# |
| 117 |
# Bug #42232 Cluster to cluster replication is not setting auto_increment |
| 118 |
# on slave cluster |
| 119 |
# |
| 120 |
set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz; |
| 121 |
set ndb_autoincrement_prefetch_sz = 32; |
| 122 |
CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT KEY) ENGINE=ndb; |
| 123 |
INSERT INTO t1 () VALUES (),(),(); |
| 124 |
sync_slave_with_master; |
| 125 |
set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz; |
| 126 |
set ndb_autoincrement_prefetch_sz = 32; |
| 127 |
select * from t1 order by id; |
| 128 |
INSERT INTO t1 () VALUES (),(),(); |
| 129 |
select * from t1 order by id; |
| 130 |
set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz; |
| 131 |
connection master; |
| 132 |
select * from t1 order by id; |
| 133 |
drop table t1; |
| 134 |
set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz; |
| 135 |
# End cleanup |
| 136 |
sync_slave_with_master; |
| 137 |
--source include/rpl_end.inc |