--source include/galera_cluster.inc

--connection node_1
CREATE TABLE t1 (c INT);
INSERT INTO t1 VALUES (0),(0);
CREATE TABLE t2 (c INT);
SET SESSION wsrep_trx_fragment_unit='STATEMENTS';
SET SESSION wsrep_trx_fragment_size=2;
--error ER_TABLEACCESS_DENIED_ERROR
DROP TABLE mysql.wsrep_streaming_log;
CREATE TRIGGER tgr AFTER INSERT ON t2 FOR EACH ROW UPDATE t1 SET c=c+1;
INSERT INTO t2 VALUES (1),(2);
SELECT * FROM t1;
SELECT * FROM t2;

SET wsrep_trx_fragment_unit=DEFAULT;
SET GLOBAL wsrep_trx_fragment_size=DEFAULT;
DROP TRIGGER tgr;
DROP TABLE t1, t2;

--connection node_2
SET GLOBAL wsrep_on=OFF;
--error ER_WRONG_VALUE_FOR_VAR
SET SESSION wsrep_trx_fragment_unit='STATEMENTS';
SELECT @@wsrep_trx_fragment_unit;
SELECT @@wsrep_trx_fragment_size;
--error ER_WRONG_VALUE_FOR_VAR
SET SESSION wsrep_trx_fragment_size = 2;
SHOW WARNINGS;
SELECT @@wsrep_trx_fragment_unit;
SELECT @@wsrep_trx_fragment_size;
DROP TABLE mysql.wsrep_streaming_log;
--error ER_WRONG_VALUE_FOR_VAR
SET SESSION wsrep_trx_fragment_unit='STATEMENTS';
--error ER_WRONG_VALUE_FOR_VAR
SET SESSION wsrep_trx_fragment_size = 2;
SHOW WARNINGS;
SELECT @@wsrep_trx_fragment_unit;
SELECT @@wsrep_trx_fragment_size;
SET SESSION wsrep_trx_fragment_size = 0;
SELECT @@wsrep_trx_fragment_unit;
SELECT @@wsrep_trx_fragment_size;
SET GLOBAL wsrep_on=ON;
--error ER_WRONG_VALUE_FOR_VAR
SET SESSION wsrep_trx_fragment_unit='STATEMENTS';
--error ER_WRONG_VALUE_FOR_VAR
SET SESSION wsrep_trx_fragment_size = 2;
SHOW WARNINGS;
SELECT @@wsrep_trx_fragment_unit;
SELECT @@wsrep_trx_fragment_size;
SET GLOBAL wsrep_on=OFF;
CREATE TABLE IF NOT EXISTS mysql.wsrep_streaming_log
(
  node_uuid CHAR(36),
  trx_id BIGINT,
  seqno BIGINT,
  flags INT NOT NULL,
  frag LONGBLOB NOT NULL,
  PRIMARY KEY (node_uuid, trx_id, seqno)
) ENGINE=InnoDB STATS_PERSISTENT=0 CHARSET=latin1;
SET GLOBAL wsrep_on=ON;

--connection node_1
CREATE TABLE t1 (c INT);
INSERT INTO t1 VALUES (0),(0);
CREATE TABLE t2 (c INT);
SET SESSION wsrep_trx_fragment_unit='STATEMENTS';
SET SESSION wsrep_trx_fragment_size=2;
CREATE TRIGGER tgr AFTER INSERT ON t2 FOR EACH ROW UPDATE t1 SET c=c+1;
INSERT INTO t2 VALUES (1),(2);
SELECT * FROM t1;
SELECT * FROM t2;

--connection node_2
INSERT INTO t2 VALUES (1),(2);
SELECT * FROM t1;
SELECT * FROM t2;

--connection node_1
SET wsrep_trx_fragment_unit=DEFAULT;
SET GLOBAL wsrep_trx_fragment_size=DEFAULT;
DROP TRIGGER tgr;
DROP TABLE t1, t2;
