Merge pull request #235 from percona/PT-91-MySQL-5.7

PT-91 Added --preserve-triggers feature for MySQL 5.7+
This commit is contained in:
Carlos Salguero
2017-07-26 16:02:59 -03:00
committed by GitHub
6 changed files with 1916 additions and 40 deletions

View File

@@ -0,0 +1,77 @@
DROP SCHEMA IF EXISTS test;
CREATE SCHEMA test;
CREATE TABLE test.t1 (
id INT NOT NULL AUTO_INCREMENT,
f1 INT,
f2 VARCHAR(32),
PRIMARY KEY (id)
);
CREATE TABLE test.t2 LIKE test.t1;
CREATE TABLE test.log (
ts TIMESTAMP,
msg VARCHAR(255)
);
DROP TRIGGER IF EXISTS test.after_insert;
DROP TRIGGER IF EXISTS test.after_update;
DROP TRIGGER IF EXISTS test.after_delete;
CREATE TRIGGER test.after_insert
AFTER
-- a comment here
INSERT ON test.t1
-- just to make things harder
FOR EACH ROW INSERT INTO test.log VALUES (NOW(), CONCAT("inserted new row with id: ", NEW.id))
-- for pt_osc
;
CREATE TRIGGER test.after_insert2
AFTER
-- a comment here
INSERT ON test.t1
-- just to make things harder
FOR EACH ROW INSERT INTO test.log VALUES (NOW(), CONCAT("inserted duplicate of new row with id: ", NEW.id))
-- for pt_osc
;
DELIMITER //
CREATE TRIGGER test.after_update
AFTER
-- a comment here
UPDATE ON test.t1
-- just to make things harder
FOR EACH ROW
BEGIN
INSERT INTO test.log VALUES (NOW(), CONCAT("updated row row with id ", OLD.id, " old f1:", OLD.f1, " new f1: ", NEW.f1 ));
INSERT INTO test.log VALUES (NOW(), CONCAT("updated row row with id ", OLD.id, " old f1:", OLD.f1, " new f1: ", NEW.f1 ));
END
-- for pt_osc
//
DELIMITER ;
CREATE TRIGGER test.after_delete
AFTER
-- a comment here
DELETE ON test.t1
-- just to make things harder
FOR EACH ROW INSERT INTO test.log VALUES (NOW(), CONCAT("deleted row with id: ", OLD.id))
-- for pt_osc
;
INSERT INTO test.t1 VALUES
(1, 1, 'a'), (2, 1, 'b'), (3, 1, 'c'), (4, 1, 'd'),
(5, 2, 'e'), (6, 2, 'f'), (7, 3, 'h'), (8, 3, 'g');
DELETE FROM test.t1 WHERE f2 = 'h';
UPDATE test.t1
SET f1 = f1 + 1
WHERE f2 = 'g';

View File

@@ -10,9 +10,10 @@ Operation, tries, wait:
Altering `bug_1045317`.`bits`...
TS Dropping triggers...
TS Dropped triggers OK.
# Event Count
# ====== =====
# INSERT 1
# Event Count
# ================== =====
# INSERT 1
# mysql_warning_1592 1
Successfully altered `bug_1045317`.`bits`.
Creating new table...
Created new table bug_1045317._bits_new OK.

View File

@@ -0,0 +1,99 @@
-- MySQL dump 10.13 Distrib 5.7.12, for Linux (x86_64)
--
-- Host: 127.0.0.1 Database: pt_osc
-- ------------------------------------------------------
-- Server version 5.6.31-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `account`
--
DROP DATABASE IF EXISTS pt_osc;
CREATE DATABASE pt_osc;
USE pt_osc;
DROP TABLE IF EXISTS `account`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `account` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`second_key` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=20000 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `account`
--
LOCK TABLES `account` WRITE;
/*!40000 ALTER TABLE `account` DISABLE KEYS */;
INSERT INTO `account` VALUES (1,10000001),(2,10000002),(3,10000003),(4,10000004),(5,10000005),
(6,10000006),(7,10000007),(8,10000008),(9,10000009),(10,10000010),(11,10000011),(12,10000012),
(13,10000013),(14,10000014),(15,10000015),(16,10000016),(17,10000017),(18,10000018),(19,10000019),
(20,10000020),(21,10000021),(22,10000022),(23,10000023),(24,10000024),(25,10000025),(26,10000026),
(27,10000027),(28,10000028),(29,10000029),(30,10000030),(31,10000031),(32,10000032),(33,10000033),
(34,10000034),(35,10000035),(36,10000036),(37,10000037),(38,10000038),(39,10000039),(40,10000040),
(41,10000041),(42,10000042),(43,10000043),(44,10000044),(45,10000045),(46,10000046),(47,10000047),
(48,10000048),(49,10000049),(50,10000050),(51,10000051),(52,10000052),(53,10000053),(54,10000054),
(55,10000055),(56,10000056),(57,10000057),(58,10000058),(59,10000059),(60,10000060),(61,10000061),
(62,10000062),(63,10000063),(64,10000064),(65,10000065),(66,10000066),(67,10000067),(68,10000068),
(69,10000069),(70,10000070),(71,10000071),(72,10000072),(73,10000073),(74,10000074),(75,10000075),
(76,10000076),(77,10000077),(78,10000078),(79,10000079),(80,10000080),(81,10000081),(82,10000082),
(83,10000083),(84,10000084),(85,10000085),(86,10000086),(87,10000087),(88,10000088),(89,10000089),
(90,10000090),(91,10000091),(92,10000092),(93,10000093),(94,10000094),(95,10000095),(96,10000096),
(97,10000097),(98,10000098),(99,10000099),(100,10000100),(101,10000101),(102,10000102),(103,10000103),
(104,10000104),(105,10000105),(106,10000106),(107,10000107),(108,10000108),(109,10000109),(110,10000110),
(111,10000111),(112,10000112),(113,10000113),(114,10000114),(115,10000115),(116,10000116),(117,10000117),
(118,10000118),(119,10000119),(120,10000120),(121,10000121),(122,10000122),(123,10000123),(124,10000124),
(125,10000125),(126,10000126),(127,10000127),(128,10000128),(129,10000129),(130,10000130),(131,10000131),
(132,10000132),(133,10000133),(134,10000134),(135,10000135),(136,10000136),(137,10000137),(138,10000138),
(139,10000139),(140,10000140),(141,10000141),(142,10000142),(143,10000143),(144,10000144),(145,10000145),
(146,10000146),(147,10000147),(148,10000148),(149,10000149),(150,10000150),(151,10000151),(152,10000152),
(153,10000153),(154,10000154),(155,10000155),(156,10000156),(157,10000157),(158,10000158),(159,10000159),
(160,10000160),(161,10000161),(162,10000162),(163,10000163),(164,10000164),(165,10000165),(166,10000166),
(167,10000167),(168,10000168),(169,10000169),(170,10000170),(171,10000171),(172,10000172),(173,10000173),
(174,10000174),(175,10000175),(176,10000176),(177,10000177),(178,10000178),(179,10000179),(180,10000180),
(181,10000181),(182,10000182),(183,10000183),(184,10000184),(185,10000185),(186,10000186),(187,10000187),
(188,10000188),(189,10000189),(190,10000190),(191,10000191),(192,10000192),(193,10000193),(194,10000194);
/*!40000 ALTER TABLE `account` ENABLE KEYS */;
UNLOCK TABLES;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`msandbox`@`%`*/ /*!50003 TRIGGER ins_sum
before INSERT ON account
FOR EACH ROW SET NEW.second_key = NEW.id + 10000000 */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2016-07-01 17:04:54