Commit 187a5bbf authored by Marko Mäkelä's avatar Marko Mäkelä

Adjust the tests for MariaDB, and optimize them

parent f8bc799a
...@@ -19,7 +19,7 @@ SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't' ...@@ -19,7 +19,7 @@ SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
AND TIMESTAMPDIFF(SECOND, update_time, NOW()) < 120; AND TIMESTAMPDIFF(SECOND, update_time, NOW()) < 120;
COUNT(*) COUNT(*)
1 1
CREATE TABLE big (a TEXT) ENGINE=INNODB; CREATE TEMPORARY TABLE big (a TEXT) ENGINE=INNODB;
SELECT COUNT(*) FROM information_schema.innodb_buffer_page SELECT COUNT(*) FROM information_schema.innodb_buffer_page
WHERE table_name = '`test`.`t`'; WHERE table_name = '`test`.`t`';
COUNT(*) COUNT(*)
...@@ -34,20 +34,21 @@ SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't' ...@@ -34,20 +34,21 @@ SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
AND update_time IS NOT NULL; AND update_time IS NOT NULL;
COUNT(*) COUNT(*)
1 1
DROP TABLE big; DROP TEMPORARY TABLE big;
# Test the behavior after restart with a prepared XA transaction # Test the behavior after restart with a prepared XA transaction
XA START 'xatrx'; XA START 'xatrx';
INSERT INTO t VALUES (5); INSERT INTO t VALUES (5);
XA END 'xatrx'; XA END 'xatrx';
XA PREPARE 'xatrx'; XA PREPARE 'xatrx';
CONNECT con1,localhost,root,,;
call mtr.add_suppression("Found 1 prepared XA transactions"); call mtr.add_suppression("Found 1 prepared XA transactions");
FLUSH TABLES;
# Kill and restart # Kill and restart
SELECT update_time FROM information_schema.tables WHERE table_name = 't'; SELECT update_time FROM information_schema.tables WHERE table_name = 't';
update_time update_time
NULL NULL
XA COMMIT 'xatrx'; XA COMMIT 'xatrx';
SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't' SELECT COUNT(update_time) FROM information_schema.tables WHERE table_name='t';
AND update_time IS NOT NULL; COUNT(update_time)
COUNT(*)
1 1
DROP TABLE t; DROP TABLE t;
#create base table
CREATE TABLE tab1(c1 int,c2 varchar(30), c3 BLOB) ENGINE=InnoDB; CREATE TABLE tab1(c1 int,c2 varchar(30), c3 BLOB) ENGINE=InnoDB;
CREATE TABLE tab1u LIKE tab1;
CREATE TABLE tab1d LIKE tab1;
CREATE TABLE tab1i LIKE tab1;
CREATE TABLE tab3(c1 int,c2 varchar(30)) ENGINE=InnoDB; CREATE TABLE tab3(c1 int,c2 varchar(30)) ENGINE=InnoDB;
CREATE TABLE tab4(c1 int,c2 varchar(30)) ENGINE=InnoDB; CREATE TABLE tab4(c1 int,c2 varchar(30)) ENGINE=InnoDB;
CREATE TABLE tab5(c1 int,c2 varchar(30)) ENGINE=InnoDB; CREATE TABLE tab5(c1 int,c2 varchar(30)) ENGINE=InnoDB;
#insert some base records INSERT INTO tab1u VALUES(1,'Testing the wl6658','Testing the wl6658');
INSERT INTO tab1d VALUES(1,'Updated','Updated');
INSERT INTO tab4 VALUES(1,'Test for Update'); INSERT INTO tab4 VALUES(1,'Test for Update');
INSERT INTO tab5 VALUES(1,'Test for Delete'); INSERT INTO tab5 VALUES(1,'Test for Delete');
#create a trigger
CREATE TRIGGER test_trig BEFORE INSERT ON tab1 CREATE TRIGGER test_trig BEFORE INSERT ON tab1
FOR EACH ROW BEGIN FOR EACH ROW BEGIN
INSERT INTO tab3 VALUES(1,'Inserted From Trigger'); INSERT INTO tab3 VALUES(1,'Inserted From Trigger');
UPDATE tab4 SET c2='Updated from Trigger' WHERE c1=1; UPDATE tab4 SET c2='Updated from Trigger' WHERE c1=1;
DELETE FROM tab5; DELETE FROM tab5;
END | END |
CREATE TABLE tab2(
id INT NOT NULL,
store_name VARCHAR(30),
parts VARCHAR(30),
store_id INT
) ENGINE=InnoDB
PARTITION BY LIST(store_id) (
PARTITION pNorth VALUES IN (10,20,30),
PARTITION pEast VALUES IN (40,50,60),
PARTITION pWest VALUES IN (70,80,100)
);
SELECT update_time
FROM information_schema.tables WHERE table_name='tab2';
update_time
NULL
CREATE PROCEDURE proc_wl6658()
BEGIN
INSERT INTO tab2 VALUES(1,'ORACLE','NUTT',10);
INSERT INTO tab2 VALUES(2,'HUAWEI','BOLT',40);
COMMIT;
END |
CALL proc_wl6658;
SELECT * FROM tab2 ORDER BY id,store_id;
id store_name parts store_id
1 ORACLE NUTT 10
2 HUAWEI BOLT 40
SELECT COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab2';
COUNT(update_time)
1
TRUNCATE TABLE tab2;
SELECT COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab2';
COUNT(update_time)
1
CREATE TABLE tab7(c1 INT NOT NULL, PRIMARY KEY (c1)) ENGINE=INNODB;
CREATE TABLE tab8(c1 INT PRIMARY KEY,c2 INT,
FOREIGN KEY (c2) REFERENCES tab7(c1) ON DELETE CASCADE )
ENGINE=INNODB;
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
GROUP BY table_name ORDER BY table_name;
table_name update_time
tab7 NULL
tab8 NULL
INSERT INTO tab7 VALUES(1);
INSERT INTO tab8 VALUES(1,1);
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
GROUP BY table_name ORDER BY table_name;
table_name COUNT(update_time)
tab7 1
tab8 1
#restart the server #restart the server
# restart
check the update_time Before DML, whether it is NULL
SELECT table_name,update_time SELECT table_name,update_time
FROM information_schema.tables FROM information_schema.tables
WHERE table_name IN ('tab1','tab3','tab4','tab5'); WHERE table_name IN ('tab1','tab2','tab3','tab4','tab5','tab7','tab8')
ORDER BY table_name;
table_name update_time table_name update_time
tab1 NULL tab1 NULL
tab2 NULL
tab3 NULL tab3 NULL
tab4 NULL tab4 NULL
tab5 NULL tab5 NULL
SET AUTOCOMMIT=OFF; tab7 NULL
tab8 NULL
#case1: #case1:
BEGIN WORK; BEGIN WORK;
INSERT INTO tab1 INSERT INTO tab1
VALUES(1,'Testing the wl6658', 'Testing the wl6658'); VALUES(1,'Testing the wl6658', 'Testing the wl6658');
check the update_time Before commit, whether it is NULL SELECT update_time
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab1'; FROM information_schema.tables WHERE table_name='tab1';
table_name update_time update_time
tab1 NULL NULL
COMMIT; COMMIT;
#check the record is inserted
SELECT * FROM tab1; SELECT * FROM tab1;
c1 c2 c3 c1 c2 c3
1 Testing the wl6658 Testing the wl6658 1 Testing the wl6658 Testing the wl6658
#check the record is inserted
SELECT * FROM tab3; SELECT * FROM tab3;
c1 c2 c1 c2
1 Inserted From Trigger 1 Inserted From Trigger
#check the record is updated
SELECT * FROM tab4; SELECT * FROM tab4;
c1 c2 c1 c2
1 Updated from Trigger 1 Updated from Trigger
#check no record exists
SELECT * FROM tab5; SELECT * FROM tab5;
c1 c2 c1 c2
check the update_time After Commit, whether it is not NULL
SELECT table_name,COUNT(update_time) SELECT table_name,COUNT(update_time)
FROM information_schema.tables FROM information_schema.tables
WHERE table_name IN ('tab1','tab3','tab4','tab5') WHERE table_name IN ('tab1','tab3','tab4','tab5')
GROUP BY table_name; GROUP BY table_name ORDER BY table_name;
table_name COUNT(update_time) table_name COUNT(update_time)
tab1 1 tab1 1
tab3 1 tab3 1
tab4 1 tab4 1
tab5 1 tab5 1
#restart the server
# restart
Testcase with UPDATE stmt and transaction Testcase with UPDATE stmt and transaction
#check the record is existing SELECT * FROM tab1u;
SELECT * FROM tab1;
c1 c2 c3 c1 c2 c3
1 Testing the wl6658 Testing the wl6658 1 Testing the wl6658 Testing the wl6658
check the update_time Before DML, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1u';
FROM information_schema.tables WHERE table_name='tab1'; update_time
table_name update_time NULL
tab1 NULL
SET AUTOCOMMIT=OFF;
#case2: #case2:
START TRANSACTION; START TRANSACTION;
UPDATE tab1 SET c2='Updated',c3='Updated' WHERE c1=1; UPDATE tab1u SET c2='Updated',c3='Updated' WHERE c1=1;
check the update_time Before commit, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1u';
FROM information_schema.tables WHERE table_name='tab1'; update_time
table_name update_time NULL
tab1 NULL
COMMIT; COMMIT;
#check the record is updated SELECT * FROM tab1u;
SELECT * FROM tab1;
c1 c2 c3 c1 c2 c3
1 Updated Updated 1 Updated Updated
check the update_time After Commit, whether it is not NULL SELECT COUNT(update_time)
SELECT table_name,COUNT(update_time) FROM information_schema.tables WHERE table_name='tab1u';
FROM information_schema.tables WHERE table_name='tab1'; COUNT(update_time)
table_name COUNT(update_time) 1
tab1 1 SELECT * FROM tab1d;
#restart the server
# restart
#check the record is existing
SELECT * FROM tab1;
c1 c2 c3 c1 c2 c3
1 Updated Updated 1 Updated Updated
check the update_time Before DML, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1d';
FROM information_schema.tables WHERE table_name='tab1'; update_time
table_name update_time NULL
tab1 NULL
SET AUTOCOMMIT=OFF;
#case3: #case3:
START TRANSACTION; START TRANSACTION;
DELETE FROM tab1; DELETE FROM tab1d;
check the update_time Before commit, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1d';
FROM information_schema.tables WHERE table_name='tab1'; update_time
table_name update_time NULL
tab1 NULL
COMMIT; COMMIT;
#check the record is deleted SELECT * FROM tab1d;
SELECT * FROM tab1;
c1 c2 c3 c1 c2 c3
check the update_time After Commit, whether it is not NULL SELECT COUNT(update_time)
SELECT table_name,COUNT(update_time) FROM information_schema.tables WHERE table_name='tab1d';
FROM information_schema.tables WHERE table_name='tab1'; COUNT(update_time)
table_name COUNT(update_time) 1
tab1 1 SELECT * FROM tab1i;
#restart the server
# restart
#check no records are existing
SELECT * FROM tab1;
c1 c2 c3 c1 c2 c3
check the update_time Before DML, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1i';
FROM information_schema.tables WHERE table_name='tab1'; update_time
table_name update_time NULL
tab1 NULL
SET AUTOCOMMIT=OFF;
#case4: #case4:
START TRANSACTION; START TRANSACTION;
INSERT INTO tab1 INSERT INTO tab1i
VALUES(1,'Testing the wl6658', 'Testing the wl6658'); VALUES(1,'Testing the wl6658', 'Testing the wl6658');
check the update_time Before Rollback, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1i';
FROM information_schema.tables WHERE table_name='tab1'; update_time
table_name update_time NULL
tab1 NULL
ROLLBACK; ROLLBACK;
#check no record is inserted. SELECT * FROM tab1i;
SELECT * FROM tab1;
c1 c2 c3 c1 c2 c3
check the update_time After Rollback, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1i';
FROM information_schema.tables WHERE table_name='tab1'; update_time
table_name update_time NULL
tab1 NULL
CREATE TABLE tab2(
id INT NOT NULL,
store_name VARCHAR(30),
parts VARCHAR(30),
store_id INT
) ENGINE=InnoDB
PARTITION BY LIST(store_id) (
PARTITION pNorth VALUES IN (10,20,30),
PARTITION pEast VALUES IN (40,50,60),
PARTITION pWest VALUES IN (70,80,100)
);
check the update_time Before DML, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab2';
table_name update_time
tab2 NULL
#case5:
#create proc with DML
CREATE PROCEDURE proc_wl6658()
BEGIN
INSERT INTO tab2 VALUES(1,'ORACLE','NUTT',10);
INSERT INTO tab2 VALUES(2,'HUAWEI','BOLT',40);
COMMIT;
END |
CALL proc_wl6658;
#check the records are inserted
SELECT * FROM tab2 ORDER BY id,store_id;
id store_name parts store_id
1 ORACLE NUTT 10
2 HUAWEI BOLT 40
check the update_time After Commit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab2';
table_name COUNT(update_time)
tab2 1
#delete all records
TRUNCATE TABLE tab2;
#restart the server
# restart
#case6:
SET AUTOCOMMIT=off;
BEGIN WORK; BEGIN WORK;
INSERT INTO tab2 VALUES(1,'Oracle','NUTT',10); INSERT INTO tab2 VALUES(1,'Oracle','NUTT',10);
SAVEPOINT A; SAVEPOINT A;
...@@ -198,104 +183,46 @@ SAVEPOINT B; ...@@ -198,104 +183,46 @@ SAVEPOINT B;
INSERT INTO tab2 VALUES(3,'IBM','NAIL',70); INSERT INTO tab2 VALUES(3,'IBM','NAIL',70);
SAVEPOINT C; SAVEPOINT C;
ROLLBACK to A; ROLLBACK to A;
#check 1 record is inserted
SELECT * FROM tab2; SELECT * FROM tab2;
id store_name parts store_id id store_name parts store_id
1 Oracle NUTT 10 1 Oracle NUTT 10
check the update_time Before DML, whether it is NULL SELECT update_time
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab2'; FROM information_schema.tables WHERE table_name='tab2';
table_name update_time update_time
tab2 NULL NULL
#execute DDL instead of commit #execute DDL instead of commit
create table tab6(c1 int); create table tab6(c1 int);
check the update_time After Commit, whether it is not NULL SELECT COUNT(update_time)
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab2'; FROM information_schema.tables WHERE table_name='tab2';
table_name COUNT(update_time) COUNT(update_time)
tab2 1
#case7:
#create some base tables
set the flag to default
SET AUTOCOMMIT=Default;
CREATE TABLE tab7(c1 INT NOT NULL, PRIMARY KEY (c1)) ENGINE=INNODB;
CREATE TABLE tab8(c1 INT PRIMARY KEY,c2 INT,
FOREIGN KEY (c2) REFERENCES tab7(c1) ON DELETE CASCADE )
ENGINE=INNODB;
check the update_time Before DML, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab7';
table_name update_time
tab7 NULL
check the update_time Before DML, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab8';
table_name update_time
tab8 NULL
INSERT INTO tab7 VALUES(1);
INSERT INTO tab8 VALUES(1,1);
#check the record is inserted
SELECT * FROM tab7;
c1
1 1
#check the record is inserted
SELECT * FROM tab8;
c1 c2
1 1
check the update_time After Autocommit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab7';
table_name COUNT(update_time)
tab7 1
check the update_time After Autocommit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab8';
table_name COUNT(update_time)
tab8 1
#restart the server
# restart
SET AUTOCOMMIT=off;
START TRANSACTION; START TRANSACTION;
DELETE FROM tab7; DELETE FROM tab7;
ROLLBACK; ROLLBACK;
#check record exist
SELECT * FROM tab7; SELECT * FROM tab7;
c1 c1
1 1
#check record exist
SELECT * FROM tab8; SELECT * FROM tab8;
c1 c2 c1 c2
1 1 1 1
check the update_time After Rollback, whether it is NULL
SELECT table_name,update_time SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab7'; FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
GROUP BY table_name ORDER BY table_name;
table_name update_time table_name update_time
tab7 NULL tab7 NULL
check the update_time After Rollback, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab8';
table_name update_time
tab8 NULL tab8 NULL
START TRANSACTION;
DELETE FROM tab7; DELETE FROM tab7;
COMMIT;
#check no record exist
SELECT * FROM tab7; SELECT * FROM tab7;
c1 c1
#check no record exist
SELECT * FROM tab8; SELECT * FROM tab8;
c1 c2 c1 c2
check the update_time After Commit, whether it is not NULL
SELECT table_name,COUNT(update_time) SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab7'; FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
GROUP BY table_name ORDER BY table_name;
table_name COUNT(update_time) table_name COUNT(update_time)
tab7 1 tab7 1
check the update_time After Commit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab8';
table_name COUNT(update_time)
tab8 1 tab8 1
#cleanup #cleanup
DROP TRIGGER test_trig; DROP TRIGGER test_trig;
DROP TABLE tab1,tab2,tab3,tab4,tab5,tab6,tab8,tab7; DROP TABLE tab1,tab1u,tab1d,tab1i,tab2,tab3,tab4,tab5,tab6,tab8,tab7;
DROP PROCEDURE proc_wl6658; DROP PROCEDURE proc_wl6658;
...@@ -25,7 +25,7 @@ AND update_time IS NOT NULL; ...@@ -25,7 +25,7 @@ AND update_time IS NOT NULL;
SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't' SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
AND TIMESTAMPDIFF(SECOND, update_time, NOW()) < 120; AND TIMESTAMPDIFF(SECOND, update_time, NOW()) < 120;
CREATE TABLE big (a TEXT) ENGINE=INNODB; CREATE TEMPORARY TABLE big (a TEXT) ENGINE=INNODB;
SELECT COUNT(*) FROM information_schema.innodb_buffer_page SELECT COUNT(*) FROM information_schema.innodb_buffer_page
WHERE table_name = '`test`.`t`'; WHERE table_name = '`test`.`t`';
...@@ -44,7 +44,7 @@ COMMIT; ...@@ -44,7 +44,7 @@ COMMIT;
-- enable_query_log -- enable_query_log
-- echo # INSERT lots of data in table 'big': end -- echo # INSERT lots of data in table 'big': end
# confirm that table 't' has been evicted # confirm that all pages for table 't' have been evicted
SELECT COUNT(*) FROM information_schema.innodb_buffer_page SELECT COUNT(*) FROM information_schema.innodb_buffer_page
WHERE table_name = '`test`.`t`'; WHERE table_name = '`test`.`t`';
...@@ -53,7 +53,7 @@ WHERE table_name = '`test`.`t`'; ...@@ -53,7 +53,7 @@ WHERE table_name = '`test`.`t`';
SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't' SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't'
AND update_time IS NOT NULL; AND update_time IS NOT NULL;
DROP TABLE big; DROP TEMPORARY TABLE big;
-- echo # Test the behavior after restart with a prepared XA transaction -- echo # Test the behavior after restart with a prepared XA transaction
...@@ -63,9 +63,9 @@ XA END 'xatrx'; ...@@ -63,9 +63,9 @@ XA END 'xatrx';
XA PREPARE 'xatrx'; XA PREPARE 'xatrx';
CONNECT (con1,localhost,root,,); CONNECT (con1,localhost,root,,);
CONNECTION con1;
call mtr.add_suppression("Found 1 prepared XA transactions"); call mtr.add_suppression("Found 1 prepared XA transactions");
FLUSH TABLES;
--source include/kill_and_restart_mysqld.inc --source include/kill_and_restart_mysqld.inc
...@@ -73,7 +73,6 @@ SELECT update_time FROM information_schema.tables WHERE table_name = 't'; ...@@ -73,7 +73,6 @@ SELECT update_time FROM information_schema.tables WHERE table_name = 't';
XA COMMIT 'xatrx'; XA COMMIT 'xatrx';
SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 't' SELECT COUNT(update_time) FROM information_schema.tables WHERE table_name='t';
AND update_time IS NOT NULL;
DROP TABLE t; DROP TABLE t;
################################################################### ###################################################################
#Testing functionality of the WL6658 #Testing functionality of the WL6658
#case1: when autocommit off begin work with INSERT with Triggers #case1: begin work with INSERT with Triggers
#case2: when autocommit off begin transaction with UPDATE #case2: (tab1u) begin transaction with UPDATE
#case3: when autocommit off begin transaction with DELETE #case3: (tab1d) begin transaction with DELETE
#case4: when autocommit off Rollback & INSERT #case4: (tab1i) Rollback & INSERT
#case5: when autocommit off with partition table and procedures #case5: (tab2) partitioned table and procedures
#case6: when autocommit off with SAVEPOINTs & DDL #case6: (tab2) SAVEPOINT
#case7: when autocommit off pk-fk with ON DELETE CASCADE #case7: (tab7,tab8) pk-fk with ON DELETE CASCADE
################################################################### ###################################################################
--source include/no_valgrind_without_big.inc --source include/no_valgrind_without_big.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_partition.inc
--source include/not_embedded.inc --source include/not_embedded.inc
--echo #create base table
CREATE TABLE tab1(c1 int,c2 varchar(30), c3 BLOB) ENGINE=InnoDB; CREATE TABLE tab1(c1 int,c2 varchar(30), c3 BLOB) ENGINE=InnoDB;
CREATE TABLE tab1u LIKE tab1;
CREATE TABLE tab1d LIKE tab1;
CREATE TABLE tab1i LIKE tab1;
CREATE TABLE tab3(c1 int,c2 varchar(30)) ENGINE=InnoDB; CREATE TABLE tab3(c1 int,c2 varchar(30)) ENGINE=InnoDB;
CREATE TABLE tab4(c1 int,c2 varchar(30)) ENGINE=InnoDB; CREATE TABLE tab4(c1 int,c2 varchar(30)) ENGINE=InnoDB;
CREATE TABLE tab5(c1 int,c2 varchar(30)) ENGINE=InnoDB; CREATE TABLE tab5(c1 int,c2 varchar(30)) ENGINE=InnoDB;
--echo #insert some base records INSERT INTO tab1u VALUES(1,'Testing the wl6658','Testing the wl6658');
INSERT INTO tab1d VALUES(1,'Updated','Updated');
INSERT INTO tab4 VALUES(1,'Test for Update'); INSERT INTO tab4 VALUES(1,'Test for Update');
INSERT INTO tab5 VALUES(1,'Test for Delete'); INSERT INTO tab5 VALUES(1,'Test for Delete');
delimiter |; delimiter |;
--echo #create a trigger
CREATE TRIGGER test_trig BEFORE INSERT ON tab1 CREATE TRIGGER test_trig BEFORE INSERT ON tab1
FOR EACH ROW BEGIN FOR EACH ROW BEGIN
INSERT INTO tab3 VALUES(1,'Inserted From Trigger'); INSERT INTO tab3 VALUES(1,'Inserted From Trigger');
...@@ -34,15 +37,69 @@ END | ...@@ -34,15 +37,69 @@ END |
delimiter ;| delimiter ;|
CREATE TABLE tab2(
id INT NOT NULL,
store_name VARCHAR(30),
parts VARCHAR(30),
store_id INT
) ENGINE=InnoDB
PARTITION BY LIST(store_id) (
PARTITION pNorth VALUES IN (10,20,30),
PARTITION pEast VALUES IN (40,50,60),
PARTITION pWest VALUES IN (70,80,100)
);
SELECT update_time
FROM information_schema.tables WHERE table_name='tab2';
delimiter |;
CREATE PROCEDURE proc_wl6658()
BEGIN
INSERT INTO tab2 VALUES(1,'ORACLE','NUTT',10);
INSERT INTO tab2 VALUES(2,'HUAWEI','BOLT',40);
COMMIT;
END |
delimiter ;|
CALL proc_wl6658;
SELECT * FROM tab2 ORDER BY id,store_id;
SELECT COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab2';
TRUNCATE TABLE tab2;
SELECT COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab2';
CREATE TABLE tab7(c1 INT NOT NULL, PRIMARY KEY (c1)) ENGINE=INNODB;
CREATE TABLE tab8(c1 INT PRIMARY KEY,c2 INT,
FOREIGN KEY (c2) REFERENCES tab7(c1) ON DELETE CASCADE )
ENGINE=INNODB;
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
GROUP BY table_name ORDER BY table_name;
INSERT INTO tab7 VALUES(1);
INSERT INTO tab8 VALUES(1,1);
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
GROUP BY table_name ORDER BY table_name;
--echo #restart the server --echo #restart the server
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
--echo check the update_time Before DML, whether it is NULL
SELECT table_name,update_time SELECT table_name,update_time
FROM information_schema.tables FROM information_schema.tables
WHERE table_name IN ('tab1','tab3','tab4','tab5'); WHERE table_name IN ('tab1','tab2','tab3','tab4','tab5','tab7','tab8')
ORDER BY table_name;
SET AUTOCOMMIT=OFF;
--echo #case1: --echo #case1:
...@@ -51,172 +108,83 @@ BEGIN WORK; ...@@ -51,172 +108,83 @@ BEGIN WORK;
INSERT INTO tab1 INSERT INTO tab1
VALUES(1,'Testing the wl6658', 'Testing the wl6658'); VALUES(1,'Testing the wl6658', 'Testing the wl6658');
--echo check the update_time Before commit, whether it is NULL SELECT update_time
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab1'; FROM information_schema.tables WHERE table_name='tab1';
COMMIT; COMMIT;
--echo #check the record is inserted
SELECT * FROM tab1; SELECT * FROM tab1;
--echo #check the record is inserted
SELECT * FROM tab3; SELECT * FROM tab3;
--echo #check the record is updated
SELECT * FROM tab4; SELECT * FROM tab4;
--echo #check no record exists
SELECT * FROM tab5; SELECT * FROM tab5;
--echo check the update_time After Commit, whether it is not NULL
--sorted_result
SELECT table_name,COUNT(update_time) SELECT table_name,COUNT(update_time)
FROM information_schema.tables FROM information_schema.tables
WHERE table_name IN ('tab1','tab3','tab4','tab5') WHERE table_name IN ('tab1','tab3','tab4','tab5')
GROUP BY table_name; GROUP BY table_name ORDER BY table_name;
--echo #restart the server
--source include/restart_mysqld.inc
--echo Testcase with UPDATE stmt and transaction --echo Testcase with UPDATE stmt and transaction
--echo #check the record is existing SELECT * FROM tab1u;
SELECT * FROM tab1;
--echo check the update_time Before DML, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab1';
SET AUTOCOMMIT=OFF; SELECT update_time
FROM information_schema.tables WHERE table_name='tab1u';
--echo #case2: --echo #case2:
START TRANSACTION; START TRANSACTION;
UPDATE tab1 SET c2='Updated',c3='Updated' WHERE c1=1; UPDATE tab1u SET c2='Updated',c3='Updated' WHERE c1=1;
--echo check the update_time Before commit, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1u';
FROM information_schema.tables WHERE table_name='tab1';
COMMIT; COMMIT;
--echo #check the record is updated SELECT * FROM tab1u;
SELECT * FROM tab1;
--echo check the update_time After Commit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab1';
--echo #restart the server
--source include/restart_mysqld.inc
--echo #check the record is existing SELECT COUNT(update_time)
SELECT * FROM tab1; FROM information_schema.tables WHERE table_name='tab1u';
--echo check the update_time Before DML, whether it is NULL SELECT * FROM tab1d;
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab1';
SET AUTOCOMMIT=OFF; SELECT update_time
FROM information_schema.tables WHERE table_name='tab1d';
--echo #case3: --echo #case3:
START TRANSACTION; START TRANSACTION;
DELETE FROM tab1; DELETE FROM tab1d;
--echo check the update_time Before commit, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1d';
FROM information_schema.tables WHERE table_name='tab1';
COMMIT; COMMIT;
--echo #check the record is deleted SELECT * FROM tab1d;
SELECT * FROM tab1;
--echo check the update_time After Commit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab1';
--echo #restart the server SELECT COUNT(update_time)
--source include/restart_mysqld.inc FROM information_schema.tables WHERE table_name='tab1d';
--echo #check no records are existing SELECT * FROM tab1i;
SELECT * FROM tab1;
--echo check the update_time Before DML, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1i';
FROM information_schema.tables WHERE table_name='tab1';
SET AUTOCOMMIT=OFF;
--echo #case4: --echo #case4:
START TRANSACTION; START TRANSACTION;
INSERT INTO tab1 INSERT INTO tab1i
VALUES(1,'Testing the wl6658', 'Testing the wl6658'); VALUES(1,'Testing the wl6658', 'Testing the wl6658');
--echo check the update_time Before Rollback, whether it is NULL SELECT update_time
SELECT table_name,update_time FROM information_schema.tables WHERE table_name='tab1i';
FROM information_schema.tables WHERE table_name='tab1';
ROLLBACK; ROLLBACK;
--echo #check no record is inserted. SELECT * FROM tab1i;
SELECT * FROM tab1;
--echo check the update_time After Rollback, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab1';
CREATE TABLE tab2(
id INT NOT NULL,
store_name VARCHAR(30),
parts VARCHAR(30),
store_id INT
) ENGINE=InnoDB
PARTITION BY LIST(store_id) (
PARTITION pNorth VALUES IN (10,20,30),
PARTITION pEast VALUES IN (40,50,60),
PARTITION pWest VALUES IN (70,80,100)
);
--echo check the update_time Before DML, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab2';
--echo #case5:
delimiter |;
--echo #create proc with DML
CREATE PROCEDURE proc_wl6658()
BEGIN
INSERT INTO tab2 VALUES(1,'ORACLE','NUTT',10);
INSERT INTO tab2 VALUES(2,'HUAWEI','BOLT',40);
COMMIT;
END |
delimiter ;|
CALL proc_wl6658;
--echo #check the records are inserted
SELECT * FROM tab2 ORDER BY id,store_id;
--echo check the update_time After Commit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab2';
--echo #delete all records
TRUNCATE TABLE tab2;
--echo #restart the server
--source include/restart_mysqld.inc
--echo #case6:
SET AUTOCOMMIT=off; SELECT update_time
FROM information_schema.tables WHERE table_name='tab1i';
BEGIN WORK; BEGIN WORK;
INSERT INTO tab2 VALUES(1,'Oracle','NUTT',10); INSERT INTO tab2 VALUES(1,'Oracle','NUTT',10);
...@@ -227,104 +195,37 @@ INSERT INTO tab2 VALUES(3,'IBM','NAIL',70); ...@@ -227,104 +195,37 @@ INSERT INTO tab2 VALUES(3,'IBM','NAIL',70);
SAVEPOINT C; SAVEPOINT C;
ROLLBACK to A; ROLLBACK to A;
--echo #check 1 record is inserted
SELECT * FROM tab2; SELECT * FROM tab2;
--echo check the update_time Before DML, whether it is NULL SELECT update_time
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab2'; FROM information_schema.tables WHERE table_name='tab2';
--echo #execute DDL instead of commit --echo #execute DDL instead of commit
create table tab6(c1 int); create table tab6(c1 int);
--echo check the update_time After Commit, whether it is not NULL SELECT COUNT(update_time)
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab2'; FROM information_schema.tables WHERE table_name='tab2';
--echo #case7:
--echo #create some base tables
--echo set the flag to default
SET AUTOCOMMIT=Default;
CREATE TABLE tab7(c1 INT NOT NULL, PRIMARY KEY (c1)) ENGINE=INNODB;
CREATE TABLE tab8(c1 INT PRIMARY KEY,c2 INT,
FOREIGN KEY (c2) REFERENCES tab7(c1) ON DELETE CASCADE )
ENGINE=INNODB;
--echo check the update_time Before DML, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab7';
--echo check the update_time Before DML, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab8';
INSERT INTO tab7 VALUES(1);
INSERT INTO tab8 VALUES(1,1);
--echo #check the record is inserted
SELECT * FROM tab7;
--echo #check the record is inserted
SELECT * FROM tab8;
--echo check the update_time After Autocommit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab7';
--echo check the update_time After Autocommit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab8';
--echo #restart the server
--source include/restart_mysqld.inc
SET AUTOCOMMIT=off;
START TRANSACTION; START TRANSACTION;
DELETE FROM tab7; DELETE FROM tab7;
ROLLBACK; ROLLBACK;
--echo #check record exist
SELECT * FROM tab7; SELECT * FROM tab7;
--echo #check record exist
SELECT * FROM tab8; SELECT * FROM tab8;
--echo check the update_time After Rollback, whether it is NULL
SELECT table_name,update_time SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab7'; FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
GROUP BY table_name ORDER BY table_name;
--echo check the update_time After Rollback, whether it is NULL
SELECT table_name,update_time
FROM information_schema.tables WHERE table_name='tab8';
START TRANSACTION;
DELETE FROM tab7; DELETE FROM tab7;
COMMIT;
--echo #check no record exist
SELECT * FROM tab7; SELECT * FROM tab7;
--echo #check no record exist
SELECT * FROM tab8; SELECT * FROM tab8;
--echo check the update_time After Commit, whether it is not NULL
SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab7';
--echo check the update_time After Commit, whether it is not NULL
SELECT table_name,COUNT(update_time) SELECT table_name,COUNT(update_time)
FROM information_schema.tables WHERE table_name='tab8'; FROM information_schema.tables WHERE table_name IN ('tab7','tab8')
GROUP BY table_name ORDER BY table_name;
--echo #cleanup --echo #cleanup
DROP TRIGGER test_trig; DROP TRIGGER test_trig;
DROP TABLE tab1,tab2,tab3,tab4,tab5,tab6,tab8,tab7; DROP TABLE tab1,tab1u,tab1d,tab1i,tab2,tab3,tab4,tab5,tab6,tab8,tab7;
DROP PROCEDURE proc_wl6658; DROP PROCEDURE proc_wl6658;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment