--source include/not_embedded.inc
--source include/have_perfschema.inc
--source include/no_protocol.inc

-- source include/master-slave.inc

connection master;
--echo **** On Master ****

--disable_warnings
drop table if exists test.marker;
--enable_warnings

create table test.marker(a int) engine=innodb;
insert into test.marker values (1);
select * from test.marker;

truncate table performance_schema.events_waits_history_long;
truncate table performance_schema.events_statements_summary_by_digest;

update performance_schema.setup_instruments
  set enabled='YES', timed='YES';

sync_slave_with_master;
--echo **** On Slave ****

truncate table performance_schema.events_waits_history_long;
truncate table performance_schema.events_statements_summary_by_digest;

update performance_schema.setup_instruments
  set enabled='YES', timed='NO';

connection master;
--echo **** On Master ****

select * from performance_schema.setup_instruments
  where timed='NO';

select "This better be in the master" as in_master_digest;

insert into performance_schema.setup_objects
  values ('TABLE', 'master', 'foo', 'YES', 'YES');

select * from performance_schema.setup_objects
  order by object_type, object_schema, object_name;

select digest, digest_text, count_star
  from performance_schema.events_statements_summary_by_digest
  where digest_text like "%in_%_digest%";

insert into test.marker values (2);

sync_slave_with_master;
--echo **** On Slave ****

select * from test.marker;

select * from performance_schema.setup_instruments
  where timed='YES';

select "This better be in the slave" as in_slave_digest;

insert into performance_schema.setup_objects
  values ('TABLE', 'slave', 'foo', 'YES', 'YES');

select * from performance_schema.setup_objects
  order by object_type, object_schema, object_name;

select digest, digest_text, count_star
  from performance_schema.events_statements_summary_by_digest
  where digest_text like "%in_%_digest%";

connection master;
--echo **** On Master ****
delete from performance_schema.setup_objects
  where object_schema='master';
sync_slave_with_master;
--echo **** On Slave ****

delete from performance_schema.setup_objects
  where object_schema='slave';
select * from performance_schema.setup_objects;

--disable_query_log
--disable_warnings
connection master;
drop table test.marker;
sync_slave_with_master;
--enable_warnings
--enable_query_log
--source include/rpl_end.inc
