mariadb/mysql-test/suite/galera/t/galera_partitioned_tables.test
Jan Lindström 22414d2ed0 MDEV-27861: Creating partitioned tables should not be allowed with wsrep_osu_method=TOI and wsrep_strict_ddl=ON
Problem was incorrect handling of partitioned tables,
because db_type == DB_TYPE_PARTITION_DB
wsrep_should_replicate_ddl incorrectly marked
DDL as not replicatable. However, in partitioned
tables we should check implementing storage engine
from table->file->partition_ht() if available because
if partition handler is InnoDB all DDL should be allowed
even with wsrep_strict_ddl. For other storage engines
DDL should not be allowed and error should be issued.

This is 10.5 version of the fix.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-02-02 04:54:42 +01:00

131 lines
3.8 KiB
Text

--source include/galera_cluster.inc
--source include/have_partition.inc
--source include/have_innodb.inc
--source include/have_aria.inc
--echo # wsrep-strict_ddl = OFF
SET GLOBAL wsrep_strict_ddl = OFF;
SELECT @@wsrep_strict_ddl;
CREATE OR REPLACE TABLE t1 (v1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB
PARTITION BY KEY (v1)
PARTITIONS 2;
CREATE OR REPLACE TABLE t2 (v1 INT NOT NULL PRIMARY KEY) ENGINE=MyISAM
PARTITION BY KEY (v1)
PARTITIONS 2;
ALTER TABLE t1 ADD COLUMN v2 int;
ALTER TABLE t2 ADD COLUMN v2 int;
INSERT INTO t1 VALUES (1,1),(2,2);
INSERT INTO t2 VALUES (1,1),(2,2);
ALTER TABLE t1 ADD COLUMN v3 int, ENGINE=MyISAM;
ALTER TABLE t2 ADD COLUMN v3 int, ENGINE=Aria;
UPDATE t1 SET v3 = 3;
UPDATE t2 SET v3 = 3;
CREATE INDEX xx1 ON t1(v2);
CREATE INDEX xx2 ON t2(v2);
DROP INDEX xx1 ON t1;
DROP INDEX xx2 ON t2;
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
RENAME TABLE t1 TO t1_v2;
RENAME TABLE t2 TO t2_v2;
CREATE VIEW x1 AS SELECT * FROM t1_v2;
CREATE VIEW x2 AS SELECT * FROM t2_v2;
CREATE DEFINER=`root`@`localhost` TRIGGER increment_before_t1
AFTER INSERT ON t1_v2 FOR EACH ROW
UPDATE t1_v2 SET t1_v2.v3 = t1_v2.v3+1;
CREATE DEFINER=`root`@`localhost` TRIGGER increment_before_t2
AFTER INSERT ON t2_v2 FOR EACH ROW
UPDATE t2_v2 SET t2_v2.v3 = t2_v2.v3+1;
--connection node_2
SHOW CREATE TABLE t1_v2;
SHOW CREATE TABLE t2_v2;
SHOW CREATE VIEW x1;
SHOW CREATE VIEW x2;
SELECT * FROM t1_v2;
SELECT * FROM t2_v2;
--connection node_1
DROP VIEW x1;
DROP VIEW x2;
DROP TRIGGER increment_before_t1;
DROP TRIGGER increment_before_t2;
DROP TABLE t1_v2;
DROP TABLE t2_v2;
SET GLOBAL wsrep_strict_ddl = OFF;
CREATE OR REPLACE TABLE t2 (v1 INT NOT NULL PRIMARY KEY) ENGINE=MyISAM
PARTITION BY KEY (v1)
PARTITIONS 2;
--echo # wsrep-strict_ddl = ON
SET GLOBAL wsrep_strict_ddl = ON;
SELECT @@wsrep_strict_ddl;
CREATE OR REPLACE TABLE t1 (v1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB
PARTITION BY KEY (v1)
PARTITIONS 2;
--error ER_GALERA_REPLICATION_NOT_SUPPORTED
CREATE OR REPLACE TABLE t3 (v1 INT NOT NULL PRIMARY KEY) ENGINE=MyISAM
PARTITION BY KEY (v1)
PARTITIONS 2;
ALTER TABLE t1 ADD COLUMN v2 int;
--error ER_GALERA_REPLICATION_NOT_SUPPORTED
ALTER TABLE t2 ADD COLUMN v2 int;
INSERT INTO t1 VALUES (1,1),(2,2);
INSERT INTO t2 VALUES (1),(2);
--error ER_GALERA_REPLICATION_NOT_SUPPORTED
ALTER TABLE t1 ADD COLUMN v3 int, ENGINE=MyISAM;
--error ER_GALERA_REPLICATION_NOT_SUPPORTED
ALTER TABLE t2 ADD COLUMN v3 int, ENGINE=Aria;
UPDATE t1 SET v2 = v2 + 3;
UPDATE t2 SET v1 = v1 + 3;
CREATE INDEX xx1 ON t1(v2);
--error ER_GALERA_REPLICATION_NOT_SUPPORTED
CREATE INDEX xx2 ON t2(v2);
DROP INDEX xx1 ON t1;
--error ER_GALERA_REPLICATION_NOT_SUPPORTED
DROP INDEX xx2 on t2;
TRUNCATE TABLE t1;
--error ER_GALERA_REPLICATION_NOT_SUPPORTED
TRUNCATE TABLE t2;
# At the moment can't restrict rename
RENAME TABLE t1 TO t1_v2;
RENAME TABLE t2 TO t2_v2;
RENAME TABLE t2_v2 TO t2;
CREATE VIEW x1 AS SELECT * FROM t1_v2;
--error ER_GALERA_REPLICATION_NOT_SUPPORTED
CREATE VIEW x2 AS SELECT * FROM t2;
CREATE DEFINER=`root`@`localhost` TRIGGER increment_before_t1
AFTER INSERT ON t1_v2 FOR EACH ROW
UPDATE t1_v2 SET t1_v2.v2 = t1_v2.v2+1;
--error ER_GALERA_REPLICATION_NOT_SUPPORTED
CREATE DEFINER=`root`@`localhost` TRIGGER increment_before_t2
AFTER INSERT ON t2 FOR EACH ROW
UPDATE t2 SET t2.v1 = t2.v1+1;
--connection node_2
SHOW CREATE TABLE t1_v2;
SHOW CREATE TABLE t2;
SHOW CREATE VIEW x1;
SELECT * FROM t1_v2;
SELECT * FROM t2;
--connection node_1
DROP VIEW x1;
DROP TRIGGER increment_before_t1;
DROP TABLE t1_v2;
# We allow dropping table
DROP TABLE t2;
SET GLOBAL wsrep_strict_ddl=OFF;
CREATE OR REPLACE TABLE t2 (v1 INT NOT NULL PRIMARY KEY) ENGINE=MyISAM
PARTITION BY KEY (v1)
PARTITIONS 2;
--echo # wsrep-strict_ddl = ON
SET GLOBAL wsrep_strict_ddl = ON;
SELECT @@wsrep_strict_ddl;
ALTER TABLE t2 ENGINE=InnoDB;
DROP TABLE t2;
SET GLOBAL wsrep_strict_ddl = DEFAULT;