#
# A simple test for PREPARE / EXECUTE -style prepared statements with Galera
#
# C-API-level prepared-statements can not be triggered from inside mysqltest, however
# can be exercised when running an MTR test suite with the --ps-protocol switch.
#

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

CREATE TABLE t1 (f1 CHAR(5)) ENGINE=InnoDB;
CREATE TABLE t2 (f1 CHAR(5)) ENGINE=InnoDB;
CREATE TABLE t3 (f1 CHAR(5)) ENGINE=InnoDB;
CREATE TABLE t4 (f1 CHAR(5)) ENGINE=InnoDB;

SET SESSION sql_mode='STRICT_ALL_TABLES';

PREPARE st1 FROM 'INSERT INTO t1 VALUES ("abc")';
PREPARE st2 FROM 'INSERT INTO t2 VALUES ("abc")';
PREPARE st3 FROM 'INSERT INTO t3 VALUES ("abc")';
PREPARE st4 FROM 'INSERT INTO t4 VALUES ("abc")';

EXECUTE st1;
EXECUTE st2;
EXECUTE st3;
EXECUTE st4;

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

ALTER TABLE t1 ADD COLUMN f2 INTEGER;
ALTER TABLE t1 DROP COLUMN f1;

--connection node_1
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
EXECUTE st1;

--connection node_1
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
