-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-16355 Add option for mysqldump to read data as of specific times…
…tamp from system-versioned tables Based on Aleksey Midenkov's patch mysqldump changes: * --as-of option specifies historical point; * query forging protection for --as-of parameter. system versioned tables are detected by querying I_S.TABLES: * it transfers much less data when the full table definition is not needed * it does not give false positives on x TEXT DEFAULT 'WITH SYSTEM VERSIONING'
- Loading branch information
Showing
4 changed files
with
133 additions
and
7 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
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
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,50 @@ | ||
# | ||
# MDEV-16355 Add option for mysqldump to read data as of specific timestamp from system-versioned tables | ||
# | ||
create or replace table t1 (x int) with system versioning; | ||
set timestamp=unix_timestamp('1990-01-01 00:00'); | ||
insert t1 (x) values (1),(2),(3); | ||
set timestamp=unix_timestamp('1990-08-03 00:00'); | ||
delete from t1 where x=1; | ||
set timestamp=unix_timestamp('1991-01-02 00:00'); | ||
delete from t1 where x=2; | ||
set timestamp=default; | ||
#MYSQL_DUMP --compact test | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `t1` ( | ||
`x` int(11) DEFAULT NULL | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
INSERT INTO `t1` VALUES (3); | ||
#MYSQL_DUMP --compact --as-of="1990-01-02 00:00" test | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `t1` ( | ||
`x` int(11) DEFAULT NULL | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
INSERT INTO `t1` VALUES (1),(2),(3); | ||
#MYSQL_DUMP --compact --as-of="1990-08-02 00:00" --databases test | ||
|
||
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */; | ||
|
||
USE `test`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `t1` ( | ||
`x` int(11) DEFAULT NULL | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
INSERT INTO `t1` VALUES (1),(2),(3); | ||
#MYSQL_DUMP --compact --as-of="1990-08-04 00:00" test t1 | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `t1` ( | ||
`x` int(11) DEFAULT NULL | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
INSERT INTO `t1` VALUES (2),(3); | ||
#MYSQL_DUMP --compact --as-of="1990-08-04 00:00' where 'abc" test 2>&1 | ||
mysqldump: Incorrect DATETIME value: '1990-08-04 00:00' where 'abc' | ||
drop tables t1; |
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,32 @@ | ||
--source include/not_embedded.inc | ||
--source suite/versioning/common.inc | ||
|
||
--echo # | ||
--echo # MDEV-16355 Add option for mysqldump to read data as of specific timestamp from system-versioned tables | ||
--echo # | ||
create or replace table t1 (x int) with system versioning; | ||
set timestamp=unix_timestamp('1990-01-01 00:00'); | ||
insert t1 (x) values (1),(2),(3); | ||
set timestamp=unix_timestamp('1990-08-03 00:00'); | ||
delete from t1 where x=1; | ||
set timestamp=unix_timestamp('1991-01-02 00:00'); | ||
delete from t1 where x=2; | ||
set timestamp=default; | ||
|
||
--echo #MYSQL_DUMP --compact test | ||
--exec $MYSQL_DUMP --compact test | ||
--echo #MYSQL_DUMP --compact --as-of="1990-01-02 00:00" test | ||
--exec $MYSQL_DUMP --compact --as-of="1990-01-02 00:00" test | ||
--echo #MYSQL_DUMP --compact --as-of="1990-08-02 00:00" --databases test | ||
--exec $MYSQL_DUMP --compact --as-of="1990-08-02 00:00" --databases test | ||
--echo #MYSQL_DUMP --compact --as-of="1990-08-04 00:00" test t1 | ||
--exec $MYSQL_DUMP --compact --as-of="1990-08-04 00:00" test t1 | ||
## Forged query protection | ||
--echo #MYSQL_DUMP --compact --as-of="1990-08-04 00:00' where 'abc" test 2>&1 | ||
--replace_result mysqldump.exe mysqldump | ||
--error 1 | ||
--exec $MYSQL_DUMP --compact --as-of="1990-08-04 00:00' where 'abc" test 2>&1 | ||
|
||
drop tables t1; | ||
|
||
--source suite/versioning/common_finish.inc |