#
# Testing upgrading from server without merges for auto_increment
# to new server with such support.
#
set debug_dbug='+d,myrocks_autoinc_upgrade';
create table t (i int primary key auto_increment);
insert into t values ();
insert into t values ();
insert into t values ();
select * from t;
i
1
2
3
delete from t where i > 1;
select * from t;
i
1
select table_name, index_name, auto_increment
from information_schema.rocksdb_ddl where table_name = 't';
table_name	index_name	auto_increment
t	PRIMARY	NULL
set debug_dbug='-d,myrocks_autoinc_upgrade';
insert into t values ();
insert into t values ();
insert into t values ();
select * from t;
i
1
2
3
4
select table_name, index_name, auto_increment
from information_schema.rocksdb_ddl where table_name = 't';
table_name	index_name	auto_increment
t	PRIMARY	5
delete from t where i > 1;
insert into t values ();
insert into t values ();
insert into t values ();
select * from t;
i
1
5
6
7
drop table t;
#
# Testing crash safety of transactions.
#
create table t (i int primary key auto_increment);
insert into t values ();
insert into t values ();
insert into t values ();
# Before anything
begin;
insert into t values ();
insert into t values ();
set debug_dbug="+d,crash_commit_before";
commit;
ERROR HY000: Lost connection to server during query
select max(i) into @row_max from t;
select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
table_schema	table_name	auto_increment > @row_max
test	t	1
# After engine prepare
begin;
insert into t values ();
insert into t values ();
set debug_dbug="+d,crash_commit_after_prepare";
commit;
ERROR HY000: Lost connection to server during query
select max(i) into @row_max from t;
select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
table_schema	table_name	auto_increment > @row_max
test	t	1
# After binlog
begin;
insert into t values ();
insert into t values ();
set debug_dbug="+d,crash_commit_after_log";
commit;
ERROR HY000: Lost connection to server during query
select max(i) into @row_max from t;
select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
table_schema	table_name	auto_increment > @row_max
test	t	1
# After everything
begin;
insert into t values ();
insert into t values ();
set debug_dbug="+d,crash_commit_after";
commit;
ERROR HY000: Lost connection to server during query
select max(i) into @row_max from t;
select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't';
table_schema	table_name	auto_increment > @row_max
test	t	1
drop table t;
