# verify that information_schema.tokudb_locks gets populated with locks for 2 clients

source include/have_tokudb.inc;
set default_storage_engine='tokudb';
set tokudb_prelock_empty=false;
disable_warnings;
drop table if exists t;
enable_warnings;

create table t (id int primary key);
set autocommit=0;
let $default_id=`select connection_id()`;

# should be empty
select locks_dname,locks_key_left,locks_key_right,locks_table_schema,locks_table_name,locks_table_dictionary_name from information_schema.tokudb_locks where locks_table_schema='test' and locks_table_name='t' and locks_table_dictionary_name='main' order by locks_key_left, locks_key_right;

insert into t values (1);
insert into t values (3);
insert into t values (5);

connect (conn_a,localhost,root,,);
set autocommit=0;
let $a_id=`select connection_id()`;

insert into t values (2);
insert into t values (4);
insert into t values (6);

# should find 3 locks for 2 transactions
connection default;
eval select locks_dname,locks_key_left,locks_key_right,locks_table_schema,locks_table_name,locks_table_dictionary_name from information_schema.tokudb_locks where locks_table_schema='test' and locks_table_name='t' and locks_table_dictionary_name='main' order by locks_key_left, locks_key_right;

connection conn_a;
commit;
connection default;
commit;

# should be empty
select locks_dname,locks_key_left,locks_key_right,locks_table_schema,locks_table_name,locks_table_dictionary_name from information_schema.tokudb_locks where locks_table_schema='test' and locks_table_name='t' and locks_table_dictionary_name='main' order by locks_key_left, locks_key_right;
commit;

disconnect conn_a;

drop table t;
