mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
Merge bk-internal.mysql.com:/home/bk/mysql-5.1-engines
into bodhi.(none):/opt/local/work/mysql-5.1-runtime mysql-test/include/mix1.inc: Auto merged mysql-test/r/innodb_mysql.result: Auto merged
This commit is contained in:
@@ -222,9 +222,6 @@ t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS';
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 4.1 tests
|
||||
|
||||
|
||||
#
|
||||
# Bug #12882 min/max inconsistent on empty table
|
||||
#
|
||||
@@ -423,24 +420,6 @@ SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#
|
||||
# Bug#22781: SQL_BIG_RESULT fails to influence sort plan
|
||||
#
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB;
|
||||
|
||||
INSERT INTO t1 VALUES ( 1 , 1 , 1);
|
||||
INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1;
|
||||
|
||||
EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b;
|
||||
EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#26159: crash for a loose scan of a table that has been emptied
|
||||
#
|
||||
@@ -501,40 +480,6 @@ set global query_cache_size=@save_qcache_size;
|
||||
|
||||
--source include/innodb_rollback_on_timeout.inc
|
||||
|
||||
#
|
||||
# Bug #27210: INNODB ON DUPLICATE KEY UPDATE
|
||||
#
|
||||
|
||||
set @save_qcache_size=@@global.query_cache_size;
|
||||
set @save_qcache_type=@@global.query_cache_type;
|
||||
set global query_cache_size=10*1024*1024;
|
||||
set global query_cache_type=1;
|
||||
connect (con1,localhost,root,,);
|
||||
connection con1;
|
||||
drop table if exists `test`;
|
||||
CREATE TABLE `test` (`test1` varchar(3) NOT NULL,
|
||||
`test2` varchar(4) NOT NULL,PRIMARY KEY (`test1`))
|
||||
ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '5678');
|
||||
disconnect con1;
|
||||
connect (con2,localhost,root,,);
|
||||
connection con2;
|
||||
select * from test;
|
||||
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '1234')
|
||||
ON DUPLICATE KEY UPDATE `test2` = '1234';
|
||||
select * from test;
|
||||
flush tables;
|
||||
select * from test;
|
||||
disconnect con2;
|
||||
connection default;
|
||||
drop table test;
|
||||
set global query_cache_type=@save_qcache_type;
|
||||
set global query_cache_size=@save_qcache_size;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
-- source include/have_innodb.inc
|
||||
|
||||
#
|
||||
# Bug #27650: INSERT fails after multi-row INSERT of the form:
|
||||
# INSERT INTO t (id...) VALUES (NULL...) ON DUPLICATE KEY UPDATE id=VALUES(id)
|
||||
@@ -720,7 +665,6 @@ DISCONNECT c1;
|
||||
DISCONNECT c2;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
|
||||
#
|
||||
# Bug #25798: a query with forced index merge returns wrong result
|
||||
#
|
||||
@@ -778,9 +722,6 @@ set @@sort_buffer_size=default;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
#
|
||||
# Test of behaviour with CREATE ... SELECT
|
||||
#
|
||||
@@ -858,6 +799,21 @@ DROP TABLE t1;
|
||||
|
||||
--source include/innodb_rollback_on_timeout.inc
|
||||
|
||||
#
|
||||
# Bug#27296 Assertion in ALTER TABLE SET DEFAULT in Linux Debug build
|
||||
# (possible deadlock).
|
||||
#
|
||||
# The bug is applicable only to a transactoinal table.
|
||||
# Cover with tests behavior that no longer causes an
|
||||
# assertion.
|
||||
#
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (a int) engine=innodb;
|
||||
alter table t1 alter a set default 1;
|
||||
drop table t1;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
|
||||
|
@@ -31,7 +31,7 @@ create event e_55 on schedule at 10000101000000 do drop table t;
|
||||
ERROR HY000: Incorrect AT value: '10000101000000'
|
||||
create event e_55 on schedule at 20000101000000 do drop table t;
|
||||
Warnings:
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been created
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
|
||||
show events;
|
||||
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
|
||||
create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t;
|
||||
@@ -447,32 +447,32 @@ e3 +00:00 CREATE EVENT `e3` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00
|
||||
The following should fail, and nothing should be altered.
|
||||
ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
|
||||
ENDS '1999-01-02 00:00:00';
|
||||
ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been altered
|
||||
ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
|
||||
ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
|
||||
ENDS '1999-01-02 00:00:00' DISABLE;
|
||||
ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been altered
|
||||
ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
|
||||
The following should give warnings, and nothing should be created.
|
||||
CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
|
||||
ENDS '1999-01-02 00:00:00'
|
||||
DO
|
||||
SELECT 1;
|
||||
Warnings:
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been created
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
|
||||
CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'
|
||||
ENDS '1999-01-02 00:00:00' DISABLE
|
||||
DO
|
||||
SELECT 1;
|
||||
Warnings:
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been created
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
|
||||
CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DO
|
||||
SELECT 1;
|
||||
Warnings:
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been created
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
|
||||
CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DISABLE
|
||||
DO
|
||||
SELECT 1;
|
||||
Warnings:
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been created
|
||||
Note 1585 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
|
||||
SHOW EVENTS;
|
||||
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
|
||||
events_test e1 root@localhost +05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
|
||||
|
@@ -1066,7 +1066,7 @@ c int(11) YES NULL
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
alter database information_schema;
|
||||
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
||||
drop database information_schema;
|
||||
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
|
||||
drop table information_schema.tables;
|
||||
@@ -1412,6 +1412,10 @@ v2 YES
|
||||
delete from v1;
|
||||
drop view v1,v2;
|
||||
drop table t1,t2;
|
||||
alter database;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
||||
alter database test;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
||||
End of 5.0 tests.
|
||||
select * from information_schema.engines WHERE ENGINE="MyISAM";
|
||||
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
|
||||
|
@@ -166,7 +166,6 @@ t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
DROP TABLE t1;
|
||||
End of 4.1 tests
|
||||
create table t1m (a int) engine = MEMORY;
|
||||
create table t1i (a int);
|
||||
create table t2m (a int) engine = MEMORY;
|
||||
@@ -362,22 +361,6 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB;
|
||||
INSERT INTO t1 VALUES ( 1 , 1 , 1);
|
||||
INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1;
|
||||
EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL b 5 NULL 128
|
||||
EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
id int NOT NULL,
|
||||
name varchar(20) NOT NULL,
|
||||
@@ -503,33 +486,6 @@ a
|
||||
2
|
||||
5
|
||||
drop table t1;
|
||||
set @save_qcache_size=@@global.query_cache_size;
|
||||
set @save_qcache_type=@@global.query_cache_type;
|
||||
set global query_cache_size=10*1024*1024;
|
||||
set global query_cache_type=1;
|
||||
drop table if exists `test`;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 'test'
|
||||
CREATE TABLE `test` (`test1` varchar(3) NOT NULL,
|
||||
`test2` varchar(4) NOT NULL,PRIMARY KEY (`test1`))
|
||||
ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '5678');
|
||||
select * from test;
|
||||
test1 test2
|
||||
tes 5678
|
||||
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '1234')
|
||||
ON DUPLICATE KEY UPDATE `test2` = '1234';
|
||||
select * from test;
|
||||
test1 test2
|
||||
tes 1234
|
||||
flush tables;
|
||||
select * from test;
|
||||
test1 test2
|
||||
tes 1234
|
||||
drop table test;
|
||||
set global query_cache_type=@save_qcache_type;
|
||||
set global query_cache_size=@save_qcache_size;
|
||||
End of 5.0 tests
|
||||
create table t1(
|
||||
id int auto_increment,
|
||||
c char(1) not null,
|
||||
@@ -739,7 +695,6 @@ COUNT(*)
|
||||
3072
|
||||
set @@sort_buffer_size=default;
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.0 tests
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
insert into t1 values (1,1),(1,2);
|
||||
CREATE TABLE t2 (primary key (a)) select * from t1;
|
||||
@@ -855,6 +810,10 @@ a
|
||||
2
|
||||
5
|
||||
drop table t1;
|
||||
drop table if exists t1;
|
||||
create table t1 (a int) engine=innodb;
|
||||
alter table t1 alter a set default 1;
|
||||
drop table t1;
|
||||
End of 5.0 tests
|
||||
CREATE TABLE `t2` (
|
||||
`k` int(11) NOT NULL auto_increment,
|
||||
|
@@ -1301,6 +1301,7 @@ drop procedure f3;
|
||||
drop procedure f4;
|
||||
drop table t1;
|
||||
set GLOBAL query_cache_size=0;
|
||||
End of 4.1 tests
|
||||
SET GLOBAL query_cache_size=102400;
|
||||
create table t1(a int);
|
||||
insert into t1 values(0), (1), (4), (5);
|
||||
@@ -1495,6 +1496,46 @@ insert into t1 values ('c');
|
||||
a
|
||||
drop table t1;
|
||||
set GLOBAL query_cache_size= default;
|
||||
Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock
|
||||
set GLOBAL query_cache_type=1;
|
||||
set GLOBAL query_cache_limit=10000;
|
||||
set GLOBAL query_cache_min_res_unit=0;
|
||||
set GLOBAL query_cache_size= 100000;
|
||||
flush tables;
|
||||
drop table if exists t1, t2;
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
Locking table T2 with a write lock.
|
||||
lock table t2 write;
|
||||
Select blocked by write lock.
|
||||
select *, (select count(*) from t2) from t1;;
|
||||
Sleeing is ok, because selecting should be done very fast.
|
||||
Inserting into table T1.
|
||||
insert into t1 values (4);
|
||||
Unlocking the tables.
|
||||
unlock tables;
|
||||
Collecting result from previously blocked select.
|
||||
Next select should contain 4 rows, as the insert is long finished.
|
||||
select *, (select count(*) from t2) from t1;
|
||||
a (select count(*) from t2)
|
||||
1 0
|
||||
2 0
|
||||
3 0
|
||||
4 0
|
||||
reset query cache;
|
||||
select *, (select count(*) from t2) from t1;
|
||||
a (select count(*) from t2)
|
||||
1 0
|
||||
2 0
|
||||
3 0
|
||||
4 0
|
||||
drop table t1,t2;
|
||||
set GLOBAL query_cache_type=default;
|
||||
set GLOBAL query_cache_limit=default;
|
||||
set GLOBAL query_cache_min_res_unit=default;
|
||||
set GLOBAL query_cache_size=default;
|
||||
End of 5.0 tests
|
||||
drop database if exists db1;
|
||||
drop database if exists db2;
|
||||
set GLOBAL query_cache_size=15*1024*1024;
|
||||
@@ -1543,3 +1584,4 @@ Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
drop database db2;
|
||||
drop database db3;
|
||||
End of 5.1 tests
|
||||
|
@@ -1312,4 +1312,43 @@ t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR E
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE p1;
|
||||
DEALLOCATE PREPARE stmt1;
|
||||
set names koi8r;
|
||||
DROP VIEW IF EXISTS v1;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP EVENT IF EXISTS ev1;
|
||||
CREATE VIEW v1 AS SELECT '<27><><EFBFBD><EFBFBD>' AS test;
|
||||
CREATE PROCEDURE p1() SELECT '<27><><EFBFBD><EFBFBD>' AS test;
|
||||
CREATE FUNCTION f1() RETURNS CHAR(10) RETURN '<27><><EFBFBD><EFBFBD>';
|
||||
CREATE TABLE t1(c1 CHAR(10));
|
||||
CREATE TRIGGER t1_bi BEFORE INSERT ON t1
|
||||
FOR EACH ROW
|
||||
SET NEW.c1 = '<27><><EFBFBD><EFBFBD>';
|
||||
CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO SELECT '<27><><EFBFBD><EFBFBD>' AS test;
|
||||
set names utf8;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _koi8r'тест' AS `test` koi8r koi8r_general_ci
|
||||
SHOW CREATE PROCEDURE p1;
|
||||
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
|
||||
p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
|
||||
SELECT 'тест' AS test koi8r koi8r_general_ci latin1_swedish_ci
|
||||
SHOW CREATE FUNCTION f1;
|
||||
Function sql_mode Create Function character_set_client collation_connection Database Collation
|
||||
f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS char(10) CHARSET latin1
|
||||
RETURN 'тест' koi8r koi8r_general_ci latin1_swedish_ci
|
||||
SHOW CREATE TRIGGER t1_bi;
|
||||
Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
|
||||
t1_bi CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1
|
||||
FOR EACH ROW
|
||||
SET NEW.c1 = 'тест' koi8r koi8r_general_ci latin1_swedish_ci
|
||||
SHOW CREATE EVENT ev1;
|
||||
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
|
||||
ev1 SYSTEM CREATE EVENT `ev1` ON SCHEDULE AT '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 'тест' AS test koi8r koi8r_general_ci latin1_swedish_ci
|
||||
DROP VIEW v1;
|
||||
DROP PROCEDURE p1;
|
||||
DROP FUNCTION f1;
|
||||
DROP TABLE t1;
|
||||
DROP EVENT ev1;
|
||||
End of 5.1 tests
|
||||
|
@@ -6281,6 +6281,31 @@ v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI
|
||||
DROP VIEW v1;
|
||||
DROP FUNCTION metered;
|
||||
DROP TABLE t1;
|
||||
drop database if exists mysqltest_db1;
|
||||
create database mysqltest_db1;
|
||||
create procedure mysqltest_db1.sp_bug28551() begin end;
|
||||
call mysqltest_db1.sp_bug28551();
|
||||
show warnings;
|
||||
Level Code Message
|
||||
drop database mysqltest_db1;
|
||||
drop database if exists mysqltest_db1;
|
||||
drop table if exists test.t1;
|
||||
create database mysqltest_db1;
|
||||
use mysqltest_db1;
|
||||
drop database mysqltest_db1;
|
||||
create table test.t1 (id int);
|
||||
insert into test.t1 (id) values (1);
|
||||
create procedure test.sp_bug29050() begin select * from t1; end//
|
||||
show warnings;
|
||||
Level Code Message
|
||||
call test.sp_bug29050();
|
||||
id
|
||||
1
|
||||
show warnings;
|
||||
Level Code Message
|
||||
use test;
|
||||
drop procedure sp_bug29050;
|
||||
drop table t1;
|
||||
drop procedure if exists proc_25411_a;
|
||||
drop procedure if exists proc_25411_b;
|
||||
drop procedure if exists proc_25411_c;
|
||||
|
@@ -82,3 +82,62 @@ ALICE 33 1 0
|
||||
THE CROWN 43 1 0
|
||||
THE PIE 53 1 1
|
||||
drop table t1;
|
||||
|
||||
Bug#26141 mixing table types in trigger causes full
|
||||
table lock on innodb table
|
||||
|
||||
Ensure we do not open and lock tables for the triggers we do not
|
||||
fire.
|
||||
|
||||
drop table if exists t1, t2, t3;
|
||||
drop trigger if exists trg_bug26141_au;
|
||||
drop trigger if exists trg_bug26141_ai;
|
||||
create table t1 (c int primary key) engine=innodb;
|
||||
create table t2 (c int) engine=myisam;
|
||||
create table t3 (c int) engine=myisam;
|
||||
insert into t1 (c) values (1);
|
||||
create trigger trg_bug26141_ai after insert on t1
|
||||
for each row
|
||||
begin
|
||||
insert into t2 (c) values (1);
|
||||
# We need the 'sync' lock to synchronously wait in connection 2 till
|
||||
# the moment when the trigger acquired all the locks.
|
||||
select release_lock("lock_bug26141_sync") into @a;
|
||||
# 1000 is time in seconds of lock wait timeout -- this is a way
|
||||
# to cause a manageable sleep up to 1000 seconds
|
||||
select get_lock("lock_bug26141_wait", 1000) into @a;
|
||||
end|
|
||||
create trigger trg_bug26141_au after update on t1
|
||||
for each row
|
||||
begin
|
||||
insert into t3 (c) values (1);
|
||||
end|
|
||||
select get_lock("lock_bug26141_wait", 0);
|
||||
get_lock("lock_bug26141_wait", 0)
|
||||
1
|
||||
select get_lock("lock_bug26141_sync", /* must not be priorly locked */ 0);
|
||||
get_lock("lock_bug26141_sync", /* must not be priorly locked */ 0)
|
||||
1
|
||||
insert into t1 (c) values (2);
|
||||
select get_lock("lock_bug26141_sync", 1000);
|
||||
get_lock("lock_bug26141_sync", 1000)
|
||||
1
|
||||
update t1 set c=3 where c=1;
|
||||
select release_lock("lock_bug26141_sync");
|
||||
release_lock("lock_bug26141_sync")
|
||||
1
|
||||
select release_lock("lock_bug26141_wait");
|
||||
release_lock("lock_bug26141_wait")
|
||||
1
|
||||
select * from t1;
|
||||
c
|
||||
2
|
||||
3
|
||||
select * from t2;
|
||||
c
|
||||
1
|
||||
select * from t3;
|
||||
c
|
||||
1
|
||||
drop table t1, t2, t3;
|
||||
End of 5.0 tests
|
||||
|
@@ -351,7 +351,7 @@ create trigger trg1 before insert on mysqltest.t1 for each row set @a:= 1;
|
||||
ERROR HY000: Trigger in wrong schema
|
||||
use mysqltest;
|
||||
create trigger test.trg1 before insert on t1 for each row set @a:= 1;
|
||||
ERROR HY000: Trigger in wrong schema
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
drop database mysqltest;
|
||||
use test;
|
||||
create table t1 (i int, j int default 10, k int not null, key (k));
|
||||
@@ -842,7 +842,7 @@ drop table t1;
|
||||
create trigger t1_bi before insert on test.t1 for each row set @a:=0;
|
||||
ERROR 3D000: No database selected
|
||||
create trigger test.t1_bi before insert on t1 for each row set @a:=0;
|
||||
ERROR 3D000: No database selected
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
drop trigger t1_bi;
|
||||
ERROR 3D000: No database selected
|
||||
create table t1 (id int);
|
||||
@@ -1476,6 +1476,463 @@ DROP TRIGGER t1_test;
|
||||
DROP TABLE t1,t2;
|
||||
SET SESSION LOW_PRIORITY_UPDATES=DEFAULT;
|
||||
SET GLOBAL LOW_PRIORITY_UPDATES=DEFAULT;
|
||||
|
||||
Bug#28502 Triggers that update another innodb table will block
|
||||
on X lock unnecessarily
|
||||
|
||||
Ensure we do not open and lock tables for triggers we do not fire.
|
||||
|
||||
drop table if exists t1, t2;
|
||||
drop trigger if exists trg_bug28502_au;
|
||||
create table t1 (id int, count int);
|
||||
create table t2 (id int);
|
||||
create trigger trg_bug28502_au before update on t2
|
||||
for each row
|
||||
begin
|
||||
if (new.id is not null) then
|
||||
update t1 set count= count + 1 where id = old.id;
|
||||
end if;
|
||||
end|
|
||||
insert into t1 (id, count) values (1, 0);
|
||||
lock table t1 write;
|
||||
insert into t2 set id=1;
|
||||
unlock tables;
|
||||
update t2 set id=1 where id=1;
|
||||
select * from t1;
|
||||
id count
|
||||
1 1
|
||||
select * from t2;
|
||||
id
|
||||
1
|
||||
drop table t1, t2;
|
||||
|
||||
Additionally, provide test coverage for triggers and
|
||||
all MySQL data changing commands.
|
||||
|
||||
drop table if exists t1, t2, t1_op_log;
|
||||
drop view if exists v1;
|
||||
drop trigger if exists trg_bug28502_bi;
|
||||
drop trigger if exists trg_bug28502_ai;
|
||||
drop trigger if exists trg_bug28502_bu;
|
||||
drop trigger if exists trg_bug28502_au;
|
||||
drop trigger if exists trg_bug28502_bd;
|
||||
drop trigger if exists trg_bug28502_ad;
|
||||
create table t1 (id int primary key auto_increment, operation varchar(255));
|
||||
create table t2 (id int primary key);
|
||||
create table t1_op_log(operation varchar(255));
|
||||
create view v1 as select * from t1;
|
||||
create trigger trg_bug28502_bi before insert on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("Before INSERT, new=", new.operation));
|
||||
create trigger trg_bug28502_ai after insert on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("After INSERT, new=", new.operation));
|
||||
create trigger trg_bug28502_bu before update on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("Before UPDATE, new=", new.operation,
|
||||
", old=", old.operation));
|
||||
create trigger trg_bug28502_au after update on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("After UPDATE, new=", new.operation,
|
||||
", old=", old.operation));
|
||||
create trigger trg_bug28502_bd before delete on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("Before DELETE, old=", old.operation));
|
||||
create trigger trg_bug28502_ad after delete on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("After DELETE, old=", old.operation));
|
||||
insert into t1 (operation) values ("INSERT");
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 INSERT
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT
|
||||
After INSERT, new=INSERT
|
||||
truncate t1_op_log;
|
||||
update t1 set operation="UPDATE" where id=@id;
|
||||
select * from t1;
|
||||
id operation
|
||||
1 UPDATE
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before UPDATE, new=UPDATE, old=INSERT
|
||||
After UPDATE, new=UPDATE, old=INSERT
|
||||
truncate t1_op_log;
|
||||
delete from t1 where id=@id;
|
||||
select * from t1;
|
||||
id operation
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before DELETE, old=UPDATE
|
||||
After DELETE, old=UPDATE
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
insert into t1 (id, operation) values
|
||||
(NULL, "INSERT ON DUPLICATE KEY UPDATE, inserting a new key")
|
||||
on duplicate key update id=NULL, operation="Should never happen";
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
After INSERT, new=INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
truncate t1_op_log;
|
||||
insert into t1 (id, operation) values
|
||||
(@id, "INSERT ON DUPLICATE KEY UPDATE, the key value is the same")
|
||||
on duplicate key update id=NULL,
|
||||
operation="INSERT ON DUPLICATE KEY UPDATE, updating the duplicate";
|
||||
select * from t1;
|
||||
id operation
|
||||
0 INSERT ON DUPLICATE KEY UPDATE, updating the duplicate
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT ON DUPLICATE KEY UPDATE, the key value is the same
|
||||
Before UPDATE, new=INSERT ON DUPLICATE KEY UPDATE, updating the duplicate, old=INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
After UPDATE, new=INSERT ON DUPLICATE KEY UPDATE, updating the duplicate, old=INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
replace into t1 values (NULL, "REPLACE, inserting a new key");
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 REPLACE, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=REPLACE, inserting a new key
|
||||
After INSERT, new=REPLACE, inserting a new key
|
||||
truncate t1_op_log;
|
||||
replace into t1 values (@id, "REPLACE, deleting the duplicate");
|
||||
select * from t1;
|
||||
id operation
|
||||
1 REPLACE, deleting the duplicate
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=REPLACE, deleting the duplicate
|
||||
Before DELETE, old=REPLACE, inserting a new key
|
||||
After DELETE, old=REPLACE, inserting a new key
|
||||
After INSERT, new=REPLACE, deleting the duplicate
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
create table if not exists t1
|
||||
select NULL, "CREATE TABLE ... SELECT, inserting a new key";
|
||||
Warnings:
|
||||
Note 1050 Table 't1' already exists
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 CREATE TABLE ... SELECT, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=CREATE TABLE ... SELECT, inserting a new key
|
||||
After INSERT, new=CREATE TABLE ... SELECT, inserting a new key
|
||||
truncate t1_op_log;
|
||||
create table if not exists t1 replace
|
||||
select @id, "CREATE TABLE ... REPLACE SELECT, deleting a duplicate key";
|
||||
Warnings:
|
||||
Note 1050 Table 't1' already exists
|
||||
select * from t1;
|
||||
id operation
|
||||
1 CREATE TABLE ... REPLACE SELECT, deleting a duplicate key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=CREATE TABLE ... REPLACE SELECT, deleting a duplicate key
|
||||
Before DELETE, old=CREATE TABLE ... SELECT, inserting a new key
|
||||
After DELETE, old=CREATE TABLE ... SELECT, inserting a new key
|
||||
After INSERT, new=CREATE TABLE ... REPLACE SELECT, deleting a duplicate key
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
insert into t1 (id, operation)
|
||||
select NULL, "INSERT ... SELECT, inserting a new key";
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 INSERT ... SELECT, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT ... SELECT, inserting a new key
|
||||
After INSERT, new=INSERT ... SELECT, inserting a new key
|
||||
truncate t1_op_log;
|
||||
insert into t1 (id, operation)
|
||||
select @id,
|
||||
"INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate"
|
||||
on duplicate key update id=NULL,
|
||||
operation="INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate";
|
||||
select * from t1;
|
||||
id operation
|
||||
0 INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate
|
||||
Before UPDATE, new=INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate, old=INSERT ... SELECT, inserting a new key
|
||||
After UPDATE, new=INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate, old=INSERT ... SELECT, inserting a new key
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
replace into t1 (id, operation)
|
||||
select NULL, "REPLACE ... SELECT, inserting a new key";
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 REPLACE ... SELECT, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=REPLACE ... SELECT, inserting a new key
|
||||
After INSERT, new=REPLACE ... SELECT, inserting a new key
|
||||
truncate t1_op_log;
|
||||
replace into t1 (id, operation)
|
||||
select @id, "REPLACE ... SELECT, deleting a duplicate";
|
||||
select * from t1;
|
||||
id operation
|
||||
1 REPLACE ... SELECT, deleting a duplicate
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=REPLACE ... SELECT, deleting a duplicate
|
||||
Before DELETE, old=REPLACE ... SELECT, inserting a new key
|
||||
After DELETE, old=REPLACE ... SELECT, inserting a new key
|
||||
After INSERT, new=REPLACE ... SELECT, deleting a duplicate
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
insert into t1 (id, operation) values (1, "INSERT for multi-DELETE");
|
||||
insert into t2 (id) values (1);
|
||||
delete t1.*, t2.* from t1, t2 where t1.id=1;
|
||||
select * from t1;
|
||||
id operation
|
||||
select * from t2;
|
||||
id
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT for multi-DELETE
|
||||
After INSERT, new=INSERT for multi-DELETE
|
||||
Before DELETE, old=INSERT for multi-DELETE
|
||||
After DELETE, old=INSERT for multi-DELETE
|
||||
truncate t1;
|
||||
truncate t2;
|
||||
truncate t1_op_log;
|
||||
insert into t1 (id, operation) values (1, "INSERT for multi-UPDATE");
|
||||
insert into t2 (id) values (1);
|
||||
update t1, t2 set t1.id=2, operation="multi-UPDATE" where t1.id=1;
|
||||
update t1, t2
|
||||
set t2.id=3, operation="multi-UPDATE, SET for t2, but the trigger is fired" where t1.id=2;
|
||||
select * from t1;
|
||||
id operation
|
||||
2 multi-UPDATE, SET for t2, but the trigger is fired
|
||||
select * from t2;
|
||||
id
|
||||
3
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT for multi-UPDATE
|
||||
After INSERT, new=INSERT for multi-UPDATE
|
||||
Before UPDATE, new=multi-UPDATE, old=INSERT for multi-UPDATE
|
||||
After UPDATE, new=multi-UPDATE, old=INSERT for multi-UPDATE
|
||||
Before UPDATE, new=multi-UPDATE, SET for t2, but the trigger is fired, old=multi-UPDATE
|
||||
After UPDATE, new=multi-UPDATE, SET for t2, but the trigger is fired, old=multi-UPDATE
|
||||
truncate table t1;
|
||||
truncate table t2;
|
||||
truncate table t1_op_log;
|
||||
|
||||
Now do the same but use a view instead of the base table.
|
||||
|
||||
insert into v1 (operation) values ("INSERT");
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 INSERT
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT
|
||||
After INSERT, new=INSERT
|
||||
truncate t1_op_log;
|
||||
update v1 set operation="UPDATE" where id=@id;
|
||||
select * from t1;
|
||||
id operation
|
||||
1 UPDATE
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before UPDATE, new=UPDATE, old=INSERT
|
||||
After UPDATE, new=UPDATE, old=INSERT
|
||||
truncate t1_op_log;
|
||||
delete from v1 where id=@id;
|
||||
select * from t1;
|
||||
id operation
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before DELETE, old=UPDATE
|
||||
After DELETE, old=UPDATE
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
insert into v1 (id, operation) values
|
||||
(NULL, "INSERT ON DUPLICATE KEY UPDATE, inserting a new key")
|
||||
on duplicate key update id=NULL, operation="Should never happen";
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
After INSERT, new=INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
truncate t1_op_log;
|
||||
insert into v1 (id, operation) values
|
||||
(@id, "INSERT ON DUPLICATE KEY UPDATE, the key value is the same")
|
||||
on duplicate key update id=NULL,
|
||||
operation="INSERT ON DUPLICATE KEY UPDATE, updating the duplicate";
|
||||
select * from t1;
|
||||
id operation
|
||||
0 INSERT ON DUPLICATE KEY UPDATE, updating the duplicate
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT ON DUPLICATE KEY UPDATE, the key value is the same
|
||||
Before UPDATE, new=INSERT ON DUPLICATE KEY UPDATE, updating the duplicate, old=INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
After UPDATE, new=INSERT ON DUPLICATE KEY UPDATE, updating the duplicate, old=INSERT ON DUPLICATE KEY UPDATE, inserting a new key
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
replace into v1 values (NULL, "REPLACE, inserting a new key");
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 REPLACE, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=REPLACE, inserting a new key
|
||||
After INSERT, new=REPLACE, inserting a new key
|
||||
truncate t1_op_log;
|
||||
replace into v1 values (@id, "REPLACE, deleting the duplicate");
|
||||
select * from t1;
|
||||
id operation
|
||||
1 REPLACE, deleting the duplicate
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=REPLACE, deleting the duplicate
|
||||
Before DELETE, old=REPLACE, inserting a new key
|
||||
After DELETE, old=REPLACE, inserting a new key
|
||||
After INSERT, new=REPLACE, deleting the duplicate
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
create table if not exists v1
|
||||
select NULL, "CREATE TABLE ... SELECT, inserting a new key";
|
||||
Warnings:
|
||||
Note 1050 Table 'v1' already exists
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 CREATE TABLE ... SELECT, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=CREATE TABLE ... SELECT, inserting a new key
|
||||
After INSERT, new=CREATE TABLE ... SELECT, inserting a new key
|
||||
truncate t1_op_log;
|
||||
create table if not exists v1 replace
|
||||
select @id, "CREATE TABLE ... REPLACE SELECT, deleting a duplicate key";
|
||||
Warnings:
|
||||
Note 1050 Table 'v1' already exists
|
||||
select * from t1;
|
||||
id operation
|
||||
1 CREATE TABLE ... REPLACE SELECT, deleting a duplicate key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=CREATE TABLE ... REPLACE SELECT, deleting a duplicate key
|
||||
Before DELETE, old=CREATE TABLE ... SELECT, inserting a new key
|
||||
After DELETE, old=CREATE TABLE ... SELECT, inserting a new key
|
||||
After INSERT, new=CREATE TABLE ... REPLACE SELECT, deleting a duplicate key
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
insert into v1 (id, operation)
|
||||
select NULL, "INSERT ... SELECT, inserting a new key";
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 INSERT ... SELECT, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT ... SELECT, inserting a new key
|
||||
After INSERT, new=INSERT ... SELECT, inserting a new key
|
||||
truncate t1_op_log;
|
||||
insert into v1 (id, operation)
|
||||
select @id,
|
||||
"INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate"
|
||||
on duplicate key update id=NULL,
|
||||
operation="INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate";
|
||||
select * from t1;
|
||||
id operation
|
||||
0 INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate
|
||||
Before UPDATE, new=INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate, old=INSERT ... SELECT, inserting a new key
|
||||
After UPDATE, new=INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate, old=INSERT ... SELECT, inserting a new key
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
replace into v1 (id, operation)
|
||||
select NULL, "REPLACE ... SELECT, inserting a new key";
|
||||
set @id=last_insert_id();
|
||||
select * from t1;
|
||||
id operation
|
||||
1 REPLACE ... SELECT, inserting a new key
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=REPLACE ... SELECT, inserting a new key
|
||||
After INSERT, new=REPLACE ... SELECT, inserting a new key
|
||||
truncate t1_op_log;
|
||||
replace into v1 (id, operation)
|
||||
select @id, "REPLACE ... SELECT, deleting a duplicate";
|
||||
select * from t1;
|
||||
id operation
|
||||
1 REPLACE ... SELECT, deleting a duplicate
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=REPLACE ... SELECT, deleting a duplicate
|
||||
Before DELETE, old=REPLACE ... SELECT, inserting a new key
|
||||
After DELETE, old=REPLACE ... SELECT, inserting a new key
|
||||
After INSERT, new=REPLACE ... SELECT, deleting a duplicate
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
insert into v1 (id, operation) values (1, "INSERT for multi-DELETE");
|
||||
insert into t2 (id) values (1);
|
||||
delete v1.*, t2.* from v1, t2 where v1.id=1;
|
||||
select * from t1;
|
||||
id operation
|
||||
select * from t2;
|
||||
id
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT for multi-DELETE
|
||||
After INSERT, new=INSERT for multi-DELETE
|
||||
Before DELETE, old=INSERT for multi-DELETE
|
||||
After DELETE, old=INSERT for multi-DELETE
|
||||
truncate t1;
|
||||
truncate t2;
|
||||
truncate t1_op_log;
|
||||
insert into v1 (id, operation) values (1, "INSERT for multi-UPDATE");
|
||||
insert into t2 (id) values (1);
|
||||
update v1, t2 set v1.id=2, operation="multi-UPDATE" where v1.id=1;
|
||||
update v1, t2
|
||||
set t2.id=3, operation="multi-UPDATE, SET for t2, but the trigger is fired" where v1.id=2;
|
||||
select * from t1;
|
||||
id operation
|
||||
2 multi-UPDATE, SET for t2, but the trigger is fired
|
||||
select * from t2;
|
||||
id
|
||||
3
|
||||
select * from t1_op_log;
|
||||
operation
|
||||
Before INSERT, new=INSERT for multi-UPDATE
|
||||
After INSERT, new=INSERT for multi-UPDATE
|
||||
Before UPDATE, new=multi-UPDATE, old=INSERT for multi-UPDATE
|
||||
After UPDATE, new=multi-UPDATE, old=INSERT for multi-UPDATE
|
||||
Before UPDATE, new=multi-UPDATE, SET for t2, but the trigger is fired, old=multi-UPDATE
|
||||
After UPDATE, new=multi-UPDATE, SET for t2, but the trigger is fired, old=multi-UPDATE
|
||||
drop view v1;
|
||||
drop table t1, t2, t1_op_log;
|
||||
End of 5.0 tests
|
||||
drop table if exists table_25411_a;
|
||||
drop table if exists table_25411_b;
|
||||
|
@@ -703,7 +703,7 @@ drop table t1;
|
||||
#
|
||||
# Bug #9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
|
||||
#
|
||||
--error 1044
|
||||
--error ER_PARSE_ERROR
|
||||
alter database information_schema;
|
||||
--error 1044
|
||||
drop database information_schema;
|
||||
@@ -1039,6 +1039,14 @@ delete from v1;
|
||||
drop view v1,v2;
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# Bug#25859 ALTER DATABASE works w/o parameters
|
||||
#
|
||||
--error ER_PARSE_ERROR
|
||||
alter database;
|
||||
--error ER_PARSE_ERROR
|
||||
alter database test;
|
||||
|
||||
--echo End of 5.0 tests.
|
||||
#
|
||||
# Show engines
|
||||
|
@@ -878,7 +878,7 @@ drop procedure f4;
|
||||
drop table t1;
|
||||
set GLOBAL query_cache_size=0;
|
||||
|
||||
# End of 4.1 tests
|
||||
--echo End of 4.1 tests
|
||||
|
||||
#
|
||||
# Bug #10303: problem with last_query_cost
|
||||
@@ -1057,7 +1057,79 @@ drop table t1;
|
||||
|
||||
set GLOBAL query_cache_size= default;
|
||||
|
||||
# End of 5.0 tests
|
||||
#
|
||||
# Bug #28249 Query Cache returns wrong result with concurrent insert / certain lock
|
||||
#
|
||||
--echo Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock
|
||||
connect (user1,localhost,root,,test,,);
|
||||
connect (user2,localhost,root,,test,,);
|
||||
connect (user3,localhost,root,,test,,);
|
||||
|
||||
connection user1;
|
||||
|
||||
set GLOBAL query_cache_type=1;
|
||||
set GLOBAL query_cache_limit=10000;
|
||||
set GLOBAL query_cache_min_res_unit=0;
|
||||
set GLOBAL query_cache_size= 100000;
|
||||
|
||||
flush tables;
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2;
|
||||
--enable_warnings
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
connection user2;
|
||||
--echo Locking table T2 with a write lock.
|
||||
lock table t2 write;
|
||||
|
||||
connection user1;
|
||||
--echo Select blocked by write lock.
|
||||
--send select *, (select count(*) from t2) from t1;
|
||||
--echo Sleeing is ok, because selecting should be done very fast.
|
||||
sleep 5;
|
||||
|
||||
connection user3;
|
||||
--echo Inserting into table T1.
|
||||
insert into t1 values (4);
|
||||
|
||||
connection user2;
|
||||
--echo Unlocking the tables.
|
||||
unlock tables;
|
||||
|
||||
connection user1;
|
||||
--echo Collecting result from previously blocked select.
|
||||
#
|
||||
# Since the lock ordering rule in thr_multi_lock depends on
|
||||
# pointer values, from execution to execution we might have
|
||||
# different lock order, and therefore, sometimes lock t1 and block
|
||||
# on t2, and sometimes block on t2 right away. In the second case,
|
||||
# the following insert succeeds, and only then this select can
|
||||
# proceed, and we actually test nothing, as the very first select
|
||||
# returns 4 rows right away.
|
||||
# It's fine to have a test case that covers the problematic area
|
||||
# at least once in a while.
|
||||
# We, however, need to disable the result log here to make the
|
||||
# test repeatable.
|
||||
--disable_result_log
|
||||
--reap
|
||||
--enable_result_log
|
||||
--echo Next select should contain 4 rows, as the insert is long finished.
|
||||
select *, (select count(*) from t2) from t1;
|
||||
reset query cache;
|
||||
select *, (select count(*) from t2) from t1;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
connection default;
|
||||
disconnect user1;
|
||||
disconnect user2;
|
||||
disconnect user3;
|
||||
set GLOBAL query_cache_type=default;
|
||||
set GLOBAL query_cache_limit=default;
|
||||
set GLOBAL query_cache_min_res_unit=default;
|
||||
set GLOBAL query_cache_size=default;
|
||||
--echo End of 5.0 tests
|
||||
|
||||
|
||||
#
|
||||
@@ -1102,4 +1174,4 @@ show status like 'Qcache_queries_in_cache';
|
||||
drop database db2;
|
||||
drop database db3;
|
||||
|
||||
# End of 5.1 tests
|
||||
--echo End of 5.1 tests
|
||||
|
@@ -913,4 +913,68 @@ DROP TABLE t1;
|
||||
DROP PROCEDURE p1;
|
||||
DEALLOCATE PREPARE stmt1;
|
||||
|
||||
#
|
||||
# BUG#10491: Server returns data as charset binary SHOW CREATE TABLE or SELECT
|
||||
# FROM INFORMATION_SCHEMA.
|
||||
#
|
||||
# Before the change performed to fix the bug, the metadata of the output of
|
||||
# SHOW CREATE statements would always describe the result as 'binary'. That
|
||||
# would ensure that the result is never converted to character_set_client
|
||||
# (which was essential to mysqldump). Now we return to the client the actual
|
||||
# character set of the object -- which is character_set_client of the
|
||||
# connection that issues the CREATE statement, and this triggers an automatic
|
||||
# conversion to character_set_results of the connection that issues SHOW CREATE
|
||||
# statement.
|
||||
#
|
||||
# This test demonstrates that this conversion indeed is taking place.
|
||||
#
|
||||
|
||||
# Prepare: create objects in a one character set.
|
||||
|
||||
set names koi8r;
|
||||
|
||||
--disable_warnings
|
||||
DROP VIEW IF EXISTS v1;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP EVENT IF EXISTS ev1;
|
||||
--enable_warnings
|
||||
|
||||
CREATE VIEW v1 AS SELECT '<27><><EFBFBD><EFBFBD>' AS test;
|
||||
|
||||
CREATE PROCEDURE p1() SELECT '<27><><EFBFBD><EFBFBD>' AS test;
|
||||
|
||||
CREATE FUNCTION f1() RETURNS CHAR(10) RETURN '<27><><EFBFBD><EFBFBD>';
|
||||
|
||||
CREATE TABLE t1(c1 CHAR(10));
|
||||
CREATE TRIGGER t1_bi BEFORE INSERT ON t1
|
||||
FOR EACH ROW
|
||||
SET NEW.c1 = '<27><><EFBFBD><EFBFBD>';
|
||||
|
||||
CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO SELECT '<27><><EFBFBD><EFBFBD>' AS test;
|
||||
|
||||
# Test: switch the character set and show that SHOW CREATE output is
|
||||
# automatically converted to the new character_set_client.
|
||||
|
||||
set names utf8;
|
||||
|
||||
SHOW CREATE VIEW v1;
|
||||
|
||||
SHOW CREATE PROCEDURE p1;
|
||||
|
||||
SHOW CREATE FUNCTION f1;
|
||||
|
||||
SHOW CREATE TRIGGER t1_bi;
|
||||
|
||||
SHOW CREATE EVENT ev1;
|
||||
|
||||
# Cleanup.
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP PROCEDURE p1;
|
||||
DROP FUNCTION f1;
|
||||
DROP TABLE t1;
|
||||
DROP EVENT ev1;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
@@ -7250,6 +7250,43 @@ DROP VIEW v1;
|
||||
DROP FUNCTION metered;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#28551 "The warning 'No database selected' is reported when calling
|
||||
# stored procedures"
|
||||
#
|
||||
--disable_warnings
|
||||
drop database if exists mysqltest_db1;
|
||||
--enable_warnings
|
||||
create database mysqltest_db1;
|
||||
create procedure mysqltest_db1.sp_bug28551() begin end;
|
||||
call mysqltest_db1.sp_bug28551();
|
||||
show warnings;
|
||||
drop database mysqltest_db1;
|
||||
#
|
||||
# Bug#29050 Creation of a legal stored procedure fails if a database is not
|
||||
# selected prior
|
||||
#
|
||||
--disable_warnings
|
||||
drop database if exists mysqltest_db1;
|
||||
drop table if exists test.t1;
|
||||
--enable_warnings
|
||||
create database mysqltest_db1;
|
||||
use mysqltest_db1;
|
||||
# For the sake of its side effect
|
||||
drop database mysqltest_db1;
|
||||
# Now we have no current database selected.
|
||||
create table test.t1 (id int);
|
||||
insert into test.t1 (id) values (1);
|
||||
delimiter //;
|
||||
create procedure test.sp_bug29050() begin select * from t1; end//
|
||||
delimiter ;//
|
||||
show warnings;
|
||||
call test.sp_bug29050();
|
||||
show warnings;
|
||||
# Restore the old current database
|
||||
use test;
|
||||
drop procedure sp_bug29050;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug#25411 (trigger code truncated)
|
||||
|
@@ -49,4 +49,84 @@ insert into t1 values ('The Pie', 50, 1, 1);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
# End of 5.0 tests
|
||||
--echo
|
||||
--echo Bug#26141 mixing table types in trigger causes full
|
||||
--echo table lock on innodb table
|
||||
--echo
|
||||
--echo Ensure we do not open and lock tables for the triggers we do not
|
||||
--echo fire.
|
||||
--echo
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2, t3;
|
||||
drop trigger if exists trg_bug26141_au;
|
||||
drop trigger if exists trg_bug26141_ai;
|
||||
--enable_warnings
|
||||
# Note, for InnoDB to allow concurrent UPDATE and INSERT the
|
||||
# table must have a unique key.
|
||||
create table t1 (c int primary key) engine=innodb;
|
||||
create table t2 (c int) engine=myisam;
|
||||
create table t3 (c int) engine=myisam;
|
||||
insert into t1 (c) values (1);
|
||||
delimiter |;
|
||||
|
||||
create trigger trg_bug26141_ai after insert on t1
|
||||
for each row
|
||||
begin
|
||||
insert into t2 (c) values (1);
|
||||
# We need the 'sync' lock to synchronously wait in connection 2 till
|
||||
# the moment when the trigger acquired all the locks.
|
||||
select release_lock("lock_bug26141_sync") into @a;
|
||||
# 1000 is time in seconds of lock wait timeout -- this is a way
|
||||
# to cause a manageable sleep up to 1000 seconds
|
||||
select get_lock("lock_bug26141_wait", 1000) into @a;
|
||||
end|
|
||||
|
||||
create trigger trg_bug26141_au after update on t1
|
||||
for each row
|
||||
begin
|
||||
insert into t3 (c) values (1);
|
||||
end|
|
||||
delimiter ;|
|
||||
|
||||
# Establish an alternative connection.
|
||||
--connect (connection_aux,localhost,root,,test,,)
|
||||
--connect (connection_update,localhost,root,,test,,)
|
||||
|
||||
connection connection_aux;
|
||||
# Lock the wait lock, it must not be locked, so specify zero timeout.
|
||||
select get_lock("lock_bug26141_wait", 0);
|
||||
|
||||
#
|
||||
connection default;
|
||||
#
|
||||
# Run the trigger synchronously
|
||||
#
|
||||
select get_lock("lock_bug26141_sync", /* must not be priorly locked */ 0);
|
||||
# Will acquire the table level locks, perform the insert into t2,
|
||||
# release the sync lock and block on the wait lock.
|
||||
send insert into t1 (c) values (2);
|
||||
|
||||
connection connection_update;
|
||||
# Wait for the trigger to acquire its locks and unlock the sync lock.
|
||||
select get_lock("lock_bug26141_sync", 1000);
|
||||
#
|
||||
# This must continue: after the fix for the bug, we do not
|
||||
# open tables for t2, and with c=4 innobase allows the update
|
||||
# to run concurrently with insert.
|
||||
update t1 set c=3 where c=1;
|
||||
select release_lock("lock_bug26141_sync");
|
||||
connection connection_aux;
|
||||
select release_lock("lock_bug26141_wait");
|
||||
connection default;
|
||||
reap;
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
select * from t3;
|
||||
|
||||
# Drops the trigger as well.
|
||||
drop table t1, t2, t3;
|
||||
disconnect connection_update;
|
||||
disconnect connection_aux;
|
||||
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
@@ -406,7 +406,7 @@ create table mysqltest.t1 (i int);
|
||||
--error ER_TRG_IN_WRONG_SCHEMA
|
||||
create trigger trg1 before insert on mysqltest.t1 for each row set @a:= 1;
|
||||
use mysqltest;
|
||||
--error ER_TRG_IN_WRONG_SCHEMA
|
||||
--error ER_NO_SUCH_TABLE
|
||||
create trigger test.trg1 before insert on t1 for each row set @a:= 1;
|
||||
drop database mysqltest;
|
||||
use test;
|
||||
@@ -1040,7 +1040,7 @@ drop table t1;
|
||||
connection addconwithoutdb;
|
||||
--error ER_NO_DB_ERROR
|
||||
create trigger t1_bi before insert on test.t1 for each row set @a:=0;
|
||||
--error ER_NO_DB_ERROR
|
||||
--error ER_NO_SUCH_TABLE
|
||||
create trigger test.t1_bi before insert on t1 for each row set @a:=0;
|
||||
--error ER_NO_DB_ERROR
|
||||
drop trigger t1_bi;
|
||||
@@ -1828,7 +1828,372 @@ DROP TRIGGER t1_test;
|
||||
DROP TABLE t1,t2;
|
||||
SET SESSION LOW_PRIORITY_UPDATES=DEFAULT;
|
||||
SET GLOBAL LOW_PRIORITY_UPDATES=DEFAULT;
|
||||
--echo
|
||||
--echo Bug#28502 Triggers that update another innodb table will block
|
||||
--echo on X lock unnecessarily
|
||||
--echo
|
||||
--echo Ensure we do not open and lock tables for triggers we do not fire.
|
||||
--echo
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2;
|
||||
drop trigger if exists trg_bug28502_au;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (id int, count int);
|
||||
create table t2 (id int);
|
||||
delimiter |;
|
||||
|
||||
create trigger trg_bug28502_au before update on t2
|
||||
for each row
|
||||
begin
|
||||
if (new.id is not null) then
|
||||
update t1 set count= count + 1 where id = old.id;
|
||||
end if;
|
||||
end|
|
||||
|
||||
delimiter ;|
|
||||
insert into t1 (id, count) values (1, 0);
|
||||
|
||||
lock table t1 write;
|
||||
|
||||
--connect (connection_insert, localhost, root, , test, , )
|
||||
connection connection_insert;
|
||||
# Is expected to pass.
|
||||
insert into t2 set id=1;
|
||||
connection default;
|
||||
unlock tables;
|
||||
update t2 set id=1 where id=1;
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
# Will drop the trigger
|
||||
drop table t1, t2;
|
||||
disconnect connection_insert;
|
||||
--echo
|
||||
--echo Additionally, provide test coverage for triggers and
|
||||
--echo all MySQL data changing commands.
|
||||
--echo
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2, t1_op_log;
|
||||
drop view if exists v1;
|
||||
drop trigger if exists trg_bug28502_bi;
|
||||
drop trigger if exists trg_bug28502_ai;
|
||||
drop trigger if exists trg_bug28502_bu;
|
||||
drop trigger if exists trg_bug28502_au;
|
||||
drop trigger if exists trg_bug28502_bd;
|
||||
drop trigger if exists trg_bug28502_ad;
|
||||
--enable_warnings
|
||||
create table t1 (id int primary key auto_increment, operation varchar(255));
|
||||
create table t2 (id int primary key);
|
||||
create table t1_op_log(operation varchar(255));
|
||||
create view v1 as select * from t1;
|
||||
create trigger trg_bug28502_bi before insert on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("Before INSERT, new=", new.operation));
|
||||
|
||||
create trigger trg_bug28502_ai after insert on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("After INSERT, new=", new.operation));
|
||||
|
||||
create trigger trg_bug28502_bu before update on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("Before UPDATE, new=", new.operation,
|
||||
", old=", old.operation));
|
||||
|
||||
create trigger trg_bug28502_au after update on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("After UPDATE, new=", new.operation,
|
||||
", old=", old.operation));
|
||||
|
||||
create trigger trg_bug28502_bd before delete on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("Before DELETE, old=", old.operation));
|
||||
|
||||
create trigger trg_bug28502_ad after delete on t1
|
||||
for each row
|
||||
insert into t1_op_log (operation)
|
||||
values (concat("After DELETE, old=", old.operation));
|
||||
|
||||
insert into t1 (operation) values ("INSERT");
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
update t1 set operation="UPDATE" where id=@id;
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
delete from t1 where id=@id;
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into t1 (id, operation) values
|
||||
(NULL, "INSERT ON DUPLICATE KEY UPDATE, inserting a new key")
|
||||
on duplicate key update id=NULL, operation="Should never happen";
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into t1 (id, operation) values
|
||||
(@id, "INSERT ON DUPLICATE KEY UPDATE, the key value is the same")
|
||||
on duplicate key update id=NULL,
|
||||
operation="INSERT ON DUPLICATE KEY UPDATE, updating the duplicate";
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
replace into t1 values (NULL, "REPLACE, inserting a new key");
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
replace into t1 values (@id, "REPLACE, deleting the duplicate");
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
create table if not exists t1
|
||||
select NULL, "CREATE TABLE ... SELECT, inserting a new key";
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
create table if not exists t1 replace
|
||||
select @id, "CREATE TABLE ... REPLACE SELECT, deleting a duplicate key";
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into t1 (id, operation)
|
||||
select NULL, "INSERT ... SELECT, inserting a new key";
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into t1 (id, operation)
|
||||
select @id,
|
||||
"INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate"
|
||||
on duplicate key update id=NULL,
|
||||
operation="INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate";
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
replace into t1 (id, operation)
|
||||
select NULL, "REPLACE ... SELECT, inserting a new key";
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
replace into t1 (id, operation)
|
||||
select @id, "REPLACE ... SELECT, deleting a duplicate";
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into t1 (id, operation) values (1, "INSERT for multi-DELETE");
|
||||
insert into t2 (id) values (1);
|
||||
|
||||
delete t1.*, t2.* from t1, t2 where t1.id=1;
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t2;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into t1 (id, operation) values (1, "INSERT for multi-UPDATE");
|
||||
insert into t2 (id) values (1);
|
||||
update t1, t2 set t1.id=2, operation="multi-UPDATE" where t1.id=1;
|
||||
update t1, t2
|
||||
set t2.id=3, operation="multi-UPDATE, SET for t2, but the trigger is fired" where t1.id=2;
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
select * from t1_op_log;
|
||||
truncate table t1;
|
||||
truncate table t2;
|
||||
truncate table t1_op_log;
|
||||
|
||||
--echo
|
||||
--echo Now do the same but use a view instead of the base table.
|
||||
--echo
|
||||
|
||||
insert into v1 (operation) values ("INSERT");
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
update v1 set operation="UPDATE" where id=@id;
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
delete from v1 where id=@id;
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into v1 (id, operation) values
|
||||
(NULL, "INSERT ON DUPLICATE KEY UPDATE, inserting a new key")
|
||||
on duplicate key update id=NULL, operation="Should never happen";
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into v1 (id, operation) values
|
||||
(@id, "INSERT ON DUPLICATE KEY UPDATE, the key value is the same")
|
||||
on duplicate key update id=NULL,
|
||||
operation="INSERT ON DUPLICATE KEY UPDATE, updating the duplicate";
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
replace into v1 values (NULL, "REPLACE, inserting a new key");
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
replace into v1 values (@id, "REPLACE, deleting the duplicate");
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
create table if not exists v1
|
||||
select NULL, "CREATE TABLE ... SELECT, inserting a new key";
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
create table if not exists v1 replace
|
||||
select @id, "CREATE TABLE ... REPLACE SELECT, deleting a duplicate key";
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into v1 (id, operation)
|
||||
select NULL, "INSERT ... SELECT, inserting a new key";
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into v1 (id, operation)
|
||||
select @id,
|
||||
"INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate"
|
||||
on duplicate key update id=NULL,
|
||||
operation="INSERT ... SELECT ... ON DUPLICATE KEY UPDATE, updating a duplicate";
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
replace into v1 (id, operation)
|
||||
select NULL, "REPLACE ... SELECT, inserting a new key";
|
||||
|
||||
set @id=last_insert_id();
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1_op_log;
|
||||
|
||||
replace into v1 (id, operation)
|
||||
select @id, "REPLACE ... SELECT, deleting a duplicate";
|
||||
|
||||
select * from t1;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into v1 (id, operation) values (1, "INSERT for multi-DELETE");
|
||||
insert into t2 (id) values (1);
|
||||
|
||||
delete v1.*, t2.* from v1, t2 where v1.id=1;
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
select * from t1_op_log;
|
||||
truncate t1;
|
||||
truncate t2;
|
||||
truncate t1_op_log;
|
||||
|
||||
insert into v1 (id, operation) values (1, "INSERT for multi-UPDATE");
|
||||
insert into t2 (id) values (1);
|
||||
update v1, t2 set v1.id=2, operation="multi-UPDATE" where v1.id=1;
|
||||
update v1, t2
|
||||
set t2.id=3, operation="multi-UPDATE, SET for t2, but the trigger is fired" where v1.id=2;
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
select * from t1_op_log;
|
||||
|
||||
drop view v1;
|
||||
drop table t1, t2, t1_op_log;
|
||||
|
||||
#
|
||||
# TODO: test LOAD DATA INFILE
|
||||
--echo End of 5.0 tests
|
||||
|
||||
#
|
||||
|
Reference in New Issue
Block a user