# test tokudb read free replication feature with partition table

--source include/have_debug.inc
--source include/have_tokudb.inc
--source include/not_group_replication_plugin.inc
--source include/have_binlog_format_row.inc
--source include/master-slave.inc

call mtr.add_suppression(".*read free replication is disabled for TokuDB/RocksDB table.*continue with rows lookup");

connection master;

# partition table with explicit PK
CREATE TABLE t1 (id int(11) NOT NULL, pid int(11), PRIMARY KEY (id)) ENGINE=TokuDB
PARTITION BY RANGE (id)
(PARTITION p_1 VALUES LESS THAN (10) ENGINE = TokuDB,
 PARTITION p_2 VALUES LESS THAN (20) ENGINE = TokuDB,
 PARTITION p_all VALUES LESS THAN MAXVALUE ENGINE = TokuDB);

insert into t1 values (1, 1), (2, 2), (3, 3), (11, 11), (12, 12), (13, 13);

# partition table without explicit PK
CREATE TABLE t2 (id int(11) NOT NULL, pid int(11), key idx_1(id)) ENGINE=TokuDB
PARTITION BY RANGE (id)
(PARTITION p_1 VALUES LESS THAN (10) ENGINE = TokuDB,
 PARTITION p_2 VALUES LESS THAN (20) ENGINE = TokuDB,
 PARTITION p_all VALUES LESS THAN MAXVALUE ENGINE = TokuDB);

insert into t2 values (1, 1), (2, 2), (3, 3), (11, 11), (12, 12), (13, 13);

--sync_slave_with_master

# set tokudb rfr crash/assert conditions if we enter lookup code
# to make sure no unique checks or row lookups is invoked
connection slave;
--source include/stop_slave.inc
let $saved_debug = `select @@debug`;
set global debug= "+d,tokudb_crash_if_rpl_looks_up_row,tokudb_crash_if_rpl_does_uniqueness_check";
--source include/start_slave.inc

connection master;
insert into t1 values(21, 21);
delete from t1 where id = 11;
update t1 set pid = 2 where id = 1;

sync_slave_with_master;

connection master;

--let $diff_tables= master:test.t1, slave:test.t1
--source include/diff_tables.inc

# print rfr disabled warning in errlog
connection master;
insert into t2 values(21, 21);
delete from t2 where id = 11;
update t2 set pid = 2 where id = 1;

sync_slave_with_master;

--let $diff_tables= master:test.t2, slave:test.t2
--source include/diff_tables.inc

connection master;
drop table t1;
drop table t2;
sync_slave_with_master;

connection slave;
--source include/stop_slave.inc
set global debug= "-d,tokudb_crash_if_rpl_looks_up_row,tokudb_crash_if_rpl_does_uniqueness_check";
set global debug= @saved_debug;
--source include/start_slave.inc

--source include/rpl_end.inc
