--source include/galera_cluster.inc
--source include/have_innodb.inc

#
# This tests MyISAM tables in transactions. No MyISAM updates arrive on the slave, but InnoDB ones do.
#

CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
CREATE TABLE t2 (f1 INTEGER) ENGINE=MyISAM;
CREATE TABLE t3 (f1 INTEGER) ENGINE=MyISAM;

CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t3 VALUES (NEW.f1);

SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
COMMIT;

--connection node_2
SELECT COUNT(*) = 1 FROM t1;
SELECT COUNT(*) = 0 FROM t2;
SELECT COUNT(*) = 0 FROM t2;

--connection node_1
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
ROLLBACK;

--connection node_2
SELECT COUNT(*) = 1 FROM t1;
SELECT COUNT(*) = 0 FROM t2;
SELECT COUNT(*) = 0 FROM t2;

DROP TABLE t1, t2, t3;

#
# MDEV-25201 : Assertion `thd->wsrep_trx_meta.gtid.seqno == (-1)' failed in int wsrep_to_isolation_begin(THD*, const char*, const char*, const TABLE_LIST*, Alter_info*)
#
SET SESSION lock_wait_timeout=2;
SET GLOBAL wsrep_mode = REPLICATE_MYISAM;
CREATE TEMPORARY TABLE t1 (i INT, PRIMARY KEY pk (i)) ENGINE=MyISAM;
PREPARE stmt FROM "INSERT INTO t1 (id) SELECT * FROM (SELECT 4 AS i) AS y";
INSERT INTO t1 VALUES(4);
DEALLOCATE PREPARE stmt;
COMMIT;
DROP TABLE t1;
SET GLOBAL wsrep_mode = DEFAULT;
