forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[upstream] Fixing memory leak when order by is used to dump selected …
…tables Summary: `order_by` needs to be freed after every invocation of `dump_tables()`. In `dump_selected_tables()` we were not doing this. Upstream bug report: https://bugs.mysql.com/bug.php?id=96178 Reviewed By: lloyd Differential Revision: D16189662
- Loading branch information
1 parent
5bb9218
commit eb34d65
Showing
2 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
DROP TABLE IF EXISTS table1; | ||
drop database if exists database1; | ||
CREATE DATABASE database1; | ||
USE database1; | ||
CREATE TABLE table1(a INT PRIMARY KEY, b INT UNIQUE) engine = InnoDB; | ||
CREATE TABLE table2(a INT PRIMARY KEY, b INT UNIQUE) engine = InnoDB; | ||
INSERT INTO table1 VALUES (1, 3); | ||
INSERT INTO table1 VALUES (2, 2); | ||
INSERT INTO table1 VALUES (3, 1); | ||
INSERT INTO table2 VALUES (1, 3); | ||
INSERT INTO table2 VALUES (2, 2); | ||
INSERT INTO table2 VALUES (3, 1); | ||
==== mysqldump with --order-by-primary ==== | ||
-- MYSQLDUMP VERSION | ||
-- | ||
-- Host: localhost Database: database1 | ||
-- ------------------------------------------------------ | ||
-- SERVER VERSION | ||
|
||
/*!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 */; | ||
/*!50503 SET NAMES utf8mb4 */; | ||
/*!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 `table1` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `table1`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!50503 SET character_set_client = utf8mb4 */; | ||
CREATE TABLE `table1` ( | ||
`a` int NOT NULL, | ||
`b` int DEFAULT NULL, | ||
PRIMARY KEY (`a`), | ||
UNIQUE KEY `b` (`b`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Dumping data for table `table1` | ||
-- | ||
-- ORDER BY: `a`,`b` | ||
|
||
LOCK TABLES `table1` WRITE; | ||
/*!40000 ALTER TABLE `table1` DISABLE KEYS */; | ||
INSERT INTO `table1` VALUES (1,3); | ||
INSERT INTO `table1` VALUES (2,2); | ||
INSERT INTO `table1` VALUES (3,1); | ||
/*!40000 ALTER TABLE `table1` ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
|
||
-- | ||
-- Table structure for table `table2` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `table2`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!50503 SET character_set_client = utf8mb4 */; | ||
CREATE TABLE `table2` ( | ||
`a` int NOT NULL, | ||
`b` int DEFAULT NULL, | ||
PRIMARY KEY (`a`), | ||
UNIQUE KEY `b` (`b`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Dumping data for table `table2` | ||
-- | ||
-- ORDER BY: `a`,`b` | ||
|
||
LOCK TABLES `table2` WRITE; | ||
/*!40000 ALTER TABLE `table2` DISABLE KEYS */; | ||
INSERT INTO `table2` VALUES (1,3); | ||
INSERT INTO `table2` VALUES (2,2); | ||
INSERT INTO `table2` VALUES (3,1); | ||
/*!40000 ALTER TABLE `table2` ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
/*!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 | ||
DROP TABLE table1; | ||
DROP TABLE table2; | ||
drop database database1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--disable_warnings | ||
DROP TABLE IF EXISTS table1; | ||
drop database if exists database1; | ||
--enable_warnings | ||
|
||
CREATE DATABASE database1; | ||
USE database1; | ||
CREATE TABLE table1(a INT PRIMARY KEY, b INT UNIQUE) engine = InnoDB; | ||
CREATE TABLE table2(a INT PRIMARY KEY, b INT UNIQUE) engine = InnoDB; | ||
|
||
INSERT INTO table1 VALUES (1, 3); | ||
INSERT INTO table1 VALUES (2, 2); | ||
INSERT INTO table1 VALUES (3, 1); | ||
|
||
INSERT INTO table2 VALUES (1, 3); | ||
INSERT INTO table2 VALUES (2, 2); | ||
INSERT INTO table2 VALUES (3, 1); | ||
|
||
--echo ==== mysqldump with --order-by-primary ==== | ||
--replace_regex /-- Server version.*/-- SERVER VERSION/ /-- MySQL dump.*[)]/-- MYSQLDUMP VERSION/ | ||
--exec $MYSQL_DUMP --skip-dump-date --order-by-primary --extended-insert=FALSE database1 table1 table2 | ||
|
||
DROP TABLE table1; | ||
DROP TABLE table2; | ||
drop database database1; |