#
# Test DDL errors under Rolling Schema Upgrade
#

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

CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB;
INSERT INTO t1 VALUES (1), (1);

--connection node_2
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1';
--source include/wait_condition.inc

SET SESSION wsrep_OSU_method = "RSU";
--error ER_DUP_ENTRY
ALTER TABLE t1 ADD PRIMARY KEY (f1);
SET SESSION wsrep_OSU_method = "TOI";

# The ALTER has no effect
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = 't1';

INSERT INTO t1 VALUES (1);

--connection node_1
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = 't1';
SELECT COUNT(*) = 3 FROM t1;

INSERT INTO t1 VALUES (1);

--connection node_2
SELECT COUNT(3) = 4 FROM t1;

DROP TABLE t1;
