SET @max_row = 20; SET @@session.default_storage_engine = 'InnoDB'; #------------------------------------------------------------------------ # 0. Setting of auxiliary variables + Creation of an auxiliary tables # needed in many testcases #------------------------------------------------------------------------ SELECT @max_row DIV 2 INTO @max_row_div2; SELECT @max_row DIV 3 INTO @max_row_div3; SELECT @max_row DIV 4 INTO @max_row_div4; SET @max_int_4 = 2147483647; DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) , PRIMARY KEY(f_int1)) ENGINE = MEMORY; # Logging of INSERTs into t0_template suppressed DROP TABLE IF EXISTS t0_definition; CREATE TABLE t0_definition ( state CHAR(3), create_command VARBINARY(5000), file_list VARBINARY(10000), PRIMARY KEY (state) ) ENGINE = MEMORY; DROP TABLE IF EXISTS t0_aux; CREATE TABLE t0_aux ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) ENGINE = MEMORY; SET AUTOCOMMIT= 1; SET @@session.sql_mode= ''; # End of basic preparations needed for all tests #----------------------------------------------- #======================================================================== # 1.1.1.12 ALTER TABLE PARTITION #======================================================================== #------------------------------------------------------------------------ # 1 ALTER ... ANALYZE PARTITION #------------------------------------------------------------------------ # 1.1 ALTER ... ANALYZE PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 1.2 ALTER ... ANALYZE PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 1.3 ALTER ... ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 1.4 ALTER ... ANALYZE PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 analyze error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 1.5 ALTER ... ANALYZE PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; #------------------------------------------------------------------------ # 2 ALTER ... CHECK PARTITION #------------------------------------------------------------------------ # 2.1 ALTER ... CHECK PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 2.2 ALTER ... CHECK PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 2.3 ALTER ... CHECK PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 2.4 ALTER ... CHECK PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 check error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 2.5 ALTER ... CHECK PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION ALL; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION ALL; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION ALL; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION ALL; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION ALL; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION ALL; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION ALL; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 CHECK PARTITION ALL; Table Op Msg_type Msg_text test.t1 check status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; #------------------------------------------------------------------------ # 3 ALTER ... OPTIMIZE PARTITION #------------------------------------------------------------------------ # 3.1 ALTER ... OPTIMIZE PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 3.2 ALTER ... OPTIMIZE PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 3.3 ALTER ... OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 3.4 ALTER ... OPTIMIZE PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 optimize error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 3.5 ALTER ... OPTIMIZE PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 OPTIMIZE PARTITION ALL; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize on partitions. All partitions will be rebuilt and analyzed. test.t1 optimize status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; #------------------------------------------------------------------------ # 4 ALTER ... REBUILD PARTITION #------------------------------------------------------------------------ # 4.1 ALTER ... REBUILD PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 4.2 ALTER ... REBUILD PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 4.3 ALTER ... REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; # 4.4 ALTER ... REBUILD PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1; ERROR HY000: Wrong partition name or partition list DROP TABLE t1; # 4.5 ALTER ... REBUILD PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION ALL; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION ALL; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION ALL; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION ALL; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION ALL; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION ALL; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION ALL; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REBUILD PARTITION ALL; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; #------------------------------------------------------------------------ # 5 ALTER ... REPAIR PARTITION #------------------------------------------------------------------------ # 5.1 ALTER ... REPAIR PARTITION part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 5.2 ALTER ... REPAIR PARTITION part_1,part_2; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 5.3 ALTER ... REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_2,part_5,part_6,part_10; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 5.4 ALTER ... REPAIR PARTITION part_1,part_1,part_1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION part_1,part_1,part_1; Table Op Msg_type Msg_text test.t1 repair error Wrong partition name or partition list INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; # 5.5 ALTER ... REPAIR PARTITION ALL; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION ALL; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY HASH (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION ALL; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY KEY (`f_int1`) (PARTITION `part_1` ENGINE = InnoDB, PARTITION `part_2` ENGINE = InnoDB, PARTITION `part_3` ENGINE = InnoDB, PARTITION `part_4` ENGINE = InnoDB, PARTITION `part_5` ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION ALL; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (`f_int1` MOD 4) (PARTITION `part_3` VALUES IN (-3) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (-2) ENGINE = InnoDB, PARTITION `part_1` VALUES IN (-1) ENGINE = InnoDB, PARTITION `part_N` VALUES IN (NULL) ENGINE = InnoDB, PARTITION `part0` VALUES IN (0) ENGINE = InnoDB, PARTITION `part1` VALUES IN (1) ENGINE = InnoDB, PARTITION `part2` VALUES IN (2) ENGINE = InnoDB, PARTITION `part3` VALUES IN (3) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION ALL; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) (PARTITION `parta` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_1` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION `part_5` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION ALL; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1` DIV 2) SUBPARTITION BY HASH (`f_int1`) SUBPARTITIONS 2 (PARTITION `part_1` VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION `part_3` VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION `part_4` VALUES LESS THAN (2147483646) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION ALL; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY RANGE (`f_int1`) SUBPARTITION BY KEY (`f_int1`) (PARTITION `part_1` VALUES LESS THAN (0) (SUBPARTITION `subpart11` ENGINE = InnoDB, SUBPARTITION `subpart12` ENGINE = InnoDB), PARTITION `part_2` VALUES LESS THAN (5) (SUBPARTITION `subpart21` ENGINE = InnoDB, SUBPARTITION `subpart22` ENGINE = InnoDB), PARTITION `part_3` VALUES LESS THAN (10) (SUBPARTITION `subpart31` ENGINE = InnoDB, SUBPARTITION `subpart32` ENGINE = InnoDB), PARTITION `part_4` VALUES LESS THAN (2147483646) (SUBPARTITION `subpart41` ENGINE = InnoDB, SUBPARTITION `subpart42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; ERROR HY000: Table has no partition for value 2147483647 DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION ALL; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 3)) SUBPARTITION BY HASH (`f_int1` + 1) (PARTITION `part_1` VALUES IN (0) (SUBPARTITION `sp11` ENGINE = InnoDB, SUBPARTITION `sp12` ENGINE = InnoDB), PARTITION `part_2` VALUES IN (1) (SUBPARTITION `sp21` ENGINE = InnoDB, SUBPARTITION `sp22` ENGINE = InnoDB), PARTITION `part_3` VALUES IN (2) (SUBPARTITION `sp31` ENGINE = InnoDB, SUBPARTITION `sp32` ENGINE = InnoDB), PARTITION `part_4` VALUES IN (NULL) (SUBPARTITION `sp41` ENGINE = InnoDB, SUBPARTITION `sp42` ENGINE = InnoDB)) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REPAIR PARTITION ALL; Table Op Msg_type Msg_text test.t1 repair status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PARTITION BY LIST (abs(`f_int1` MOD 2)) SUBPARTITION BY KEY (`f_int1`) SUBPARTITIONS 3 (PARTITION `part_1` VALUES IN (0) ENGINE = InnoDB, PARTITION `part_2` VALUES IN (1) ENGINE = InnoDB, PARTITION `part_3` VALUES IN (NULL) ENGINE = InnoDB) # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair status OK # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; #------------------------------------------------------------------------ # 6 ALTER ... REMOVE PARTITIONING #------------------------------------------------------------------------ # 6.1 ALTER ... REMOVE PARTITIONING; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REMOVE PARTITIONING; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REMOVE PARTITIONING; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part_N VALUES IN (NULL), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REMOVE PARTITIONING; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) (PARTITION parta VALUES LESS THAN (0), PARTITION part_1 VALUES LESS THAN (5), PARTITION part_2 VALUES LESS THAN (10), PARTITION part_3 VALUES LESS THAN (10 + 5), PARTITION part_4 VALUES LESS THAN (20), PARTITION part_5 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REMOVE PARTITIONING; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2 (PARTITION part_1 VALUES LESS THAN (0), PARTITION part_2 VALUES LESS THAN (5), PARTITION part_3 VALUES LESS THAN (10), PARTITION part_4 VALUES LESS THAN (2147483646)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REMOVE PARTITIONING; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1) (PARTITION part_1 VALUES LESS THAN (0) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part_2 VALUES LESS THAN (5) (SUBPARTITION subpart21, SUBPARTITION subpart22), PARTITION part_3 VALUES LESS THAN (10) (SUBPARTITION subpart31, SUBPARTITION subpart32), PARTITION part_4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41, SUBPARTITION subpart42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REMOVE PARTITIONING; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1) (PARTITION part_1 VALUES IN (0) (SUBPARTITION sp11, SUBPARTITION sp12), PARTITION part_2 VALUES IN (1) (SUBPARTITION sp21, SUBPARTITION sp22), PARTITION part_3 VALUES IN (2) (SUBPARTITION sp31, SUBPARTITION sp32), PARTITION part_4 VALUES IN (NULL) (SUBPARTITION sp41, SUBPARTITION sp42)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REMOVE PARTITIONING; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; CREATE TABLE t1 ( f_int1 INTEGER DEFAULT 0, f_int2 INTEGER DEFAULT 0, f_char1 CHAR(20), f_char2 CHAR(20), f_charbig VARCHAR(1000) ) PARTITION BY LIST(ABS(MOD(f_int1,2))) SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3 (PARTITION part_1 VALUES IN (0), PARTITION part_2 VALUES IN (1), PARTITION part_3 VALUES IN (NULL)); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 REMOVE PARTITIONING; INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 AND @max_row; # Start usability test (inc/partition_check.inc) create_command SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f_int1` int(11) DEFAULT 0, `f_int2` int(11) DEFAULT 0, `f_char1` char(20) DEFAULT NULL, `f_char2` char(20) DEFAULT NULL, `f_charbig` varchar(1000) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci # check prerequisites-1 success: 1 # check COUNT(*) success: 1 # check MIN/MAX(f_int1) success: 1 # check MIN/MAX(f_int2) success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'delete me' FROM t0_template WHERE f_int1 IN (2,3); # check prerequisites-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'delete me'; # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE # check read via f_int1 success: 1 # check read via f_int2 success: 1 # check multiple-1 success: 1 DELETE FROM t1 WHERE MOD(f_int1,3) = 0; # check multiple-2 success: 1 INSERT INTO t1 SELECT * FROM t0_template WHERE MOD(f_int1,3) = 0; # check multiple-3 success: 1 UPDATE t1 SET f_int1 = f_int1 + @max_row WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 AND @max_row_div2 + @max_row_div4; # check multiple-4 success: 1 DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row AND @max_row_div2 + @max_row_div4 + @max_row; # check multiple-5 success: 1 SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-1 success: 1 SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), f_charbig = '#SINGLE#'; # check single-2 success: 1 SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # check single-3 success: 1 SET @cur_value1= -1; SELECT MAX(f_int1) INTO @cur_value2 FROM t1; UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # check single-4 success: 1 SELECT MAX(f_int1) INTO @cur_value FROM t1; DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # check single-5 success: 1 DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#'; # check single-6 success: 1 INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##'; # check single-7 success: 1 DELETE FROM t1 WHERE f_charbig = '#2147483647##'; DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0; INSERT t1 SET f_int1 = 0 , f_int2 = 0, f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR), f_charbig = '#NULL#'; INSERT INTO t1 SET f_int1 = NULL , f_int2 = -@max_row, f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR), f_charbig = '#NULL#'; # check null success: 1 # check null-1 success: 1 UPDATE t1 SET f_int1 = -@max_row WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-2 success: 1 UPDATE t1 SET f_int1 = NULL WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-3 success: 1 DELETE FROM t1 WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR) AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#'; # check null-4 success: 1 DELETE FROM t1 WHERE f_int1 = 0 AND f_int2 = 0 AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR) AND f_charbig = '#NULL#'; SET AUTOCOMMIT= 0; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-1 success: 1 COMMIT WORK; # check transactions-2 success: 1 ROLLBACK WORK; # check transactions-3 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; ROLLBACK WORK; # check transactions-4 success: 1 INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, '', '', 'was inserted' FROM t0_template source_tab WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; # check transactions-5 success: 1 ROLLBACK WORK; # check transactions-6 success: 1 # INFO: Storage engine used for t1 seems to be transactional. COMMIT; # check transactions-7 success: 1 DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; SET @@session.sql_mode = 'traditional'; SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1, '', '', 'was inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; ERROR 22012: Division by 0 COMMIT; # check transactions-8 success: 1 # INFO: Storage engine used for t1 seems to be able to revert # changes made by the failing statement. SET @@session.sql_mode = ''; SET AUTOCOMMIT= 1; DELETE FROM t1 WHERE f_charbig = 'was inserted'; COMMIT WORK; UPDATE t1 SET f_charbig = REPEAT('b', 1000); # check special-1 success: 1 UPDATE t1 SET f_charbig = ''; # check special-2 success: 1 UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'==='); INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-1 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; # check trigger-2 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-3 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-4 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = new.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-5 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2 WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-6 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-7 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW BEGIN UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2, f_charbig = 'updated by trigger' WHERE f_int1 = - old.f_int1; END| DELETE FROM t0_aux WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1)); # check trigger-8 success: 1 DROP TRIGGER trg_1; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = 'just inserted' WHERE f_int1 <> CAST(f_char1 AS SIGNED INT); DELETE FROM t0_aux WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; DELETE FROM t1 WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1; CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = old.f_int1 + @max_row, new.f_int2 = old.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-9 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN SET new.f_int1 = new.f_int1 + @max_row, new.f_int2 = new.f_int2 - @max_row, new.f_charbig = '####updated per update trigger####'; END| UPDATE t1 SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row, f_charbig = '####updated per update statement itself####'; # check trigger-10 success: 1 DROP TRIGGER trg_2; UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT), f_int2 = CAST(f_char1 AS SIGNED INT), f_charbig = CONCAT('===',f_char1,'==='); CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) SELECT f_int1, f_int1, CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-11 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET new.f_int1 = @my_max1 + @counter, new.f_int2 = @my_min2 - @counter, new.f_charbig = '####updated per insert trigger####'; SET @counter = @counter + 1; END| SET @counter = 1; SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; INSERT INTO t1 (f_char1, f_char2, f_charbig) SELECT CAST(f_int1 AS CHAR), CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1 ORDER BY f_int1; DROP TRIGGER trg_3; # check trigger-12 success: 1 DELETE FROM t1 WHERE f_int1 <> CAST(f_char1 AS SIGNED INT) AND f_int2 <> CAST(f_char1 AS SIGNED INT) AND f_charbig = '####updated per insert trigger####'; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK # check layout success: 1 REPAIR TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair # check layout success: 1 TRUNCATE t1; # check TRUNCATE success: 1 # check layout success: 1 # End usability test (inc/partition_check.inc) DROP TABLE t1; DROP VIEW IF EXISTS v1; DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t0_aux; DROP TABLE IF EXISTS t0_definition; DROP TABLE IF EXISTS t0_template;