#At file:///MySQL/REPO/V60/work-6.0/
2783 Joerg Bruehe 2008-10-21 [merge]
Merge from main. For local tests only, not to be pushed from this tree.
added:
mysql-test/suite/backup/
mysql-test/suite/backup/r/
mysql-test/suite/backup/r/backup_commit_backup.result
mysql-test/suite/backup/t/
mysql-test/suite/backup/t/backup_commit_backup.test
mysql-test/suite/backup/t/disabled.def
mysql-test/suite/backup_engines/include/backup_ptr.inc
mysql-test/suite/backup_engines/include/backup_ptr_commit.inc
mysql-test/suite/backup_engines/include/backup_ptr_objects.inc
mysql-test/suite/backup_engines/include/not_have_falcon.inc
mysql-test/suite/backup_engines/include/not_have_innodb.inc
mysql-test/suite/backup_engines/include/not_have_memory.inc
mysql-test/suite/backup_engines/include/not_have_myisam.inc
mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result
mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result
mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result
mysql-test/suite/backup_engines/r/backup_ptr_mixed.result
mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result
mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result
mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result
mysql-test/suite/backup_engines/r/backup_ptr_row.result
mysql-test/suite/backup_engines/r/backup_ptr_stmt.result
mysql-test/suite/backup_engines/t/backup_ptr_commit_mixed.test
mysql-test/suite/backup_engines/t/backup_ptr_commit_row.test
mysql-test/suite/backup_engines/t/backup_ptr_commit_stmt.test
mysql-test/suite/backup_engines/t/backup_ptr_mixed.test
mysql-test/suite/backup_engines/t/backup_ptr_objects_mixed.test
mysql-test/suite/backup_engines/t/backup_ptr_objects_row.test
mysql-test/suite/backup_engines/t/backup_ptr_objects_stmt.test
mysql-test/suite/backup_engines/t/backup_ptr_row.test
mysql-test/suite/backup_engines/t/backup_ptr_stmt.test
renamed:
mysql-test/r/backup.result => mysql-test/suite/backup/r/backup.result
mysql-test/r/backup_backupdir.result => mysql-test/suite/backup/r/backup_backupdir.result
mysql-test/r/backup_blob.result => mysql-test/suite/backup/r/backup_blob.result
mysql-test/r/backup_charsets.result => mysql-test/suite/backup/r/backup_charsets.result
mysql-test/r/backup_commit_blocker.result => mysql-test/suite/backup/r/backup_commit_blocker.result
mysql-test/r/backup_commit_restore.result => mysql-test/suite/backup/r/backup_commit_restore.result
mysql-test/r/backup_compression.result => mysql-test/suite/backup/r/backup_compression.result
mysql-test/r/backup_concurrent.result => mysql-test/suite/backup/r/backup_concurrent.result
mysql-test/r/backup_db_grants.result => mysql-test/suite/backup/r/backup_db_grants.result
mysql-test/r/backup_ddl_blocker.result => mysql-test/suite/backup/r/backup_ddl_blocker.result
mysql-test/r/backup_default.result => mysql-test/suite/backup/r/backup_default.result
mysql-test/r/backup_errors.result => mysql-test/suite/backup/r/backup_errors.result
mysql-test/r/backup_fkey.result => mysql-test/suite/backup/r/backup_fkey.result
mysql-test/r/backup_lock_myisam.result => mysql-test/suite/backup/r/backup_lock_myisam.result
mysql-test/r/backup_logs.result => mysql-test/suite/backup/r/backup_logs.result
mysql-test/r/backup_logs_output.result => mysql-test/suite/backup/r/backup_logs_output.result
mysql-test/r/backup_many_dbs.result => mysql-test/suite/backup/r/backup_many_dbs.result
mysql-test/r/backup_multi_blocks.result => mysql-test/suite/backup/r/backup_multi_blocks.result
mysql-test/r/backup_myisam1.result => mysql-test/suite/backup/r/backup_myisam1.result
mysql-test/r/backup_myisam2.result => mysql-test/suite/backup/r/backup_myisam2.result
mysql-test/r/backup_no_be.result => mysql-test/suite/backup/r/backup_no_be.result
mysql-test/r/backup_no_data.result => mysql-test/suite/backup/r/backup_no_data.result
mysql-test/r/backup_no_engine.result => mysql-test/suite/backup/r/backup_no_engine.result
mysql-test/r/backup_nodata_driver.result => mysql-test/suite/backup/r/backup_nodata_driver.result
mysql-test/r/backup_objects.result => mysql-test/suite/backup/r/backup_objects.result
mysql-test/r/backup_procedures.result => mysql-test/suite/backup/r/backup_procedures.result
mysql-test/r/backup_securefilepriv.result => mysql-test/suite/backup/r/backup_securefilepriv.result
mysql-test/r/backup_security.result => mysql-test/suite/backup/r/backup_security.result
mysql-test/r/backup_snapshot.result => mysql-test/suite/backup/r/backup_snapshot.result
mysql-test/r/backup_tablespace.result => mysql-test/suite/backup/r/backup_tablespace.result
mysql-test/r/backup_timeout.result => mysql-test/suite/backup/r/backup_timeout.result
mysql-test/r/backup_triggers_and_events.result => mysql-test/suite/backup/r/backup_triggers_and_events.result
mysql-test/r/backup_view_on_view.result => mysql-test/suite/backup/r/backup_view_on_view.result
mysql-test/r/backup_views.result => mysql-test/suite/backup/r/backup_views.result
mysql-test/suite/backup => mysql-test/suite/backup_engines
mysql-test/t/backup.test => mysql-test/suite/backup/t/backup.test
mysql-test/t/backup_backupdir.test => mysql-test/suite/backup/t/backup_backupdir.test
mysql-test/t/backup_blob.test => mysql-test/suite/backup/t/backup_blob.test
mysql-test/t/backup_charsets.test => mysql-test/suite/backup/t/backup_charsets.test
mysql-test/t/backup_commit_blocker.test => mysql-test/suite/backup/t/backup_commit_blocker.test
mysql-test/t/backup_commit_restore.test => mysql-test/suite/backup/t/backup_commit_restore.test
mysql-test/t/backup_compression.test => mysql-test/suite/backup/t/backup_compression.test
mysql-test/t/backup_concurrent.test => mysql-test/suite/backup/t/backup_concurrent.test
mysql-test/t/backup_db_grants.test => mysql-test/suite/backup/t/backup_db_grants.test
mysql-test/t/backup_ddl_blocker.test => mysql-test/suite/backup/t/backup_ddl_blocker.test
mysql-test/t/backup_default.test => mysql-test/suite/backup/t/backup_default.test
mysql-test/t/backup_errors.test => mysql-test/suite/backup/t/backup_errors.test
mysql-test/t/backup_fkey.test => mysql-test/suite/backup/t/backup_fkey.test
mysql-test/t/backup_lock_myisam.test => mysql-test/suite/backup/t/backup_lock_myisam.test
mysql-test/t/backup_logs.test => mysql-test/suite/backup/t/backup_logs.test
mysql-test/t/backup_logs_output.test => mysql-test/suite/backup/t/backup_logs_output.test
mysql-test/t/backup_many_dbs.test => mysql-test/suite/backup/t/backup_many_dbs.test
mysql-test/t/backup_multi_blocks.test => mysql-test/suite/backup/t/backup_multi_blocks.test
mysql-test/t/backup_myisam1-master.opt => mysql-test/suite/backup/t/backup_myisam1-master.opt
mysql-test/t/backup_myisam1.test => mysql-test/suite/backup/t/backup_myisam1.test
mysql-test/t/backup_myisam2.test => mysql-test/suite/backup/t/backup_myisam2.test
mysql-test/t/backup_no_be.test => mysql-test/suite/backup/t/backup_no_be.test
mysql-test/t/backup_no_data.test => mysql-test/suite/backup/t/backup_no_data.test
mysql-test/t/backup_no_engine.test => mysql-test/suite/backup/t/backup_no_engine.test
mysql-test/t/backup_nodata_driver.test => mysql-test/suite/backup/t/backup_nodata_driver.test
mysql-test/t/backup_objects.test => mysql-test/suite/backup/t/backup_objects.test
mysql-test/t/backup_procedures.test => mysql-test/suite/backup/t/backup_procedures.test
mysql-test/t/backup_securefilepriv-master.opt => mysql-test/suite/backup/t/backup_securefilepriv-master.opt
mysql-test/t/backup_securefilepriv.test => mysql-test/suite/backup/t/backup_securefilepriv.test
mysql-test/t/backup_security.test => mysql-test/suite/backup/t/backup_security.test
mysql-test/t/backup_snapshot.opt => mysql-test/suite/backup/t/backup_snapshot.opt
mysql-test/t/backup_snapshot.test => mysql-test/suite/backup/t/backup_snapshot.test
mysql-test/t/backup_tablespace.test => mysql-test/suite/backup/t/backup_tablespace.test
mysql-test/t/backup_timeout.test => mysql-test/suite/backup/t/backup_timeout.test
mysql-test/t/backup_triggers_and_events.test => mysql-test/suite/backup/t/backup_triggers_and_events.test
mysql-test/t/backup_view_on_view.test => mysql-test/suite/backup/t/backup_view_on_view.test
mysql-test/t/backup_views.test => mysql-test/suite/backup/t/backup_views.test
modified:
.bzrignore
mysql-test/lib/mtr_report.pl
mysql-test/suite/backup_engines/t/backup_functions.test
mysql-test/suite/backup_engines/t/backup_procedures.test
mysql-test/suite/backup_engines/t/backup_triggers.test
mysql-test/t/ps.test
mysql-test/t/ps_1general.test
mysql-test/t/query_cache.test
mysql-test/t/subselect3.test
sql/backup/backup_info.cc
sql/backup/data_backup.cc
sql/backup/image_info.h
sql/backup/kernel.cc
sql/backup/logger.h
sql/backup/stream_v1.c
sql/backup/stream_v1_transport.c
sql/log.cc
sql/share/errmsg.txt
sql/si_logs.cc
sql/si_logs.h
mysql-test/suite/backup/r/backup.result
mysql-test/suite/backup/r/backup_errors.result
mysql-test/suite/backup/t/backup.test
mysql-test/suite/backup/t/backup_errors.test
mysql-test/suite/backup/t/backup_no_data.test
=== modified file '.bzrignore'
--- a/.bzrignore 2008-10-16 19:32:35 +0000
+++ b/.bzrignore 2008-10-21 09:07:23 +0000
@@ -51,6 +51,8 @@
*/relwithdebinfo/*
*~
.*.swp
+prot.*
+prot_test.*
./CMakeCache.txt
./MySql.ncb
./MySql.sln
@@ -600,6 +602,7 @@ libmysqld/protocol_cursor.cc
libmysqld/records.cc
libmysqld/repl_failsafe.cc
libmysqld/rpl_filter.cc
+libmysqld/rpl_handler.cc
libmysqld/rpl_injector.cc
libmysqld/rpl_record.cc
libmysqld/rpl_record_old.cc
@@ -875,6 +878,7 @@ mysql-test/suite/partitions/r/partition_
mysql-test/suite/partitions/r/partition_t55.out
mysql-test/suite/partitions/r/partition_t55.refout
mysql-test/suite/partitions/t/partition.test
+mysql-test/suite/rpl/t/rpl_view-slave.opt
mysql-test/t.log
mysql-test/t/index_merge.load
mysql-test/t/tmp.test
=== modified file 'mysql-test/lib/mtr_report.pl'
--- a/mysql-test/lib/mtr_report.pl 2008-10-02 08:52:13 +0000
+++ b/mysql-test/lib/mtr_report.pl 2008-10-16 14:30:35 +0000
@@ -329,43 +329,43 @@ sub mtr_report_stats ($) {
/Slave SQL:.*(?:Error_code: \d+|Query:.*)/ or
# backup_errors test is supposed to trigger lots of backup related errors
- ($testname eq 'main.backup_errors') and
+ ($testname eq 'backup.backup_errors') and
(
- /Backup:/ or /Restore:/ or /Can't open the backup log tables/
+ /Backup:/ or /Restore:/ or /Can't open the backup logs as tables/
) or
# backup_backupdir test is supposed to trigger backup related errors
- ($testname eq 'main.backup_backupdir') and
+ ($testname eq 'backup.backup_backupdir') and
(
/Backup:/ or /Can't write to backup location/
) or
# backup_concurrent performs a backup that should fail
- ($testname eq 'main.backup_concurrent') and
+ ($testname eq 'backup.backup_concurrent') and
(
/Can't execute this command because another BACKUP\/RESTORE operation is in progress/
) or
# backup_db_grants test is supposed to trigger lots of restore warnings
- ($testname eq 'main.backup_db_grants') and
+ ($testname eq 'backup.backup_db_grants') and
(
/Restore:/ or /was skipped because the user does not exist/
) or
# The tablespace test triggers error below on purpose
- ($testname eq 'main.backup_tablespace') and
+ ($testname eq 'backup.backup_tablespace') and
(
/Restore: Tablespace .* needed by tables being restored has changed on the server/
) or
# The backup_securefilepriv test triggers error below on purpose
- ($testname eq 'main.backup_securefilepriv') and
+ ($testname eq 'backup.backup_securefilepriv') and
(
/Backup: The MySQL server is running with the /
) or
# The views test triggers errors below on purpose
- ($testname eq 'main.backup_views') and
+ ($testname eq 'backup.backup_views') and
(
/Backup: Failed to add view/ or
/Backup: Failed to obtain meta-data for view/ or
@@ -373,11 +373,11 @@ sub mtr_report_stats ($) {
) or
# ignore warning generated when backup engine selection algorithm is tested
- ($testname eq 'main.backup_no_be') and /Backup: Cannot create backup engine/ or
+ ($testname eq 'backup.backup_no_be') and /Backup: Cannot create backup engine/ or
# ignore warnings generated when backup privilege is tested
- ($testname eq 'main.backup_security') and /(Backup|Restore): Access denied; you need the SUPER/ or
+ ($testname eq 'backup.backup_security') and /(Backup|Restore): Access denied; you need the SUPER/ or
- ($testname eq 'main.backup_myisam1') and
+ ($testname eq 'backup.backup_myisam1') and
(/Backup: Can't initialize MyISAM backup driver/) or
/Sort aborted/ or
/Time-out in NDB/ or
=== added directory 'mysql-test/suite/backup'
=== added directory 'mysql-test/suite/backup/r'
=== renamed file 'mysql-test/r/backup.result' => 'mysql-test/suite/backup/r/backup.result'
--- a/mysql-test/r/backup.result 2008-07-01 20:32:27 +0000
+++ b/mysql-test/suite/backup/r/backup.result 2008-10-07 17:15:44 +0000
@@ -10,17 +10,13 @@ CREATE TABLE `building` (
`dir_code` char(4),
`building` char(6)
) ENGINE=MYISAM DEFAULT CHARSET=latin1;
-LOCK TABLES `building` WRITE;
INSERT INTO `building` VALUES ('N41','1300'),('N01','1453'),('M00','1000'),('N41','1301'),('N41','1305');
-UNLOCK TABLES;
CREATE TABLE `directorate` (
`dir_code` char(4),
`dir_name` char(30),
`dir_head_id` char(9)
) ENGINE=MYISAM DEFAULT CHARSET=latin1;
-LOCK TABLES `directorate` WRITE;
INSERT INTO `directorate` VALUES ('N41','Development','333445555'),('N01','Human Resources','123654321'),('M00','Management','333444444');
-UNLOCK TABLES;
USE db2;
CREATE TABLE `staff` (
`id` char(9),
@@ -31,17 +27,13 @@ CREATE TABLE `staff` (
`salary` int(11),
`mgr_id` char(9)
) ENGINE=MYISAM DEFAULT CHARSET=latin1;
-LOCK TABLES `staff` WRITE;
INSERT INTO `staff` VALUES ('333445555','John','Q','Smith','M',30000,'333444444'),('123763153','William','E','Walters','M',25000,'123654321'),('333444444','Alicia','F','St.Cruz','F',25000,NULL),('921312388','Goy','X','Hong','F',40000,'123654321'),('800122337','Rajesh','G','Kardakarna','M',38000,'333445555'),('820123637','Monty','C','Smythe','M',38000,'333445555'),('830132335','Richard','E','Jones','M',38000,'333445555'),('333445665','Edward','E','Engles','M',25000,'333445555'),('123654321','Beware','D','Borg','F',55000,'333444444'),('123456789','Wilma','N','Maxima','F',43000,'333445555');
-UNLOCK TABLES;
CREATE TABLE `tasking` (
`id` char(9),
`project_number` char(9),
`hours_worked` double(10,2)
) ENGINE=blackhole DEFAULT CHARSET=latin1;
-LOCK TABLES `tasking` WRITE;
INSERT INTO `tasking` VALUES ('333445555','405',23),('123763153','405',33.5),('921312388','601',44),('800122337','300',13),('820123637','300',9.5),('830132335','401',8.5),('333445555','300',11),('921312388','500',13),('800122337','300',44),('820123637','401',500.5),('830132335','400',12),('333445665','600',300.25),('123654321','607',444.75),('123456789','300',1000);
-UNLOCK TABLES;
backup: Activate synchronization points for BACKUP.
Depending on the driver used, one of the sync points is used,
and the result differs in PROCESSLIST state and info.
@@ -67,12 +59,20 @@ breakpoints: Sending finish signal to wa
SET DEBUG_SYNC= 'now SIGNAL finish';
backup_id
#
+SELECT MAX(backup_id) FROM mysql.backup_history INTO @bid;
+SELECT validity_point_time FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_time;
+SELECT binlog_file FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_file;
+SELECT binlog_pos FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_pos;
DROP DATABASE db1;
DROP DATABASE db2;
USE mysql;
RESTORE FROM 'test.ba';
backup_id
#
+SELECT MAX(backup_id) FROM mysql.backup_history INTO @bid;
SHOW CREATE DATABASE db1;
Database Create Database
db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 */
@@ -132,6 +132,18 @@ tasking CREATE TABLE `tasking` (
`project_number` char(9) DEFAULT NULL,
`hours_worked` double(10,2) DEFAULT NULL
) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1
+SELECT validity_point_time = @vp_time FROM mysql.backup_history
+WHERE backup_id = @bid;
+validity_point_time = @vp_time
+1
+SELECT binlog_file = @vp_file FROM mysql.backup_history
+WHERE backup_id = @bid;
+binlog_file = @vp_file
+1
+SELECT binlog_pos = @vp_pos FROM mysql.backup_history
+WHERE backup_id = @bid;
+binlog_pos = @vp_pos
+1
DROP DATABASE db1;
DROP DATABASE db2;
DROP DATABASE db3;
=== renamed file 'mysql-test/r/backup_backupdir.result' => 'mysql-test/suite/backup/r/backup_backupdir.result'
=== renamed file 'mysql-test/r/backup_blob.result' => 'mysql-test/suite/backup/r/backup_blob.result'
=== renamed file 'mysql-test/r/backup_charsets.result' => 'mysql-test/suite/backup/r/backup_charsets.result'
=== added file 'mysql-test/suite/backup/r/backup_commit_backup.result'
--- a/mysql-test/suite/backup/r/backup_commit_backup.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_commit_backup.result 2008-10-07 17:15:44 +0000
@@ -0,0 +1,324 @@
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+CREATE TABLE db1.t1 (s1 CHAR(3)) ENGINE=innodb;
+CREATE TABLE db1.t2 (s1 CHAR(3)) ENGINE=falcon;
+CREATE TABLE db1.t3 (s1 CHAR(3)) ENGINE=memory;
+CREATE TABLE db1.t4 (s1 CHAR(3)) ENGINE=myisam;
+CREATE TABLE db2.t1 (s1 CHAR(3)) ENGINE=innodb;
+CREATE TABLE db2.t2 (s1 CHAR(3)) ENGINE=falcon;
+CREATE TABLE db2.t3 (s1 CHAR(3)) ENGINE=myisam;
+connection B - starting transaction B
+SET autocommit=0;
+BEGIN;
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+INSERT INTO db1.t1 VALUES ('b1');
+INSERT INTO db1.t2 VALUES ('b1');
+INSERT INTO db1.t3 VALUES ('b1');
+INSERT INTO db1.t4 VALUES ('b1');
+INSERT INTO db2.t1 VALUES ('b1');
+INSERT INTO db2.t2 VALUES ('b1');
+INSERT INTO db2.t3 VALUES ('b1');
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+SELECT * FROM db1.t2;
+s1
+SELECT * FROM db1.t3;
+s1
+b1
+SELECT * FROM db1.t4;
+s1
+b1
+SELECT * FROM db2.t1;
+s1
+SELECT * FROM db2.t2;
+s1
+SELECT * FROM db2.t3;
+s1
+b1
+SELECT release_lock("sync");
+release_lock("sync")
+1
+connection A - starting transaction A
+SET autocommit=0;
+BEGIN;
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+INSERT INTO db1.t1 VALUES ('a1');
+INSERT INTO db1.t2 VALUES ('a1');
+INSERT INTO db1.t3 VALUES ('a1');
+INSERT INTO db1.t4 VALUES ('a1');
+INSERT INTO db2.t1 VALUES ('a1');
+INSERT INTO db2.t2 VALUES ('a1');
+INSERT INTO db2.t3 VALUES ('a1');
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+SELECT * FROM db1.t2;
+s1
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+SELECT * FROM db2.t1;
+s1
+SELECT * FROM db2.t2;
+s1
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+SELECT release_lock("sync");
+release_lock("sync")
+1
+connection B - performing BACKUP which commits transaction B
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+INSERT INTO db1.t1 VALUES ('b2');
+INSERT INTO db1.t2 VALUES ('b2');
+INSERT INTO db1.t3 VALUES ('b2');
+INSERT INTO db1.t4 VALUES ('b2');
+INSERT INTO db2.t1 VALUES ('b2');
+INSERT INTO db2.t2 VALUES ('b2');
+INSERT INTO db2.t3 VALUES ('b2');
+BACKUP DATABASE db1 TO 'db1.bak';
+backup_id
+#
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+b1
+b2
+SELECT * FROM db1.t2;
+s1
+b1
+b2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+SELECT * FROM db2.t1;
+s1
+b1
+b2
+SELECT * FROM db2.t2;
+s1
+b1
+b2
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+b2
+SELECT release_lock("sync");
+release_lock("sync")
+1
+connection B - doing ROLLBACK which should be a no-op after the implicit commit
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+ROLLBACK;
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+b1
+b2
+SELECT * FROM db1.t2;
+s1
+b1
+b2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+SELECT * FROM db2.t1;
+s1
+b1
+b2
+SELECT * FROM db2.t2;
+s1
+b1
+b2
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+b2
+SELECT release_lock("sync");
+release_lock("sync")
+1
+connection A - finishing transaction A
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+INSERT INTO db1.t1 VALUES ('a2');
+INSERT INTO db1.t2 VALUES ('a2');
+INSERT INTO db1.t3 VALUES ('a2');
+INSERT INTO db1.t4 VALUES ('a2');
+INSERT INTO db2.t1 VALUES ('a2');
+INSERT INTO db2.t2 VALUES ('a2');
+INSERT INTO db2.t3 VALUES ('a2');
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+b1
+b2
+SELECT * FROM db1.t2;
+s1
+b1
+b2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db2.t1;
+s1
+b1
+b2
+SELECT * FROM db2.t2;
+s1
+b1
+b2
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+b2
+a2
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+COMMIT;
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db1.t2;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db2.t1;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db2.t2;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+b2
+a2
+SELECT release_lock("sync");
+release_lock("sync")
+1
+Checking contents of the backup image
+RESTORE FROM 'db1.bak';
+backup_id
+#
+SELECT * FROM db1.t1;
+s1
+b1
+b2
+SELECT * FROM db1.t2;
+s1
+b1
+b2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+DROP DATABASE db1;
+DROP DATABASE db2;
=== renamed file 'mysql-test/r/backup_commit_blocker.result' => 'mysql-test/suite/backup/r/backup_commit_blocker.result'
=== renamed file 'mysql-test/r/backup_commit_restore.result' => 'mysql-test/suite/backup/r/backup_commit_restore.result'
=== renamed file 'mysql-test/r/backup_compression.result' => 'mysql-test/suite/backup/r/backup_compression.result'
=== renamed file 'mysql-test/r/backup_concurrent.result' => 'mysql-test/suite/backup/r/backup_concurrent.result'
=== renamed file 'mysql-test/r/backup_db_grants.result' => 'mysql-test/suite/backup/r/backup_db_grants.result'
=== renamed file 'mysql-test/r/backup_ddl_blocker.result' => 'mysql-test/suite/backup/r/backup_ddl_blocker.result'
=== renamed file 'mysql-test/r/backup_default.result' => 'mysql-test/suite/backup/r/backup_default.result'
=== renamed file 'mysql-test/r/backup_errors.result' => 'mysql-test/suite/backup/r/backup_errors.result'
--- a/mysql-test/r/backup_errors.result 2008-08-27 17:35:10 +0000
+++ b/mysql-test/suite/backup/r/backup_errors.result 2008-10-07 17:15:44 +0000
@@ -75,7 +75,7 @@ backup_id
DROP TABLE mysql.backup_history;
Backup the database;
BACKUP DATABASE test_ob_error TO 'ob_err.bak';
-ERROR 42S02: Table 'mysql.backup_history' doesn't exist
+ERROR HY000: Can't open the backup logs as tables. Check 'mysql.backup_history' and 'mysql.backup_progress' or run mysql_upgrade to repair.
SHOW ERRORS;
Level Code Message
Error # Table 'mysql.backup_history' doesn't exist
@@ -86,7 +86,7 @@ DROP TABLE test.ob_copy;
DROP TABLE mysql.backup_progress;
Backup the database;
BACKUP DATABASE test_ob_error TO 'ob_err.bak';
-ERROR 42S02: Table 'mysql.backup_progress' doesn't exist
+ERROR HY000: Can't open the backup logs as tables. Check 'mysql.backup_history' and 'mysql.backup_progress' or run mysql_upgrade to repair.
SHOW ERRORS;
Level Code Message
Error # Table 'mysql.backup_progress' doesn't exist
=== renamed file 'mysql-test/r/backup_fkey.result' => 'mysql-test/suite/backup/r/backup_fkey.result'
=== renamed file 'mysql-test/r/backup_lock_myisam.result' => 'mysql-test/suite/backup/r/backup_lock_myisam.result'
=== renamed file 'mysql-test/r/backup_logs.result' => 'mysql-test/suite/backup/r/backup_logs.result'
=== renamed file 'mysql-test/r/backup_logs_output.result' => 'mysql-test/suite/backup/r/backup_logs_output.result'
=== renamed file 'mysql-test/r/backup_many_dbs.result' => 'mysql-test/suite/backup/r/backup_many_dbs.result'
=== renamed file 'mysql-test/r/backup_multi_blocks.result' => 'mysql-test/suite/backup/r/backup_multi_blocks.result'
=== renamed file 'mysql-test/r/backup_myisam1.result' => 'mysql-test/suite/backup/r/backup_myisam1.result'
=== renamed file 'mysql-test/r/backup_myisam2.result' => 'mysql-test/suite/backup/r/backup_myisam2.result'
=== renamed file 'mysql-test/r/backup_no_be.result' => 'mysql-test/suite/backup/r/backup_no_be.result'
=== renamed file 'mysql-test/r/backup_no_data.result' => 'mysql-test/suite/backup/r/backup_no_data.result'
=== renamed file 'mysql-test/r/backup_no_engine.result' => 'mysql-test/suite/backup/r/backup_no_engine.result'
=== renamed file 'mysql-test/r/backup_nodata_driver.result' => 'mysql-test/suite/backup/r/backup_nodata_driver.result'
=== renamed file 'mysql-test/r/backup_objects.result' => 'mysql-test/suite/backup/r/backup_objects.result'
=== renamed file 'mysql-test/r/backup_procedures.result' => 'mysql-test/suite/backup/r/backup_procedures.result'
=== renamed file 'mysql-test/r/backup_securefilepriv.result' => 'mysql-test/suite/backup/r/backup_securefilepriv.result'
=== renamed file 'mysql-test/r/backup_security.result' => 'mysql-test/suite/backup/r/backup_security.result'
=== renamed file 'mysql-test/r/backup_snapshot.result' => 'mysql-test/suite/backup/r/backup_snapshot.result'
=== renamed file 'mysql-test/r/backup_tablespace.result' => 'mysql-test/suite/backup/r/backup_tablespace.result'
=== renamed file 'mysql-test/r/backup_timeout.result' => 'mysql-test/suite/backup/r/backup_timeout.result'
=== renamed file 'mysql-test/r/backup_triggers_and_events.result' => 'mysql-test/suite/backup/r/backup_triggers_and_events.result'
=== renamed file 'mysql-test/r/backup_view_on_view.result' => 'mysql-test/suite/backup/r/backup_view_on_view.result'
=== renamed file 'mysql-test/r/backup_views.result' => 'mysql-test/suite/backup/r/backup_views.result'
=== added directory 'mysql-test/suite/backup/t'
=== renamed file 'mysql-test/t/backup.test' => 'mysql-test/suite/backup/t/backup.test'
--- a/mysql-test/t/backup.test 2008-07-01 20:32:27 +0000
+++ b/mysql-test/suite/backup/t/backup.test 2008-10-07 17:15:44 +0000
@@ -1,6 +1,7 @@
--source include/have_innodb.inc
--source include/not_embedded.inc
--source include/have_debug_sync.inc
+--source include/have_log_bin.inc
SET DEBUG_SYNC= 'RESET';
@@ -32,9 +33,7 @@ CREATE TABLE `building` (
# Dumping data for table `building`
#
-LOCK TABLES `building` WRITE;
INSERT INTO `building` VALUES ('N41','1300'),('N01','1453'),('M00','1000'),('N41','1301'),('N41','1305');
-UNLOCK TABLES;
#
@@ -51,9 +50,7 @@ CREATE TABLE `directorate` (
# Dumping data for table `directorate`
#
-LOCK TABLES `directorate` WRITE;
INSERT INTO `directorate` VALUES ('N41','Development','333445555'),('N01','Human Resources','123654321'),('M00','Management','333444444');
-UNLOCK TABLES;
USE db2;
@@ -75,9 +72,7 @@ CREATE TABLE `staff` (
# Dumping data for table `staff`
#
-LOCK TABLES `staff` WRITE;
INSERT INTO `staff` VALUES ('333445555','John','Q','Smith','M',30000,'333444444'),('123763153','William','E','Walters','M',25000,'123654321'),('333444444','Alicia','F','St.Cruz','F',25000,NULL),('921312388','Goy','X','Hong','F',40000,'123654321'),('800122337','Rajesh','G','Kardakarna','M',38000,'333445555'),('820123637','Monty','C','Smythe','M',38000,'333445555'),('830132335','Richard','E','Jones','M',38000,'333445555'),('333445665','Edward','E','Engles','M',25000,'333445555'),('123654321','Beware','D','Borg','F',55000,'333444444'),('123456789','Wilma','N','Maxima','F',43000,'333445555');
-UNLOCK TABLES;
#
# Table structure for table `tasking`
@@ -93,9 +88,7 @@ CREATE TABLE `tasking` (
# Dumping data for table `tasking`
#
-LOCK TABLES `tasking` WRITE;
INSERT INTO `tasking` VALUES ('333445555','405',23),('123763153','405',33.5),('921312388','601',44),('800122337','300',13),('820123637','300',9.5),('830132335','401',8.5),('333445555','300',11),('921312388','500',13),('800122337','300',44),('820123637','401',500.5),('830132335','400',12),('333445665','600',300.25),('123654321','607',444.75),('123456789','300',1000);
-UNLOCK TABLES;
#
# Get a lock to check for locking thread in process list
@@ -132,6 +125,18 @@ connection backup;
--replace_column 1 #
reap;
+# get backup_id of the BACKUP operation.
+SELECT MAX(backup_id) FROM mysql.backup_history INTO @bid;
+
+# store VP time and binlog position
+
+SELECT validity_point_time FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_time;
+SELECT binlog_file FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_file;
+SELECT binlog_pos FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_pos;
+
DROP DATABASE db1;
DROP DATABASE db2;
@@ -140,9 +145,15 @@ DROP DATABASE db2;
USE mysql;
+# wait few seconds so that restore time != backup time
+--sleep 2
+
--replace_column 1 #
RESTORE FROM 'test.ba';
+# determine id of RESTORE operation
+SELECT MAX(backup_id) FROM mysql.backup_history INTO @bid;
+
--remove_file $MYSQLTEST_VARDIR/master-data/test.ba
SHOW CREATE DATABASE db1;
@@ -167,6 +178,15 @@ CHECK TABLE staff EXTENDED;
SELECT * FROM staff;
SHOW CREATE TABLE tasking;
+# check that VP info was correctly read and reported
+
+SELECT validity_point_time = @vp_time FROM mysql.backup_history
+WHERE backup_id = @bid;
+SELECT binlog_file = @vp_file FROM mysql.backup_history
+WHERE backup_id = @bid;
+SELECT binlog_pos = @vp_pos FROM mysql.backup_history
+WHERE backup_id = @bid;
+
DROP DATABASE db1;
DROP DATABASE db2;
DROP DATABASE db3;
=== renamed file 'mysql-test/t/backup_backupdir.test' => 'mysql-test/suite/backup/t/backup_backupdir.test'
=== renamed file 'mysql-test/t/backup_blob.test' => 'mysql-test/suite/backup/t/backup_blob.test'
=== renamed file 'mysql-test/t/backup_charsets.test' => 'mysql-test/suite/backup/t/backup_charsets.test'
=== added file 'mysql-test/suite/backup/t/backup_commit_backup.test'
--- a/mysql-test/suite/backup/t/backup_commit_backup.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_commit_backup.test 2008-10-07 17:15:44 +0000
@@ -0,0 +1,230 @@
+#
+# This test tests interraction of BACKUP command with transactions in
+# the same and different connection (BUG#38261)
+#
+# BACKUP should commit ongoing transaction in the same connection but
+# should not interferre with transactions executing in other connections.
+#
+
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/have_falcon.inc
+
+
+LET $BDIR=`select @@backupdir`;
+
+disable_warnings;
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+error 0,1;
+remove_file $BDIR/db1.bak;
+enable_warnings;
+
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+CREATE TABLE db1.t1 (s1 CHAR(3)) ENGINE=innodb; # CS driver
+CREATE TABLE db1.t2 (s1 CHAR(3)) ENGINE=falcon; # CS driver
+CREATE TABLE db1.t3 (s1 CHAR(3)) ENGINE=memory; # default driver
+CREATE TABLE db1.t4 (s1 CHAR(3)) ENGINE=myisam; # native driver
+
+CREATE TABLE db2.t1 (s1 CHAR(3)) ENGINE=innodb; # trx1
+CREATE TABLE db2.t2 (s1 CHAR(3)) ENGINE=falcon; # trx2
+CREATE TABLE db2.t3 (s1 CHAR(3)) ENGINE=myisam; # non-trx
+
+
+# Create test connections. The setup is as follows
+#
+# connA connB
+# ----- -----
+# BEGIN
+# insert data
+# BEGIN
+# insert data
+# insert data
+# BACKUP
+# ROLLBACK
+# insert data
+# COMMIT
+#
+# The default connection is used to check contents of the tables after each
+# operation.
+#
+# Note: we use "sync" lock to synchronize connections. Without it, data
+# inserted in one thread could be not always seen in another one, which would
+# made test non-deterministic.
+
+ connect(connA, localhost, root,,);
+ connect(connB, localhost, root,,);
+
+ connection connB;
+ echo connection B - starting transaction B;
+ #------------------
+ SET autocommit=0;
+ BEGIN;
+
+ SELECT get_lock("sync",10);
+ INSERT INTO db1.t1 VALUES ('b1');
+ INSERT INTO db1.t2 VALUES ('b1');
+ INSERT INTO db1.t3 VALUES ('b1');
+ INSERT INTO db1.t4 VALUES ('b1');
+
+ INSERT INTO db2.t1 VALUES ('b1');
+ INSERT INTO db2.t2 VALUES ('b1');
+ INSERT INTO db2.t3 VALUES ('b1');
+ SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+ connection connA;
+ echo connection A - starting transaction A;
+ #------------------
+ SET autocommit=0;
+ BEGIN;
+
+ SELECT get_lock("sync",10);
+ INSERT INTO db1.t1 VALUES ('a1');
+ INSERT INTO db1.t2 VALUES ('a1');
+ INSERT INTO db1.t3 VALUES ('a1');
+ INSERT INTO db1.t4 VALUES ('a1');
+
+ INSERT INTO db2.t1 VALUES ('a1');
+ INSERT INTO db2.t2 VALUES ('a1');
+ INSERT INTO db2.t3 VALUES ('a1');
+ SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+ connection connB;
+ echo connection B - performing BACKUP which commits transaction B;
+ #------------------
+ SELECT get_lock("sync",10);
+ INSERT INTO db1.t1 VALUES ('b2');
+ INSERT INTO db1.t2 VALUES ('b2');
+ INSERT INTO db1.t3 VALUES ('b2');
+ INSERT INTO db1.t4 VALUES ('b2');
+
+ INSERT INTO db2.t1 VALUES ('b2');
+ INSERT INTO db2.t2 VALUES ('b2');
+ INSERT INTO db2.t3 VALUES ('b2');
+
+ replace_column 1 #;
+ BACKUP DATABASE db1 TO 'db1.bak';
+ SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+ connection connB;
+ echo connection B - doing ROLLBACK which should be a no-op after the implicit commit;
+ #------------------
+ SELECT get_lock("sync",10);
+ ROLLBACK;
+ SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+ connection connA;
+ echo connection A - finishing transaction A;
+ #------------------
+ SELECT get_lock("sync",10);
+ INSERT INTO db1.t1 VALUES ('a2');
+ INSERT INTO db1.t2 VALUES ('a2');
+ INSERT INTO db1.t3 VALUES ('a2');
+ INSERT INTO db1.t4 VALUES ('a2');
+
+ INSERT INTO db2.t1 VALUES ('a2');
+ INSERT INTO db2.t2 VALUES ('a2');
+ INSERT INTO db2.t3 VALUES ('a2');
+ SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+ connection connA;
+ #------------------
+ SELECT get_lock("sync",10);
+ COMMIT;
+ SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+echo Checking contents of the backup image;
+
+replace_column 1 #;
+RESTORE FROM 'db1.bak';
+
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+# Cleanup
+
+DROP DATABASE db1;
+DROP DATABASE db2;
+remove_file $BDIR/db1.bak;
=== renamed file 'mysql-test/t/backup_commit_blocker.test' => 'mysql-test/suite/backup/t/backup_commit_blocker.test'
=== renamed file 'mysql-test/t/backup_commit_restore.test' => 'mysql-test/suite/backup/t/backup_commit_restore.test'
=== renamed file 'mysql-test/t/backup_compression.test' => 'mysql-test/suite/backup/t/backup_compression.test'
=== renamed file 'mysql-test/t/backup_concurrent.test' => 'mysql-test/suite/backup/t/backup_concurrent.test'
=== renamed file 'mysql-test/t/backup_db_grants.test' => 'mysql-test/suite/backup/t/backup_db_grants.test'
=== renamed file 'mysql-test/t/backup_ddl_blocker.test' => 'mysql-test/suite/backup/t/backup_ddl_blocker.test'
=== renamed file 'mysql-test/t/backup_default.test' => 'mysql-test/suite/backup/t/backup_default.test'
=== renamed file 'mysql-test/t/backup_errors.test' => 'mysql-test/suite/backup/t/backup_errors.test'
--- a/mysql-test/t/backup_errors.test 2008-08-27 17:35:10 +0000
+++ b/mysql-test/suite/backup/t/backup_errors.test 2008-10-07 17:15:44 +0000
@@ -181,7 +181,7 @@ DROP TABLE mysql.backup_history;
# Try to backup the database (should be error).
--echo Backup the database;
---error ER_NO_SUCH_TABLE
+--error ER_BACKUP_PROGRESS_TABLES
BACKUP DATABASE test_ob_error TO 'ob_err.bak';
--error 0,1
--remove_file $MYSQLTEST_VARDIR/master-data/ob_err.bak
@@ -198,7 +198,7 @@ DROP TABLE mysql.backup_progress;
# Try to backup the database (should be error).
--echo Backup the database;
---error ER_NO_SUCH_TABLE
+--error ER_BACKUP_PROGRESS_TABLES
BACKUP DATABASE test_ob_error TO 'ob_err.bak';
--error 0,1
--remove_file $MYSQLTEST_VARDIR/master-data/ob_err.bak
=== renamed file 'mysql-test/t/backup_fkey.test' => 'mysql-test/suite/backup/t/backup_fkey.test'
=== renamed file 'mysql-test/t/backup_lock_myisam.test' => 'mysql-test/suite/backup/t/backup_lock_myisam.test'
=== renamed file 'mysql-test/t/backup_logs.test' => 'mysql-test/suite/backup/t/backup_logs.test'
=== renamed file 'mysql-test/t/backup_logs_output.test' => 'mysql-test/suite/backup/t/backup_logs_output.test'
=== renamed file 'mysql-test/t/backup_many_dbs.test' => 'mysql-test/suite/backup/t/backup_many_dbs.test'
=== renamed file 'mysql-test/t/backup_multi_blocks.test' => 'mysql-test/suite/backup/t/backup_multi_blocks.test'
=== renamed file 'mysql-test/t/backup_myisam1-master.opt' => 'mysql-test/suite/backup/t/backup_myisam1-master.opt'
=== renamed file 'mysql-test/t/backup_myisam1.test' => 'mysql-test/suite/backup/t/backup_myisam1.test'
=== renamed file 'mysql-test/t/backup_myisam2.test' => 'mysql-test/suite/backup/t/backup_myisam2.test'
=== renamed file 'mysql-test/t/backup_no_be.test' => 'mysql-test/suite/backup/t/backup_no_be.test'
=== renamed file 'mysql-test/t/backup_no_data.test' => 'mysql-test/suite/backup/t/backup_no_data.test'
--- a/mysql-test/t/backup_no_data.test 2008-02-14 20:57:18 +0000
+++ b/mysql-test/suite/backup/t/backup_no_data.test 2008-10-09 09:55:08 +0000
@@ -1,6 +1,8 @@
--source include/not_embedded.inc
--disable_warnings
+--rmdir $MYSQLTEST_VARDIR/master-data/test
+--mkdir $MYSQLTEST_VARDIR/master-data/test
DROP DATABASE IF EXISTS empty_db;
DROP DATABASE IF EXISTS other_db;
--enable_warnings
=== renamed file 'mysql-test/t/backup_no_engine.test' => 'mysql-test/suite/backup/t/backup_no_engine.test'
=== renamed file 'mysql-test/t/backup_nodata_driver.test' => 'mysql-test/suite/backup/t/backup_nodata_driver.test'
=== renamed file 'mysql-test/t/backup_objects.test' => 'mysql-test/suite/backup/t/backup_objects.test'
=== renamed file 'mysql-test/t/backup_procedures.test' => 'mysql-test/suite/backup/t/backup_procedures.test'
=== renamed file 'mysql-test/t/backup_securefilepriv-master.opt' => 'mysql-test/suite/backup/t/backup_securefilepriv-master.opt'
=== renamed file 'mysql-test/t/backup_securefilepriv.test' => 'mysql-test/suite/backup/t/backup_securefilepriv.test'
=== renamed file 'mysql-test/t/backup_security.test' => 'mysql-test/suite/backup/t/backup_security.test'
=== renamed file 'mysql-test/t/backup_snapshot.opt' => 'mysql-test/suite/backup/t/backup_snapshot.opt'
=== renamed file 'mysql-test/t/backup_snapshot.test' => 'mysql-test/suite/backup/t/backup_snapshot.test'
=== renamed file 'mysql-test/t/backup_tablespace.test' => 'mysql-test/suite/backup/t/backup_tablespace.test'
=== renamed file 'mysql-test/t/backup_timeout.test' => 'mysql-test/suite/backup/t/backup_timeout.test'
=== renamed file 'mysql-test/t/backup_triggers_and_events.test' => 'mysql-test/suite/backup/t/backup_triggers_and_events.test'
=== renamed file 'mysql-test/t/backup_view_on_view.test' => 'mysql-test/suite/backup/t/backup_view_on_view.test'
=== renamed file 'mysql-test/t/backup_views.test' => 'mysql-test/suite/backup/t/backup_views.test'
=== added file 'mysql-test/suite/backup/t/disabled.def'
--- a/mysql-test/suite/backup/t/disabled.def 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/disabled.def 2008-10-09 11:45:40 +0000
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# List the test cases that are to be disabled temporarily.
+#
+# Separate the test case name and the comment with ':'.
+#
+# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
+#
+# Do not use any TAB characters for whitespace.
+#
+##############################################################################
+backup_no_engine : Bug#36021 2008-04-13 rsomla server crashes when openning table with unknown storage engine
+backup_triggers_and_events : Bug#37762 2008-07-01 rafal Test fails on remove_file for unknown reasons
+backup_no_be : Bug#38023 2008-07-16 rafal Test triggers valgrind warnings described in the bug
+backup_no_data : Bug#17823 2008-10-09 rafal Tests in main suite leave undeleted files causing this test to fail
+backup_ddl_blocker : Bug#17823 2008-10-09 rafal Tests in main suite leave undeleted files causing this test to fail
=== renamed directory 'mysql-test/suite/backup' => 'mysql-test/suite/backup_engines'
=== added file 'mysql-test/suite/backup_engines/include/backup_ptr.inc'
--- a/mysql-test/suite/backup_engines/include/backup_ptr.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/backup_ptr.inc 2008-10-08 04:26:25 +0000
@@ -0,0 +1,386 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserved during
+# backup. In this test we perform both Data Manipulation Operations and
+# Data Definition Operations. We recover the data after and before backup
+# using both binlog positions and binlog dates.
+###############################################################################
+
+
+--source include/not_embedded.inc
+--source include/have_log_bin.inc
+SELECT @@BINLOG_FORMAT;
+RESET MASTER;
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr.bak;
+
+--echo **START TEST**
+--echo **** TEST1 ****
+--echo This test will recover data using binlog position
+--echo till point of backup and after backup.
+--echo
+
+#We set constant timestamp inside the test.
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+
+# Create database
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+--echo **** Creating tables ****
+CREATE TABLE ptr.t1(id INT, a CHAR(4));
+INSERT INTO ptr.t1 VALUES(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+SELECT * FROM ptr.t1;
+
+CREATE TABLE ptr.t3(id INT, b CHAR(4));
+INSERT INTO ptr.t3 VALUES
+(11,'aa'),(22,'bb'),(33,'cc'),(44,'dd'),(55,'ee');
+
+CREATE TABLE ptr.t2(id INT, deletes_data VARCHAR(30), updates_data TEXT);
+INSERT INTO ptr.t2 VALUES
+(100,'data1 for testing','update data1'),
+(200,'data2 for testing','update data2'),
+(300,'data3 for testing','update data3'),
+(400,'data4 for testing','update data4'),
+(500,'data5 for testing','update data5'),
+(100,'data1 for testing','update data1'),
+(600,'data6 for testing','update data6');
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT COUNT(*) FROM ptr.t2;
+
+--echo **** Creating tables with different datatypes ****
+
+CREATE TABLE ptr.d1(
+rint INT,
+tint TINYINT,
+sint SMALLINT,
+bint BIGINT,
+mint MEDIUMINT,
+name CHAR(100),
+city VARCHAR(100),
+fl FLOAT(7,4),
+pers DECIMAL(8,2),
+sal DOUBLE,
+colours SET('red','blue','yellow'),
+continent ENUM('Asia', 'Europe','Africa','Antartica'),
+ts TIMESTAMP DEFAULT 0,
+dob DATE,
+y YEAR
+);
+
+CREATE TABLE ptr.d2(
+region TEXT,
+summary LONGTEXT,
+data BLOB,
+details MEDIUMBLOB,
+queries TINYTEXT,
+query2 TINYBLOB,
+extract LONGBLOB,
+paras MEDIUMTEXT
+);
+
+INSERT INTO ptr.d1 VALUES
+(785,127,7288,278829899,3777,'testing1','sweden','678.299',200.23,829899.909,
+'yellow','Asia','2008-06-01 16:23:30','1984-09-08','1984');
+
+INSERT INTO ptr.d2 VALUES
+('xxxxxxxx','Testofonline backup','aaaaaaaaaa','bbbbbbbbbbb','hhhhhhhhhhh',
+'kkkkkkkkkkkkk','mmmmmmmmmmmm','onlinebackup1');
+
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo **** Perform Data Manipulation Operations ****
+--echo ## Delete ##
+DELETE FROM ptr.t2 WHERE deletes_data='data4 for testing';
+DELETE FROM ptr.t2 WHERE id=100 LIMIT 1;
+
+--echo ## Insert and Select ##
+--echo **** Now ptr.t2 will have 5 counts in the table ****
+--echo
+SELECT COUNT(*) FROM ptr.t2;
+INSERT INTO ptr.t2 VALUES
+(800,'data1 for replacement','replace data1');
+
+--echo ## Replace ##
+REPLACE INTO ptr.t2
+SET id=800, deletes_data='data replaced', updates_data='replace over';
+
+--echo ## Union ##
+SELECT * FROM ptr.t1 UNION SELECT * FROM ptr.t3;
+
+--echo ## Update ##
+UPDATE ptr.t2 SET updates_data='##VALUE UPDATED##' WHERE id=300;
+
+--echo Now table t2 will have 6 counts with one updated and replaced values
+SELECT COUNT(*) FROM ptr.t2;
+SELECT * FROM ptr.t2 ORDER BY id;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.d1;
+DESCRIBE ptr.d2;
+
+#--echo ## Perform table maintenence operations ##
+#We disable the table maintenence operations as it is supported by only
+#Myisam and Innodb engines. Falcon engine does not support table maintenance
+#operations.
+
+#ANALYZE TABLE d1;
+#ANALYZE TABLE t2;
+#CHECK TABLE d1;
+#CHECK TABLE t2;
+
+--echo **** Perform Data Definition Operations ****
+
+--echo ## ALTER ##
+ALTER TABLE ptr.t2 ADD COLUMN changes CHAR(20);
+
+UPDATE ptr.t2 SET changes='altered' WHERE id=200;
+UPDATE ptr.t2 SET changes='altered' WHERE id=100;
+
+ALTER TABLE ptr.t3 MODIFY b VARCHAR(4);
+
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+--echo **** Now we will check the data contents in all the tables again ****
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo ** Perform Backup operation and gather binlog position and dates **
+--echo ** Backup data **
+LET $backup_id = `BACKUP DATABASE ptr TO 'ptr.bak'`;
+set timestamp=@a+2;
+LET $binlog_pos = `SELECT binlog_pos FROM mysql.backup_history WHERE backup_id =$backup_id`;
+LET $binlog_file =query_get_value(SHOW MASTER STATUS, File, 1);
+
+--echo
+--echo Now execute some operations in the table after performing backup.
+--echo
+
+--echo
+--echo **** Perform some data manipulation operations ****
+
+INSERT INTO ptr.t1 VALUES(6,'f'),(7,'g');
+INSERT INTO ptr.d1 VALUES
+(10001,120,6550,7278634657,90667,'After backup','Minneapolis',782.9901,
+789.23,97806.456,'blue','Antartica','2008-08-07 15:12:44','1954-12-23','1954');
+
+INSERT INTO ptr.t3 VALUES(1,'ff'),(3,'kk');
+SELECT * FROM t1 UNION SELECT * FROM t3 ORDER BY a;
+
+UPDATE ptr.t3 SET b='mm' where b='kk';
+SELECT * FROM ptr.t3;
+
+DELETE FROM ptr.t2 WHERE id=200;
+SELECT * FROM ptr.t2 ORDER BY id;
+
+--echo
+--echo **** Perform some data definition operations ****
+
+ALTER TABLE ptr.t2 DROP COLUMN changes;
+ALTER TABLE ptr.t3 ENGINE=MEMORY;
+CREATE TABLE definition(details LONGTEXT);
+INSERT INTO definition VALUES
+('Performing some data definition statements for PTR');
+
+DESCRIBE ptr.t2;
+DESCRIBE ptr.definition;
+
+--echo
+--echo **** The tables t1, t2, t3 and t4 has changes ****
+--echo **** New table "definition" is created after backup *****
+--echo
+
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+SET TIMESTAMP=@a+4;
+LET $binpos=query_get_value(SHOW MASTER STATUS, Position, 1);
+LET $binfile=query_get_value(SHOW MASTER STATUS, File, 1);
+
+# Rotate logs. This frees the previous log so that we can dump it.
+FLUSH LOGS;
+DROP DATABASE ptr;
+
+--echo **** Execute mysqlbinlog to recover the data from start to backup ****
+
+--exec $MYSQL_BINLOG --database=ptr $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/q1.bin
+--exec $MYSQL_BINLOG --database=ptr --stop-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+# Verify that the table we just dropped has been restored
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo **** Now perform another recovery to recover data after backup ****
+--exec $MYSQL_BINLOG --database=ptr --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+DROP DATABASE ptr;
+
+--echo *** TEST2 *** :
+--echo Perform Restore and recover transactions after backup by executing
+--echo mysqlbinlog utility using binlog position.
+
+--echo Perform restore operation
+--replace_column 1 #
+RESTORE FROM 'ptr.bak';
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo Recovering data contents after backup
+--exec $MYSQL_BINLOG --database=ptr --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+DROP DATABASE ptr;
+
+--echo *** TEST3 *** :
+--echo This test will recover data using binlog dates
+--echo till point of backup and after backup.
+
+--echo Now use binlog dates to recover the data till point of backup.
+
+--exec $MYSQL_BINLOG --database=ptr --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo We execute binlog to recover data after backup using binlog dates.
+
+--exec $MYSQL_BINLOG --database=ptr --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+DROP DATABASE ptr;
+
+--echo *** TEST4 *** :
+--echo Perform Restore and recover transactions after backup by executing
+--echo mysqlbinlog utility using binlog dates.
+
+--replace_column 1 #
+RESTORE FROM 'ptr.bak';
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--exec $MYSQL_BINLOG --database=ptr --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+SHOW DATABASES;
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+DROP DATABASE ptr;
+
+--echo *** TEST5 *** :
+--echo Do complete recovery of data after backup using binlog position. Ensure
+--echo that presence of backup operation in the binlog shouldn't have any impact
+
+--exec $MYSQL_BINLOG --database=ptr --stop-position=$binpos $MYSQLTEST_VARDIR/log/$binfile |$MYSQL
+
+SHOW DATABASES;
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+DROP DATABASE ptr;
+
+--echo *** TEST6 *** :
+--echo Do complete recovery of data after backup using binlog dates. Ensure
+--echo that presence of backup operation in the binlog shouldn't have any impact
+
+--exec $MYSQL_BINLOG --database=ptr --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+SHOW DATABASES;
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+# Test cleanup section
+
+--echo
+--echo *** DROP ptr DATABASE ****
+--echo
+
+DROP DATABASE ptr;
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr.bak
=== added file 'mysql-test/suite/backup_engines/include/backup_ptr_commit.inc'
--- a/mysql-test/suite/backup_engines/include/backup_ptr_commit.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/backup_ptr_commit.inc 2008-10-08 04:26:25 +0000
@@ -0,0 +1,226 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery includes committed
+# transactions in the backup. In this test we will commit the data during
+# backup. This can be accomplished by using debug_sync points.
+###############################################################################
+
+
+--source include/have_debug_sync.inc
+--source include/have_innodb.inc
+--source include/not_embedded.inc
+--source include/have_log_bin.inc
+SELECT @@BINLOG_FORMAT;
+RESET MASTER;
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr_objects.bak;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connect (con3,localhost,root,,);
+
+connection con1;
+
+--echo **START TEST**
+--echo *** TEST1 ***
+--echo This test will recover data that were committed during backup
+--echo operation. This is acheived by means of debug_sync points
+--echo which pauses the backup database operation during commit.
+--echo
+
+#We set constant timestamp inside the test.
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+
+--disable_warnings
+SET DEBUG_SYNC= 'RESET';
+
+# Create database
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+--echo
+--echo con1: ***Creating Tables***
+
+CREATE TABLE ptr.t1(id INT, details CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t1 VALUES
+(1,'testing1'),(2,'testing2'),(3,'testing3'),
+(4,'testing4'),(5,'testing5'),(6,'testing6');
+
+CREATE TABLE ptr.t2(id INT, info CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t2 VALUES(201, 'aa1'),(202,'aa2');
+
+CREATE TABLE ptr.t3(id INT, name CHAR(20))ENGINE=INNODB;
+INSERT intO ptr.t3 VALUES(1,'ab1'),(2,'ab2'),(3,'ab3'),(4,'ab4'),(5,'ab5');
+
+--echo
+--echo con2:
+connection con2;
+START TRANSACTION;
+INSERT intO ptr.t2 VALUES(203, 'During backup-1'),(204,'During backup-2');
+UPDATE ptr.t3 SET name='hh1' WHERE id=1;
+DELETE FROM ptr.t1 WHERE id=5;
+DELETE FROM ptr.t1 WHERE id=6;
+
+--echo con1:
+connection con1;
+--echo The values should be: t1=6 t2=2 t3=5
+
+SELECT * FROM ptr.t1;
+SELECT COUNT(*) FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT COUNT(*) FROM ptr.t2;
+SELECT * FROM ptr.t3;
+SELECT COUNT(*) FROM ptr.t3;
+
+# Activate the sync point for BACKUP.
+# When BACKUP reaches the sync point it emits the signal bup_sync
+# and waits for another thread to emit the signal bup_finish.
+SET DEBUG_SYNC= 'before_backup_data_init SIGNAL bup_sync
+ WAIT_FOR bup_finish';
+send BACKUP DATABASE ptr TO 'ptr_commit.bak';
+
+--echo
+--echo con3: Waiting for BACKUP to reach the breakpoint
+connection con3;
+# If BACKUP did already reach its sync point, then the signal is already
+# present. If not, we wait until BACKUP emits it.
+SET DEBUG_SYNC= 'now WAIT_FOR bup_sync';
+
+--echo con2:
+connection con2;
+COMMIT;
+
+--echo
+--echo con3: Signalling that BACKUP can finish
+connection con3;
+SET DEBUG_SYNC= 'now SIGNAL bup_finish';
+
+--echo con1:
+connection con1;
+--echo con1: Fetching result of BACKUP
+--replace_column 1 #
+reap;
+set timestamp=@a+2;
+
+--echo con2:
+connection con2;
+--echo After commit the values of will be: t1=4, t2=4, t3=5
+SELECT COUNT(*) FROM ptr.t1;
+SELECT * FROM ptr.t1;
+SELECT COUNT(*) FROM ptr.t2;
+SELECT * FROM ptr.t2;
+SELECT COUNT(*) FROM ptr.t3;
+SELECT * FROM ptr.t3;
+
+LET $binlog_file =query_get_value(SHOW MASTER STATUS, File, 1);
+LET $binlog_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
+
+--echo con1:
+connection con1;
+--echo **** Perform some operations after backup ****
+INSERT intO ptr.t1 VALUES(10,'After Backup1'),(20,'After Backup2');
+UPDATE ptr.t2 SET info='After Backup-1' WHERE id=202;
+UPDATE ptr.t3 SET name='After Backup-1' WHERE id=2;
+set timestamp=@a+4;
+FLUSH LOGS;
+
+--echo Values in table after backup: t1=6,t2=4(202 updated), t3=5(2 updated)
+SELECT COUNT(*) FROM ptr.t1;
+SELECT * FROM ptr.t1;
+SELECT COUNT(*) FROM ptr.t2;
+SELECT * FROM ptr.t2;
+SELECT COUNT(*) FROM ptr.t3;
+SELECT * FROM ptr.t3;
+
+DROP DATABASE ptr;
+
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/qcommit.bin
+--exec $MYSQL_BINLOG --stop-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+--echo *** Recovering data till point of backup using mysql binlog_position ***
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--echo *** Recover data after backup ***
+--exec $MYSQL_BINLOG --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+DROP DATABASE ptr;
+
+--echo *** TEST2 ***
+--echo Perform Restore and Recover committed data using mysqlbinlog position
+--echo after backup.
+--echo
+
+--echo Perform restore operation
+--replace_column 1 #
+RESTORE FROM 'ptr_commit.bak';
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--exec $MYSQL_BINLOG --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+--echo *** Recover data using binlog position after backup ***
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+DROP DATABASE ptr;
+
+--echo *** TEST3 ***
+--echo Recover committed data during backup and after backup operation
+--echo using mysqlbinlog dates
+--echo
+
+--echo use binlog dates to recover data till backup.
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--echo use binlog dates to recover data after backup.
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+--echo *** Now recover data after backup using binlog dates ***
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--echo *** TEST4 ***
+--echo Perform Restore and Recover committed data using mysqlbinlog position
+--echo after backup.
+
+--echo Perform restore operation
+--replace_column 1 #
+RESTORE FROM 'ptr_commit.bak';
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+--echo *** Now recover data after backup using binlog dates ***
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+# Test cleanup section
+
+--echo
+--echo *** DROP ptr DATABASE ****
+--echo
+
+DROP DATABASE ptr;
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr_commit.bak
+SET DEBUG_SYNC= 'RESET';
=== added file 'mysql-test/suite/backup_engines/include/backup_ptr_objects.inc'
--- a/mysql-test/suite/backup_engines/include/backup_ptr_objects.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/backup_ptr_objects.inc 2008-10-08 04:26:25 +0000
@@ -0,0 +1,630 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery preserves all the
+# objects during backup. We include objects like tables, views, triggers,
+# stored procedures and stored functions. This test also verifies the
+# dependencies in objects are recovered properly using mysql binlog position
+# binlog dates.
+###############################################################################
+
+--source include/not_embedded.inc
+--source include/have_log_bin.inc
+SELECT @@BINLOG_FORMAT;
+RESET MASTER;
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr_objects.bak;
+
+--echo **START TEST**
+--echo *** TEST1 ***
+--echo This test will recover data and objects using binlog position
+--echo till point of backup and after backup.
+--echo
+
+#We set constant timestamp inside the test.
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+
+#
+# Two databases are created ptr_ob1 and ptr_ob2.
+# ptr_ob1 has tables t1, t2, t3, tv1 and views v ,v1, vv.
+# v --> ptr_ob1.t1, v1 --> ptr_ob2.t1, vv --> ptr_ob2.v1
+# ptr_ob2 has tables t1, t2 and views v1.
+# v1 --> ptr_ob1.tv1 + ptr_ob2.t2
+# trg1(before insert), trg2(after insert), trg4(after delete) and
+# trg5(before update) are in ptr_ob1.
+# trg3(before delete) and trg6(after update) are in ptr_ob2.
+# procedure p1, p2 and p3 are created in ptr_ob1 and p4 in ptr_ob2.
+#
+
+# Create database
+CREATE DATABASE IF NOT EXISTS ptr_ob1;
+CREATE DATABASE IF NOT EXISTS ptr_ob2;
+USE ptr_ob1;
+
+--echo **** Creating tables ****
+
+CREATE TABLE ptr_ob1.t1(
+ id INT,
+ a INT,
+ b CHAR(5)
+);
+
+CREATE TABLE ptr_ob1.t2(
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ data CHAR(50)
+);
+
+CREATE TABLE ptr_ob1.t3(
+ srno INT AUTO_INCREMENT,
+ PRIMARY KEY(srno),
+ name VARCHAR(30) NOT NULL,
+ old_a INT
+);
+
+CREATE TABLE ptr_ob2.t1(
+ id INT,
+ b CHAR(5)
+);
+
+CREATE TABLE ptr_ob2.t2(id SMALLINT);
+
+INSERT INTO ptr_ob2.t1 VALUES(11,'set1'),(21,'set2'),(3,'set3'),(4,'set4');
+INSERT INTO ptr_ob2.t2 VALUES(91),(5),(26),(33),(5);
+
+--echo **** Creating views ****
+
+CREATE VIEW ptr_ob1.v AS SELECT * FROM ptr_ob1.t1;
+CREATE VIEW ptr_ob1.v1 AS SELECT * FROM ptr_ob2.t1;
+
+CREATE TABLE ptr_ob1.tv1(id SMALLINT);
+INSERT INTO ptr_ob1.tv1 VALUES(1),(2),(3),(3),(5);
+SELECT * FROM ptr_ob1.tv1 UNION ALL SELECT * FROM ptr_ob2.t2;
+CREATE VIEW ptr_ob2.v1 AS SELECT * FROM ptr_ob1.tv1 UNION ALL
+SELECT * FROM ptr_ob2.t2 ORDER BY id;
+SELECT * FROM ptr_ob2.v1;
+
+--echo #### Creating view from another view ####
+CREATE VIEW ptr_ob1.vv AS SELECT SUM(id) from ptr_ob2.v1 GROUP BY id;
+SELECT * FROM ptr_ob1.vv;
+
+--echo **** Creating Triggers ****
+
+delimiter ||;
+CREATE TRIGGER ptr_ob1.trg1 BEFORE INSERT ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+ INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END;||
+delimiter ;||
+
+INSERT INTO ptr_ob1.t1 VALUES(1,20, 'bb1'), (2,50, 'bb2'),(3,80,'bb3');
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.t3;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT ON ptr_ob1.t2 FOR EACH ROW
+BEGIN
+ INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END;||
+delimiter ;||
+
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL, 'Normal Insert1'),(NULL, 'Normal Insert2'),
+(NULL, 'Normal Insert3'),(NULL, 'Normal Insert4');
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob2.trg3 BEFORE DELETE ON ptr_ob2.t2 FOR EACH ROW
+ SET @del_sum:= @del_sum + old.id;||
+ SET @del_sum:= 0;||
+delimiter ;||
+
+DELETE FROM ptr_ob2.t2 WHERE id=26;
+DELETE FROM ptr_ob2.t2 WHERE id=91;
+SELECT @del_sum;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob1.trg4 AFTER DELETE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+ INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END;||
+delimiter ;||
+
+DELETE FROM ptr_ob1.t1 WHERE id=2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob2.t1;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob1.trg5 BEFORE UPDATE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+ SET @id=old.id;
+ SET @a_old=old.a;
+ SET @a_new=new.a;
+END;
+||
+delimiter ;||
+
+UPDATE ptr_ob1.t1 SET a='85' WHERE b='bb3';
+SELECT @id, @a_old, @a_new;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob2.trg6 AFTER UPDATE ON ptr_ob2.t1 FOR EACH ROW
+BEGIN
+ INSERT INTO ptr_ob1.t2 VALUES
+ (NULL,'Trigger fired from after update of ptr_ob2.t1');
+END;
+||
+delimiter ;||
+
+UPDATE ptr_ob2.t1 SET b='alert' WHERE id=3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.v1;
+
+--echo
+--echo **** Creating stored Procedures and functions ****
+--echo
+
+--echo #### The procedure p1 will insert VALUES in view ####
+delimiter ||;
+CREATE PROCEDURE ptr_ob1.p1(details CHAR(40), id INT)
+BEGIN
+ INSERT INTO ptr_ob1.v1 VALUES(1,'fired');
+END;
+||
+
+--echo #### Procedure p2 will trigger trg2 ####
+
+CREATE PROCEDURE ptr_ob1.p2(content VARCHAR(40))
+BEGIN
+ INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Trigger fired from procedure p2');
+END;||
+
+--echo #### Procedure p3 will trigger trg6 ####
+
+CREATE PROCEDURE ptr_ob1.p3(info TEXT)
+BEGIN
+ UPDATE ptr_ob2.t1 SET b='#up#' WHERE id=4;
+END;||
+
+--echo #### Procedure p4 will call view ####
+
+CREATE PROCEDURE ptr_ob2.p4()
+BEGIN
+ SELECT * FROM ptr_ob2.v1;
+END;
+||
+
+--echo #### Function f1() ####
+
+CREATE FUNCTION f1() RETURNS INT
+RETURN (SELECT COUNT(*) FROM ptr_ob1.v1);||
+DELIMITER ;||
+
+SELECT f1();
+
+CALL ptr_ob1.p1('procedure p1 called for view v1', 1);
+CALL ptr_ob1.p1('procedure p1 called for view v1', 2);
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob2.t1;
+
+CALL ptr_ob1.p2('procedure p2 called for trg2');
+CALL ptr_ob1.p2('procedure p2 again called for trg2');
+
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+
+CALL ptr_ob1.p3('procedure p3 called for trg6');
+
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.t2;
+
+CALL ptr_ob2.p4();
+
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT * FROM ptr_ob1.tv1;
+
+--echo ** Checking data contents in all the tables before performing backup **
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+# Perform backup operation and obtain binlog position and dates.
+LET $backup_id = `BACKUP DATABASE ptr_ob1, ptr_ob2 TO 'ptr_objects.bak'`;
+set timestamp=@a+2;
+LET $binlog_pos = `SELECT binlog_pos FROM mysql.backup_history WHERE backup_id =$backup_id`;
+LET $binlog_file =query_get_value(SHOW MASTER STATUS, File, 1);
+
+--echo Make some changes to objects.
+
+ALTER VIEW ptr_ob1.v AS SELECT id, a FROM ptr_ob1.t1;
+ALTER TABLE ptr_ob1.vv RENAME TO ptr_ob1.vva;
+ALTER TABLE ptr_ob2.t2 ADD COLUMN af_backup VARCHAR(30);
+ALTER TABLE ptr_ob1.t3 CHANGE name name TEXT;
+DESCRIBE ptr_ob1.t3;
+ALTER PROCEDURE ptr_ob2.p4 COMMENT 'AFTER BACKUP';
+SELECT * FROM ptr_ob1.v;
+
+--echo Creating some new objects
+
+CREATE TABLE ptr_ob1.t11 (i INT, sr INT, j INT) engine=myisam;
+INSERT INTO ptr_ob1.t11 VALUES (1, 2, 3);
+CREATE TRIGGER ptr_ob1.ai AFTER INSERT ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.au AFTER UPDATE ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.ad AFTER DELETE ON ptr_ob1.t11 FOR EACH ROW SET @a:= old.sr;
+
+INSERT INTO ptr_ob1.t11 VALUES(4, 5, 6),(7, 8, 9);
+SELECT @a;
+UPDATE ptr_ob1.t11 SET i=10 WHERE sr=5;
+SELECT @a;
+DELETE FROM ptr_ob1.t11 WHERE sr=8;
+SELECT @a;
+
+--echo Now alter the table
+
+ALTER TABLE ptr_ob1.t11 DROP COLUMN j;
+SELECT * FROM ptr_ob1.t11;
+INSERT INTO ptr_ob1.t11 VALUES(11, 12);
+SELECT @a;
+
+--echo Firing existing triggers and calling procedures.
+
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Insert after backup');
+INSERT INTO ptr_ob2.t2 VALUES(10, 'af_bk1'),(2, 'af_bk2'),(7,'af_bk3'),(2,'af_bk4');
+DELETE FROM ptr_ob2.t2 WHERE id=10;
+SELECT @del_sum;
+
+CALL ptr_ob1.p1('procedure p1 af_bkup for view v1', 3);
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob2.t1;
+
+CALL ptr_ob1.p2('procedure p2 called af_bkup for trg2');
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+
+CALL ptr_ob1.p3('procedure p3 called af_bkup for trg6');
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.t2;
+
+CALL ptr_ob2.p4();
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.tv1;
+
+# Changes made after backup are:
+# ptr_ob1.v is altered, ptr_ob1.vv is renamed as vva.
+# ptr_ob2.t2 has new column added, ptr_ob1.t3 has datatype change.
+# Table ptr_ob1.t11 is created and triggers ptr_ob1.ai, au, ad is created.
+# procedure ptr_ob2.p4 is altered.
+
+--echo Checking the data contents after backup.
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+SET TIMESTAMP=@a+4;
+LET $binpos=query_get_value(SHOW MASTER STATUS, Position, 1);
+LET $binfile=query_get_value(SHOW MASTER STATUS, File, 1);
+
+# Rotate logs. This frees the previous log so that we can dump it.
+FLUSH LOGS;
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo **** Execute mysqlbinlog to recover the data from start to backup ****
+
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/qobject.bin
+--exec $MYSQL_BINLOG --stop-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+# Verify that the table we just dropped has been restored
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+--echo **** Now perform another recovery to recover data after backup ****
+
+--exec $MYSQL_BINLOG --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST2 *** :
+--echo Perform Restore and recover transactions after backup by executing
+--echo mysqlbinlog utility using binlog position.
+--echo
+
+--echo Perfrom Restore operation
+--replace_column 1 #
+RESTORE FROM 'ptr_objects.bak';
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+--echo Now use binlog position to recover data after backup
+--exec $MYSQL_BINLOG --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST3 *** :
+--echo This test will recover data and objects using binlog dates
+--echo till point of backup and after backup.
+--echo
+
+--echo Use mysqlbinlog dates to recover data till point of backup.
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+--echo Use mysqlbinlog dates to recover data after backup
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST4 *** :
+--echo Perform Restore and recover objects after backup by executing mysqlbinlog
+--echo utility using binlog dates.
+--echo
+
+--echo Perform Restore operation
+--replace_column 1 #
+RESTORE FROM 'ptr_objects.bak';
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+--echo use binlog dates to recover data after backup.
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST5 *** :
+--echo Do complete recovery of data after backup using binlog position. Ensure
+--echo that presence of backup operation in the binlog shouldn't have any impact
+
+--exec $MYSQL_BINLOG --stop-position=$binpos $MYSQLTEST_VARDIR/log/$binfile |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST6 *** :
+--echo Do complete recovery of data after backup using binlog dates. Ensure
+--echo that presence of backup operation in the binlog shouldn't have any impact
+
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+# Test cleanup section
+
+--echo
+--echo *** DROP ptr_ob1 and ptr_ob2 DATABASE ****
+--echo
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr_objects.bak
+
+
+
=== added file 'mysql-test/suite/backup_engines/include/not_have_falcon.inc'
--- a/mysql-test/suite/backup_engines/include/not_have_falcon.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/not_have_falcon.inc 2008-10-08 04:26:25 +0000
@@ -0,0 +1,9 @@
+# We will disable Falcon storage engine if we include not_have_falcon.inc
+# in our test case.
+
+--replace_result $ENGINE ENGINE
+if(`SELECT '$ENGINE'='falcon'`)
+{
+ skip "This test does not support Falcon engine";
+}
+
=== added file 'mysql-test/suite/backup_engines/include/not_have_innodb.inc'
--- a/mysql-test/suite/backup_engines/include/not_have_innodb.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/not_have_innodb.inc 2008-10-08 04:26:25 +0000
@@ -0,0 +1,10 @@
+# We will disable Innodb storage engine if we include not_have_innodb.inc
+# in our test case.
+
+
+--replace_result $ENGINE ENGINE
+if(`SELECT '$ENGINE'='innodb'`)
+{
+ skip "This test does not support Innodb engine";
+}
+
=== added file 'mysql-test/suite/backup_engines/include/not_have_memory.inc'
--- a/mysql-test/suite/backup_engines/include/not_have_memory.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/not_have_memory.inc 2008-10-08 04:26:25 +0000
@@ -0,0 +1,10 @@
+# We will disable Memory storage engine if we include not_have_memory.inc
+# in our test case.
+
+
+--replace_result $ENGINE ENGINE
+if(`SELECT '$ENGINE'='memory'`)
+{
+ skip "This test does not support memory engine";
+}
+
=== added file 'mysql-test/suite/backup_engines/include/not_have_myisam.inc'
--- a/mysql-test/suite/backup_engines/include/not_have_myisam.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/not_have_myisam.inc 2008-10-08 04:26:25 +0000
@@ -0,0 +1,10 @@
+# We will disable Myisam storage engine if we include not_have_myisam.inc
+# in our test case.
+
+
+--replace_result $ENGINE ENGINE
+if(`SELECT '$ENGINE'='myisam'`)
+{
+ skip "This test does not support Myisam engine";
+}
+
=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result 2008-10-08 04:26:25 +0000
@@ -0,0 +1,360 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name Value
+storage_engine #
+SET GLOBAL BINLOG_FORMAT='MIXED';
+SET BINLOG_FORMAT='MIXED';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+MIXED
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data that were committed during backup
+operation. This is acheived by means of debug_sync points
+which pauses the backup database operation during commit.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+SET DEBUG_SYNC= 'RESET';
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+con1: ***Creating Tables***
+CREATE TABLE ptr.t1(id INT, details CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t1 VALUES
+(1,'testing1'),(2,'testing2'),(3,'testing3'),
+(4,'testing4'),(5,'testing5'),(6,'testing6');
+CREATE TABLE ptr.t2(id INT, info CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t2 VALUES(201, 'aa1'),(202,'aa2');
+CREATE TABLE ptr.t3(id INT, name CHAR(20))ENGINE=INNODB;
+INSERT intO ptr.t3 VALUES(1,'ab1'),(2,'ab2'),(3,'ab3'),(4,'ab4'),(5,'ab5');
+
+con2:
+START TRANSACTION;
+INSERT intO ptr.t2 VALUES(203, 'During backup-1'),(204,'During backup-2');
+UPDATE ptr.t3 SET name='hh1' WHERE id=1;
+DELETE FROM ptr.t1 WHERE id=5;
+DELETE FROM ptr.t1 WHERE id=6;
+con1:
+The values should be: t1=6 t2=2 t3=5
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+5 testing5
+6 testing6
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+2
+SELECT * FROM ptr.t3;
+id name
+1 ab1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SET DEBUG_SYNC= 'before_backup_data_init SIGNAL bup_sync
+ WAIT_FOR bup_finish';
+BACKUP DATABASE ptr TO 'ptr_commit.bak';
+
+con3: Waiting for BACKUP to reach the breakpoint
+SET DEBUG_SYNC= 'now WAIT_FOR bup_sync';
+con2:
+COMMIT;
+
+con3: Signalling that BACKUP can finish
+SET DEBUG_SYNC= 'now SIGNAL bup_finish';
+con1:
+con1: Fetching result of BACKUP
+backup_id
+#
+set timestamp=@a+2;
+con2:
+After commit the values of will be: t1=4, t2=4, t3=5
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+4
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+con1:
+**** Perform some operations after backup ****
+INSERT intO ptr.t1 VALUES(10,'After Backup1'),(20,'After Backup2');
+UPDATE ptr.t2 SET info='After Backup-1' WHERE id=202;
+UPDATE ptr.t3 SET name='After Backup-1' WHERE id=2;
+set timestamp=@a+4;
+FLUSH LOGS;
+Values in table after backup: t1=6,t2=4(202 updated), t3=5(2 updated)
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+DROP DATABASE ptr;
+*** Recovering data till point of backup using mysql binlog_position ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+*** Recover data after backup ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+DROP DATABASE ptr;
+*** TEST2 ***
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+*** Recover data using binlog position after backup ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+DROP DATABASE ptr;
+*** TEST3 ***
+Recover committed data during backup and after backup operation
+using mysqlbinlog dates
+
+use binlog dates to recover data till backup.
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+use binlog dates to recover data after backup.
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+*** TEST4 ***
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+
+*** DROP ptr DATABASE ****
+
+DROP DATABASE ptr;
+SET DEBUG_SYNC= 'RESET';
=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result 2008-10-08 04:26:25 +0000
@@ -0,0 +1,360 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name Value
+storage_engine #
+SET GLOBAL BINLOG_FORMAT='ROW';
+SET BINLOG_FORMAT='ROW';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+ROW
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data that were committed during backup
+operation. This is acheived by means of debug_sync points
+which pauses the backup database operation during commit.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+SET DEBUG_SYNC= 'RESET';
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+con1: ***Creating Tables***
+CREATE TABLE ptr.t1(id INT, details CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t1 VALUES
+(1,'testing1'),(2,'testing2'),(3,'testing3'),
+(4,'testing4'),(5,'testing5'),(6,'testing6');
+CREATE TABLE ptr.t2(id INT, info CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t2 VALUES(201, 'aa1'),(202,'aa2');
+CREATE TABLE ptr.t3(id INT, name CHAR(20))ENGINE=INNODB;
+INSERT intO ptr.t3 VALUES(1,'ab1'),(2,'ab2'),(3,'ab3'),(4,'ab4'),(5,'ab5');
+
+con2:
+START TRANSACTION;
+INSERT intO ptr.t2 VALUES(203, 'During backup-1'),(204,'During backup-2');
+UPDATE ptr.t3 SET name='hh1' WHERE id=1;
+DELETE FROM ptr.t1 WHERE id=5;
+DELETE FROM ptr.t1 WHERE id=6;
+con1:
+The values should be: t1=6 t2=2 t3=5
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+5 testing5
+6 testing6
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+2
+SELECT * FROM ptr.t3;
+id name
+1 ab1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SET DEBUG_SYNC= 'before_backup_data_init SIGNAL bup_sync
+ WAIT_FOR bup_finish';
+BACKUP DATABASE ptr TO 'ptr_commit.bak';
+
+con3: Waiting for BACKUP to reach the breakpoint
+SET DEBUG_SYNC= 'now WAIT_FOR bup_sync';
+con2:
+COMMIT;
+
+con3: Signalling that BACKUP can finish
+SET DEBUG_SYNC= 'now SIGNAL bup_finish';
+con1:
+con1: Fetching result of BACKUP
+backup_id
+#
+set timestamp=@a+2;
+con2:
+After commit the values of will be: t1=4, t2=4, t3=5
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+4
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+con1:
+**** Perform some operations after backup ****
+INSERT intO ptr.t1 VALUES(10,'After Backup1'),(20,'After Backup2');
+UPDATE ptr.t2 SET info='After Backup-1' WHERE id=202;
+UPDATE ptr.t3 SET name='After Backup-1' WHERE id=2;
+set timestamp=@a+4;
+FLUSH LOGS;
+Values in table after backup: t1=6,t2=4(202 updated), t3=5(2 updated)
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+DROP DATABASE ptr;
+*** Recovering data till point of backup using mysql binlog_position ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+*** Recover data after backup ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+DROP DATABASE ptr;
+*** TEST2 ***
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+*** Recover data using binlog position after backup ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+DROP DATABASE ptr;
+*** TEST3 ***
+Recover committed data during backup and after backup operation
+using mysqlbinlog dates
+
+use binlog dates to recover data till backup.
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+use binlog dates to recover data after backup.
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+*** TEST4 ***
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+
+*** DROP ptr DATABASE ****
+
+DROP DATABASE ptr;
+SET DEBUG_SYNC= 'RESET';
=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result 2008-10-08 04:26:25 +0000
@@ -0,0 +1,360 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name Value
+storage_engine #
+SET GLOBAL BINLOG_FORMAT='STATEMENT';
+SET BINLOG_FORMAT='STATEMENT';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+STATEMENT
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data that were committed during backup
+operation. This is acheived by means of debug_sync points
+which pauses the backup database operation during commit.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+SET DEBUG_SYNC= 'RESET';
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+con1: ***Creating Tables***
+CREATE TABLE ptr.t1(id INT, details CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t1 VALUES
+(1,'testing1'),(2,'testing2'),(3,'testing3'),
+(4,'testing4'),(5,'testing5'),(6,'testing6');
+CREATE TABLE ptr.t2(id INT, info CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t2 VALUES(201, 'aa1'),(202,'aa2');
+CREATE TABLE ptr.t3(id INT, name CHAR(20))ENGINE=INNODB;
+INSERT intO ptr.t3 VALUES(1,'ab1'),(2,'ab2'),(3,'ab3'),(4,'ab4'),(5,'ab5');
+
+con2:
+START TRANSACTION;
+INSERT intO ptr.t2 VALUES(203, 'During backup-1'),(204,'During backup-2');
+UPDATE ptr.t3 SET name='hh1' WHERE id=1;
+DELETE FROM ptr.t1 WHERE id=5;
+DELETE FROM ptr.t1 WHERE id=6;
+con1:
+The values should be: t1=6 t2=2 t3=5
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+5 testing5
+6 testing6
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+2
+SELECT * FROM ptr.t3;
+id name
+1 ab1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SET DEBUG_SYNC= 'before_backup_data_init SIGNAL bup_sync
+ WAIT_FOR bup_finish';
+BACKUP DATABASE ptr TO 'ptr_commit.bak';
+
+con3: Waiting for BACKUP to reach the breakpoint
+SET DEBUG_SYNC= 'now WAIT_FOR bup_sync';
+con2:
+COMMIT;
+
+con3: Signalling that BACKUP can finish
+SET DEBUG_SYNC= 'now SIGNAL bup_finish';
+con1:
+con1: Fetching result of BACKUP
+backup_id
+#
+set timestamp=@a+2;
+con2:
+After commit the values of will be: t1=4, t2=4, t3=5
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+4
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+con1:
+**** Perform some operations after backup ****
+INSERT intO ptr.t1 VALUES(10,'After Backup1'),(20,'After Backup2');
+UPDATE ptr.t2 SET info='After Backup-1' WHERE id=202;
+UPDATE ptr.t3 SET name='After Backup-1' WHERE id=2;
+set timestamp=@a+4;
+FLUSH LOGS;
+Values in table after backup: t1=6,t2=4(202 updated), t3=5(2 updated)
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+DROP DATABASE ptr;
+*** Recovering data till point of backup using mysql binlog_position ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+*** Recover data after backup ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+DROP DATABASE ptr;
+*** TEST2 ***
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+*** Recover data using binlog position after backup ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+DROP DATABASE ptr;
+*** TEST3 ***
+Recover committed data during backup and after backup operation
+using mysqlbinlog dates
+
+use binlog dates to recover data till backup.
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+use binlog dates to recover data after backup.
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+*** TEST4 ***
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 aa2
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 ab2
+3 ab3
+4 ab4
+5 ab5
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id details
+1 testing1
+2 testing2
+3 testing3
+4 testing4
+10 After Backup1
+20 After Backup2
+SELECT * FROM ptr.t2;
+id info
+201 aa1
+202 After Backup-1
+203 During backup-1
+204 During backup-2
+SELECT * FROM ptr.t3;
+id name
+1 hh1
+2 After Backup-1
+3 ab3
+4 ab4
+5 ab5
+
+*** DROP ptr DATABASE ****
+
+DROP DATABASE ptr;
+SET DEBUG_SYNC= 'RESET';
=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_mixed.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_mixed.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_mixed.result 2008-10-08 04:26:25 +0000
@@ -0,0 +1,843 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name Value
+storage_engine #
+SET GLOBAL BINLOG_FORMAT='MIXED';
+SET BINLOG_FORMAT='MIXED';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+MIXED
+RESET MASTER;
+**START TEST**
+**** TEST1 ****
+This test will recover data using binlog position
+till point of backup and after backup.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+**** Creating tables ****
+CREATE TABLE ptr.t1(id INT, a CHAR(4));
+INSERT INTO ptr.t1 VALUES(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+CREATE TABLE ptr.t3(id INT, b CHAR(4));
+INSERT INTO ptr.t3 VALUES
+(11,'aa'),(22,'bb'),(33,'cc'),(44,'dd'),(55,'ee');
+CREATE TABLE ptr.t2(id INT, deletes_data VARCHAR(30), updates_data TEXT);
+INSERT INTO ptr.t2 VALUES
+(100,'data1 for testing','update data1'),
+(200,'data2 for testing','update data2'),
+(300,'data3 for testing','update data3'),
+(400,'data4 for testing','update data4'),
+(500,'data5 for testing','update data5'),
+(100,'data1 for testing','update data1'),
+(600,'data6 for testing','update data6');
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data
+100 data1 for testing update data1
+100 data1 for testing update data1
+200 data2 for testing update data2
+300 data3 for testing update data3
+400 data4 for testing update data4
+500 data5 for testing update data5
+600 data6 for testing update data6
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+7
+**** Creating tables with different datatypes ****
+CREATE TABLE ptr.d1(
+rint INT,
+tint TINYINT,
+sint SMALLINT,
+bint BIGINT,
+mint MEDIUMINT,
+name CHAR(100),
+city VARCHAR(100),
+fl FLOAT(7,4),
+pers DECIMAL(8,2),
+sal DOUBLE,
+colours SET('red','blue','yellow'),
+continent ENUM('Asia', 'Europe','Africa','Antartica'),
+ts TIMESTAMP DEFAULT 0,
+dob DATE,
+y YEAR
+);
+CREATE TABLE ptr.d2(
+region TEXT,
+summary LONGTEXT,
+data BLOB,
+details MEDIUMBLOB,
+queries TINYTEXT,
+query2 TINYBLOB,
+extract LONGBLOB,
+paras MEDIUMTEXT
+);
+INSERT INTO ptr.d1 VALUES
+(785,127,7288,278829899,3777,'testing1','sweden','678.299',200.23,829899.909,
+'yellow','Asia','2008-06-01 16:23:30','1984-09-08','1984');
+INSERT INTO ptr.d2 VALUES
+('xxxxxxxx','Testofonline backup','aaaaaaaaaa','bbbbbbbbbbb','hhhhhhhhhhh',
+'kkkkkkkkkkkkk','mmmmmmmmmmmm','onlinebackup1');
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+**** Perform Data Manipulation Operations ****
+## Delete ##
+DELETE FROM ptr.t2 WHERE deletes_data='data4 for testing';
+DELETE FROM ptr.t2 WHERE id=100 LIMIT 1;
+## Insert and Select ##
+**** Now ptr.t2 will have 5 counts in the table ****
+
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+5
+INSERT INTO ptr.t2 VALUES
+(800,'data1 for replacement','replace data1');
+## Replace ##
+REPLACE INTO ptr.t2
+SET id=800, deletes_data='data replaced', updates_data='replace over';
+## Union ##
+SELECT * FROM ptr.t1 UNION SELECT * FROM ptr.t3;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+## Update ##
+UPDATE ptr.t2 SET updates_data='##VALUE UPDATED##' WHERE id=300;
+Now table t2 will have 6 counts with one updated and replaced values
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+7
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data
+100 data1 for testing update data1
+200 data2 for testing update data2
+300 data3 for testing ##VALUE UPDATED##
+500 data5 for testing update data5
+600 data6 for testing update data6
+800 data1 for replacement replace data1
+800 data replaced replace over
+DESCRIBE ptr.t1;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+a char(4) YES NULL
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+DESCRIBE ptr.d1;
+Field Type Null Key Default Extra
+rint int(11) YES NULL
+tint tinyint(4) YES NULL
+sint smallint(6) YES NULL
+bint bigint(20) YES NULL
+mint mediumint(9) YES NULL
+name char(100) YES NULL
+city varchar(100) YES NULL
+fl float(7,4) YES NULL
+pers decimal(8,2) YES NULL
+sal double YES NULL
+colours set('red','blue','yellow') YES NULL
+continent enum('Asia','Europe','Africa','Antartica') YES NULL
+ts timestamp NO 0000-00-00 00:00:00
+dob date YES NULL
+y year(4) YES NULL
+DESCRIBE ptr.d2;
+Field Type Null Key Default Extra
+region text YES NULL
+summary longtext YES NULL
+data blob YES NULL
+details mediumblob YES NULL
+queries tinytext YES NULL
+query2 tinyblob YES NULL
+extract longblob YES NULL
+paras mediumtext YES NULL
+**** Perform Data Definition Operations ****
+## ALTER ##
+ALTER TABLE ptr.t2 ADD COLUMN changes CHAR(20);
+UPDATE ptr.t2 SET changes='altered' WHERE id=200;
+UPDATE ptr.t2 SET changes='altered' WHERE id=100;
+ALTER TABLE ptr.t3 MODIFY b VARCHAR(4);
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+changes char(20) YES NULL
+DESCRIBE ptr.t3;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+b varchar(4) YES NULL
+**** Now we will check the data contents in all the tables again ****
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data changes
+100 data1 for testing update data1 altered
+200 data2 for testing update data2 altered
+300 data3 for testing ##VALUE UPDATED## NULL
+500 data5 for testing update data5 NULL
+600 data6 for testing update data6 NULL
+800 data1 for replacement replace data1 NULL
+800 data replaced replace over NULL
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+** Perform Backup operation and gather binlog position and dates **
+** Backup data **
+set timestamp=@a+2;
+
+Now execute some operations in the table after performing backup.
+
+
+**** Perform some data manipulation operations ****
+INSERT INTO ptr.t1 VALUES(6,'f'),(7,'g');
+INSERT INTO ptr.d1 VALUES
+(10001,120,6550,7278634657,90667,'After backup','Minneapolis',782.9901,
+789.23,97806.456,'blue','Antartica','2008-08-07 15:12:44','1954-12-23','1954');
+INSERT INTO ptr.t3 VALUES(1,'ff'),(3,'kk');
+SELECT * FROM t1 UNION SELECT * FROM t3 ORDER BY a;
+id a
+1 a
+11 aa
+2 b
+22 bb
+3 c
+33 cc
+4 d
+44 dd
+5 e
+55 ee
+6 f
+1 ff
+7 g
+3 kk
+UPDATE ptr.t3 SET b='mm' where b='kk';
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+1 ff
+3 mm
+DELETE FROM ptr.t2 WHERE id=200;
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data changes
+100 data1 for testing update data1 altered
+300 data3 for testing ##VALUE UPDATED## NULL
+500 data5 for testing update data5 NULL
+600 data6 for testing update data6 NULL
+800 data1 for replacement replace data1 NULL
+800 data replaced replace over NULL
+
+**** Perform some data definition operations ****
+ALTER TABLE ptr.t2 DROP COLUMN changes;
+ALTER TABLE ptr.t3 ENGINE=MEMORY;
+CREATE TABLE definition(details LONGTEXT);
+INSERT INTO definition VALUES
+('Performing some data definition statements for PTR');
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+DESCRIBE ptr.definition;
+Field Type Null Key Default Extra
+details longtext YES NULL
+
+**** The tables t1, t2, t3 and t4 has changes ****
+**** New table "definition" is created after backup *****
+
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+6 f
+7 g
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data
+100 data1 for testing update data1
+300 data3 for testing ##VALUE UPDATED##
+500 data5 for testing update data5
+600 data6 for testing update data6
+800 data1 for replacement replace data1
+800 data replaced replace over
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+1 ff
+3 mm
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+10001 120 6550 7278634657 90667 After backup Minneapolis 782.9901 789.23 97806.456 blue Antartica 2008-08-07 15:12:44 1954-12-23 1954
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+SET TIMESTAMP=@a+4;
+FLUSH LOGS;
+DROP DATABASE ptr;
+**** Execute mysqlbinlog to recover the data from start to backup ****
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data changes
+100 data1 for testing update data1 altered
+200 data2 for testing update data2 altered
+300 data3 for testing ##VALUE UPDATED## NULL
+500 data5 for testing update data5 NULL
+600 data6 for testing update data6 NULL
+800 data1 for replacement replace data1 NULL
+800 data replaced replace over NULL
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+**** Now perform another recovery to recover data after backup ****
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+a char(4) YES NULL
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+DESCRIBE ptr.t3;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+b varchar(4) YES NULL
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+6 f
+7 g
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data
+100 data1 for testing update data1
+300 data3 for testing ##VALUE UPDATED##
+500 data5 for testing update data5
+600 data6 for testing update data6
+800 data1 for replacement replace data1
+800 data replaced replace over
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+1 ff
+3 mm
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+10001 120 6550 7278634657 90667 After backup Minneapolis 782.9901 789.23 97806.456 blue Antartica 2008-08-07 15:12:44 1954-12-23 1954
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+DROP DATABASE ptr;
+*** TEST2 *** :
+Perform Restore and recover transactions after backup by executing
+mysqlbinlog utility using binlog position.
+Perform restore operation
+RESTORE FROM 'ptr.bak';
+backup_id
+#
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data changes
+100 data1 for testing update data1 altered
+200 data2 for testing update data2 altered
+300 data3 for testing ##VALUE UPDATED## NULL
+500 data5 for testing update data5 NULL
+600 data6 for testing update data6 NULL
+800 data1 for replacement replace data1 NULL
+800 data replaced replace over NULL
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+Recovering data contents after backup
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+a char(4) YES NULL
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+DESCRIBE ptr.t3;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+b varchar(4) YES NULL
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+6 f
+7 g
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data
+100 data1 for testing update data1
+300 data3 for testing ##VALUE UPDATED##
+500 data5 for testing update data5
+600 data6 for testing update data6
+800 data1 for replacement replace data1
+800 data replaced replace over
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+1 ff
+3 mm
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+10001 120 6550 7278634657 90667 After backup Minneapolis 782.9901 789.23 97806.456 blue Antartica 2008-08-07 15:12:44 1954-12-23 1954
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+DROP DATABASE ptr;
+*** TEST3 *** :
+This test will recover data using binlog dates
+till point of backup and after backup.
+Now use binlog dates to recover the data till point of backup.
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data changes
+100 data1 for testing update data1 altered
+200 data2 for testing update data2 altered
+300 data3 for testing ##VALUE UPDATED## NULL
+500 data5 for testing update data5 NULL
+600 data6 for testing update data6 NULL
+800 data1 for replacement replace data1 NULL
+800 data replaced replace over NULL
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+We execute binlog to recover data after backup using binlog dates.
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+a char(4) YES NULL
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+DESCRIBE ptr.t3;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+b varchar(4) YES NULL
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+6 f
+7 g
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data
+100 data1 for testing update data1
+300 data3 for testing ##VALUE UPDATED##
+500 data5 for testing update data5
+600 data6 for testing update data6
+800 data1 for replacement replace data1
+800 data replaced replace over
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+1 ff
+3 mm
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+10001 120 6550 7278634657 90667 After backup Minneapolis 782.9901 789.23 97806.456 blue Antartica 2008-08-07 15:12:44 1954-12-23 1954
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+DROP DATABASE ptr;
+*** TEST4 *** :
+Perform Restore and recover transactions after backup by executing
+mysqlbinlog utility using binlog dates.
+RESTORE FROM 'ptr.bak';
+backup_id
+#
+DESCRIBE ptr.t1;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+a char(4) YES NULL
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+changes char(20) YES NULL
+DESCRIBE ptr.t3;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+b varchar(4) YES NULL
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data changes
+100 data1 for testing update data1 altered
+200 data2 for testing update data2 altered
+300 data3 for testing ##VALUE UPDATED## NULL
+500 data5 for testing update data5 NULL
+600 data6 for testing update data6 NULL
+800 data1 for replacement replace data1 NULL
+800 data replaced replace over NULL
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+SHOW DATABASES;
+Database
+information_schema
+mysql
+ptr
+test
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+a char(4) YES NULL
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+DESCRIBE ptr.t3;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+b varchar(4) YES NULL
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+6 f
+7 g
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data
+100 data1 for testing update data1
+300 data3 for testing ##VALUE UPDATED##
+500 data5 for testing update data5
+600 data6 for testing update data6
+800 data1 for replacement replace data1
+800 data replaced replace over
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+1 ff
+3 mm
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+10001 120 6550 7278634657 90667 After backup Minneapolis 782.9901 789.23 97806.456 blue Antartica 2008-08-07 15:12:44 1954-12-23 1954
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+DROP DATABASE ptr;
+*** TEST5 *** :
+Do complete recovery of data after backup using binlog position. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW DATABASES;
+Database
+information_schema
+mysql
+ptr
+test
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+a char(4) YES NULL
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+DESCRIBE ptr.t3;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+b varchar(4) YES NULL
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+6 f
+7 g
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data
+100 data1 for testing update data1
+300 data3 for testing ##VALUE UPDATED##
+500 data5 for testing update data5
+600 data6 for testing update data6
+800 data1 for replacement replace data1
+800 data replaced replace over
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+1 ff
+3 mm
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+10001 120 6550 7278634657 90667 After backup Minneapolis 782.9901 789.23 97806.456 blue Antartica 2008-08-07 15:12:44 1954-12-23 1954
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+DROP DATABASE ptr;
+*** TEST6 *** :
+Do complete recovery of data after backup using binlog dates. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW DATABASES;
+Database
+information_schema
+mysql
+ptr
+test
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+a char(4) YES NULL
+DESCRIBE ptr.t2;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+deletes_data varchar(30) YES NULL
+updates_data text YES NULL
+DESCRIBE ptr.t3;
+Field Type Null Key Default Extra
+id int(11) YES NULL
+b varchar(4) YES NULL
+SELECT * FROM ptr.t1;
+id a
+1 a
+2 b
+3 c
+4 d
+5 e
+6 f
+7 g
+SELECT * FROM ptr.t2 ORDER BY id;
+id deletes_data updates_data
+100 data1 for testing update data1
+300 data3 for testing ##VALUE UPDATED##
+500 data5 for testing update data5
+600 data6 for testing update data6
+800 data1 for replacement replace data1
+800 data replaced replace over
+SELECT * FROM ptr.t3;
+id b
+11 aa
+22 bb
+33 cc
+44 dd
+55 ee
+1 ff
+3 mm
+SELECT * FROM ptr.d1;
+rint tint sint bint mint name city fl pers sal colours continent ts dob y
+785 127 7288 278829899 3777 testing1 sweden 678.2990 200.23 829899.909 yellow Asia 2008-06-01 16:23:30 1984-09-08 1984
+10001 120 6550 7278634657 90667 After backup Minneapolis 782.9901 789.23 97806.456 blue Antartica 2008-08-07 15:12:44 1954-12-23 1954
+SELECT * FROM ptr.d2;
+region summary data details queries query2 extract paras
+xxxxxxxx Testofonline backup aaaaaaaaaa bbbbbbbbbbb hhhhhhhhhhh kkkkkkkkkkkkk mmmmmmmmmmmm onlinebackup1
+
+*** DROP ptr DATABASE ****
+
+DROP DATABASE ptr;
=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result 2008-10-08 04:26:25 +0000
@@ -0,0 +1,2106 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name Value
+storage_engine #
+SET GLOBAL BINLOG_FORMAT='MIXED';
+SET BINLOG_FORMAT='MIXED';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+MIXED
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data and objects using binlog position
+till point of backup and after backup.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+CREATE DATABASE IF NOT EXISTS ptr_ob1;
+CREATE DATABASE IF NOT EXISTS ptr_ob2;
+USE ptr_ob1;
+**** Creating tables ****
+CREATE TABLE ptr_ob1.t1(
+id INT,
+a INT,
+b CHAR(5)
+);
+CREATE TABLE ptr_ob1.t2(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+data CHAR(50)
+);
+CREATE TABLE ptr_ob1.t3(
+srno INT AUTO_INCREMENT,
+PRIMARY KEY(srno),
+name VARCHAR(30) NOT NULL,
+old_a INT
+);
+CREATE TABLE ptr_ob2.t1(
+id INT,
+b CHAR(5)
+);
+CREATE TABLE ptr_ob2.t2(id SMALLINT);
+INSERT INTO ptr_ob2.t1 VALUES(11,'set1'),(21,'set2'),(3,'set3'),(4,'set4');
+INSERT INTO ptr_ob2.t2 VALUES(91),(5),(26),(33),(5);
+**** Creating views ****
+CREATE VIEW ptr_ob1.v AS SELECT * FROM ptr_ob1.t1;
+CREATE VIEW ptr_ob1.v1 AS SELECT * FROM ptr_ob2.t1;
+CREATE TABLE ptr_ob1.tv1(id SMALLINT);
+INSERT INTO ptr_ob1.tv1 VALUES(1),(2),(3),(3),(5);
+SELECT * FROM ptr_ob1.tv1 UNION ALL SELECT * FROM ptr_ob2.t2;
+id
+1
+2
+3
+3
+5
+91
+5
+26
+33
+5
+CREATE VIEW ptr_ob2.v1 AS SELECT * FROM ptr_ob1.tv1 UNION ALL
+SELECT * FROM ptr_ob2.t2 ORDER BY id;
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+26
+33
+91
+#### Creating view from another view ####
+CREATE VIEW ptr_ob1.vv AS SELECT SUM(id) from ptr_ob2.v1 GROUP BY id;
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+26
+33
+91
+**** Creating Triggers ****
+CREATE TRIGGER ptr_ob1.trg1 BEFORE INSERT ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END;||
+INSERT INTO ptr_ob1.t1 VALUES(1,20, 'bb1'), (2,50, 'bb2'),(3,80,'bb3');
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+2 50 bb2
+3 80 bb3
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT ON ptr_ob1.t2 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END;||
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL, 'Normal Insert1'),(NULL, 'Normal Insert2'),
+(NULL, 'Normal Insert3'),(NULL, 'Normal Insert4');
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+CREATE TRIGGER ptr_ob2.trg3 BEFORE DELETE ON ptr_ob2.t2 FOR EACH ROW
+SET @del_sum:= @del_sum + old.id;||
+SET @del_sum:= 0;||
+DELETE FROM ptr_ob2.t2 WHERE id=26;
+DELETE FROM ptr_ob2.t2 WHERE id=91;
+SELECT @del_sum;
+@del_sum
+117
+CREATE TRIGGER ptr_ob1.trg4 AFTER DELETE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END;||
+DELETE FROM ptr_ob1.t1 WHERE id=2;
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 80 bb3
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 set3
+4 set4
+2 bb2
+CREATE TRIGGER ptr_ob1.trg5 BEFORE UPDATE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END;
+||
+UPDATE ptr_ob1.t1 SET a='85' WHERE b='bb3';
+SELECT @id, @a_old, @a_new;
+@id @a_old @a_new
+3 80 85
+CREATE TRIGGER ptr_ob2.trg6 AFTER UPDATE ON ptr_ob2.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END;
+||
+UPDATE ptr_ob2.t1 SET b='alert' WHERE id=3;
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+
+**** Creating stored Procedures and functions ****
+
+#### The procedure p1 will insert VALUES in view ####
+CREATE PROCEDURE ptr_ob1.p1(details CHAR(40), id INT)
+BEGIN
+INSERT INTO ptr_ob1.v1 VALUES(1,'fired');
+END;
+||
+#### Procedure p2 will trigger trg2 ####
+CREATE PROCEDURE ptr_ob1.p2(content VARCHAR(40))
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Trigger fired from procedure p2');
+END;||
+#### Procedure p3 will trigger trg6 ####
+CREATE PROCEDURE ptr_ob1.p3(info TEXT)
+BEGIN
+UPDATE ptr_ob2.t1 SET b='#up#' WHERE id=4;
+END;||
+#### Procedure p4 will call view ####
+CREATE PROCEDURE ptr_ob2.p4()
+BEGIN
+SELECT * FROM ptr_ob2.v1;
+END;
+||
+#### Function f1() ####
+CREATE FUNCTION f1() RETURNS INT
+RETURN (SELECT COUNT(*) FROM ptr_ob1.v1);||
+SELECT f1();
+f1()
+5
+CALL ptr_ob1.p1('procedure p1 called for view v1', 1);
+CALL ptr_ob1.p1('procedure p1 called for view v1', 2);
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+1 fired
+1 fired
+CALL ptr_ob1.p2('procedure p2 called for trg2');
+CALL ptr_ob1.p2('procedure p2 again called for trg2');
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+CALL ptr_ob1.p3('procedure p3 called for trg6');
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+** Checking data contents in all the tables before performing backup **
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+set timestamp=@a+2;
+Make some changes to objects.
+ALTER VIEW ptr_ob1.v AS SELECT id, a FROM ptr_ob1.t1;
+ALTER TABLE ptr_ob1.vv RENAME TO ptr_ob1.vva;
+ALTER TABLE ptr_ob2.t2 ADD COLUMN af_backup VARCHAR(30);
+ALTER TABLE ptr_ob1.t3 CHANGE name name TEXT;
+DESCRIBE ptr_ob1.t3;
+Field Type Null Key Default Extra
+srno int(11) NO PRI NULL auto_increment
+name text YES NULL
+old_a int(11) YES NULL
+ALTER PROCEDURE ptr_ob2.p4 COMMENT 'AFTER BACKUP';
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+Creating some new objects
+CREATE TABLE ptr_ob1.t11 (i INT, sr INT, j INT) engine=myisam;
+INSERT INTO ptr_ob1.t11 VALUES (1, 2, 3);
+CREATE TRIGGER ptr_ob1.ai AFTER INSERT ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.au AFTER UPDATE ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.ad AFTER DELETE ON ptr_ob1.t11 FOR EACH ROW SET @a:= old.sr;
+INSERT INTO ptr_ob1.t11 VALUES(4, 5, 6),(7, 8, 9);
+SELECT @a;
+@a
+8
+UPDATE ptr_ob1.t11 SET i=10 WHERE sr=5;
+SELECT @a;
+@a
+5
+DELETE FROM ptr_ob1.t11 WHERE sr=8;
+SELECT @a;
+@a
+8
+Now alter the table
+ALTER TABLE ptr_ob1.t11 DROP COLUMN j;
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+INSERT INTO ptr_ob1.t11 VALUES(11, 12);
+SELECT @a;
+@a
+12
+Firing existing triggers and calling procedures.
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Insert after backup');
+INSERT INTO ptr_ob2.t2 VALUES(10, 'af_bk1'),(2, 'af_bk2'),(7,'af_bk3'),(2,'af_bk4');
+DELETE FROM ptr_ob2.t2 WHERE id=10;
+SELECT @del_sum;
+@del_sum
+127
+CALL ptr_ob1.p1('procedure p1 af_bkup for view v1', 3);
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+CALL ptr_ob1.p2('procedure p2 called af_bkup for trg2');
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+CALL ptr_ob1.p3('procedure p3 called af_bkup for trg6');
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+Checking the data contents after backup.
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+SET TIMESTAMP=@a+4;
+FLUSH LOGS;
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+**** Execute mysqlbinlog to recover the data from start to backup ****
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+**** Now perform another recovery to recover data after backup ****
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST2 *** :
+Perform Restore and recover transactions after backup by executing
+mysqlbinlog utility using binlog position.
+
+Perfrom Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Now use binlog position to recover data after backup
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST3 *** :
+This test will recover data and objects using binlog dates
+till point of backup and after backup.
+
+Use mysqlbinlog dates to recover data till point of backup.
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Use mysqlbinlog dates to recover data after backup
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST4 *** :
+Perform Restore and recover objects after backup by executing mysqlbinlog
+utility using binlog dates.
+
+Perform Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+use binlog dates to recover data after backup.
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST5 *** :
+Do complete recovery of data after backup using binlog position. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST6 *** :
+Do complete recovery of data after backup using binlog dates. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+
+*** DROP ptr_ob1 and ptr_ob2 DATABASE ****
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result 2008-10-08 04:26:25 +0000
@@ -0,0 +1,2106 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name Value
+storage_engine #
+SET GLOBAL BINLOG_FORMAT='ROW';
+SET BINLOG_FORMAT='ROW';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+ROW
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data and objects using binlog position
+till point of backup and after backup.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+CREATE DATABASE IF NOT EXISTS ptr_ob1;
+CREATE DATABASE IF NOT EXISTS ptr_ob2;
+USE ptr_ob1;
+**** Creating tables ****
+CREATE TABLE ptr_ob1.t1(
+id INT,
+a INT,
+b CHAR(5)
+);
+CREATE TABLE ptr_ob1.t2(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+data CHAR(50)
+);
+CREATE TABLE ptr_ob1.t3(
+srno INT AUTO_INCREMENT,
+PRIMARY KEY(srno),
+name VARCHAR(30) NOT NULL,
+old_a INT
+);
+CREATE TABLE ptr_ob2.t1(
+id INT,
+b CHAR(5)
+);
+CREATE TABLE ptr_ob2.t2(id SMALLINT);
+INSERT INTO ptr_ob2.t1 VALUES(11,'set1'),(21,'set2'),(3,'set3'),(4,'set4');
+INSERT INTO ptr_ob2.t2 VALUES(91),(5),(26),(33),(5);
+**** Creating views ****
+CREATE VIEW ptr_ob1.v AS SELECT * FROM ptr_ob1.t1;
+CREATE VIEW ptr_ob1.v1 AS SELECT * FROM ptr_ob2.t1;
+CREATE TABLE ptr_ob1.tv1(id SMALLINT);
+INSERT INTO ptr_ob1.tv1 VALUES(1),(2),(3),(3),(5);
+SELECT * FROM ptr_ob1.tv1 UNION ALL SELECT * FROM ptr_ob2.t2;
+id
+1
+2
+3
+3
+5
+91
+5
+26
+33
+5
+CREATE VIEW ptr_ob2.v1 AS SELECT * FROM ptr_ob1.tv1 UNION ALL
+SELECT * FROM ptr_ob2.t2 ORDER BY id;
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+26
+33
+91
+#### Creating view from another view ####
+CREATE VIEW ptr_ob1.vv AS SELECT SUM(id) from ptr_ob2.v1 GROUP BY id;
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+26
+33
+91
+**** Creating Triggers ****
+CREATE TRIGGER ptr_ob1.trg1 BEFORE INSERT ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END;||
+INSERT INTO ptr_ob1.t1 VALUES(1,20, 'bb1'), (2,50, 'bb2'),(3,80,'bb3');
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+2 50 bb2
+3 80 bb3
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT ON ptr_ob1.t2 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END;||
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL, 'Normal Insert1'),(NULL, 'Normal Insert2'),
+(NULL, 'Normal Insert3'),(NULL, 'Normal Insert4');
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+CREATE TRIGGER ptr_ob2.trg3 BEFORE DELETE ON ptr_ob2.t2 FOR EACH ROW
+SET @del_sum:= @del_sum + old.id;||
+SET @del_sum:= 0;||
+DELETE FROM ptr_ob2.t2 WHERE id=26;
+DELETE FROM ptr_ob2.t2 WHERE id=91;
+SELECT @del_sum;
+@del_sum
+117
+CREATE TRIGGER ptr_ob1.trg4 AFTER DELETE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END;||
+DELETE FROM ptr_ob1.t1 WHERE id=2;
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 80 bb3
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 set3
+4 set4
+2 bb2
+CREATE TRIGGER ptr_ob1.trg5 BEFORE UPDATE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END;
+||
+UPDATE ptr_ob1.t1 SET a='85' WHERE b='bb3';
+SELECT @id, @a_old, @a_new;
+@id @a_old @a_new
+3 80 85
+CREATE TRIGGER ptr_ob2.trg6 AFTER UPDATE ON ptr_ob2.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END;
+||
+UPDATE ptr_ob2.t1 SET b='alert' WHERE id=3;
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+
+**** Creating stored Procedures and functions ****
+
+#### The procedure p1 will insert VALUES in view ####
+CREATE PROCEDURE ptr_ob1.p1(details CHAR(40), id INT)
+BEGIN
+INSERT INTO ptr_ob1.v1 VALUES(1,'fired');
+END;
+||
+#### Procedure p2 will trigger trg2 ####
+CREATE PROCEDURE ptr_ob1.p2(content VARCHAR(40))
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Trigger fired from procedure p2');
+END;||
+#### Procedure p3 will trigger trg6 ####
+CREATE PROCEDURE ptr_ob1.p3(info TEXT)
+BEGIN
+UPDATE ptr_ob2.t1 SET b='#up#' WHERE id=4;
+END;||
+#### Procedure p4 will call view ####
+CREATE PROCEDURE ptr_ob2.p4()
+BEGIN
+SELECT * FROM ptr_ob2.v1;
+END;
+||
+#### Function f1() ####
+CREATE FUNCTION f1() RETURNS INT
+RETURN (SELECT COUNT(*) FROM ptr_ob1.v1);||
+SELECT f1();
+f1()
+5
+CALL ptr_ob1.p1('procedure p1 called for view v1', 1);
+CALL ptr_ob1.p1('procedure p1 called for view v1', 2);
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+1 fired
+1 fired
+CALL ptr_ob1.p2('procedure p2 called for trg2');
+CALL ptr_ob1.p2('procedure p2 again called for trg2');
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+CALL ptr_ob1.p3('procedure p3 called for trg6');
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+** Checking data contents in all the tables before performing backup **
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+set timestamp=@a+2;
+Make some changes to objects.
+ALTER VIEW ptr_ob1.v AS SELECT id, a FROM ptr_ob1.t1;
+ALTER TABLE ptr_ob1.vv RENAME TO ptr_ob1.vva;
+ALTER TABLE ptr_ob2.t2 ADD COLUMN af_backup VARCHAR(30);
+ALTER TABLE ptr_ob1.t3 CHANGE name name TEXT;
+DESCRIBE ptr_ob1.t3;
+Field Type Null Key Default Extra
+srno int(11) NO PRI NULL auto_increment
+name text YES NULL
+old_a int(11) YES NULL
+ALTER PROCEDURE ptr_ob2.p4 COMMENT 'AFTER BACKUP';
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+Creating some new objects
+CREATE TABLE ptr_ob1.t11 (i INT, sr INT, j INT) engine=myisam;
+INSERT INTO ptr_ob1.t11 VALUES (1, 2, 3);
+CREATE TRIGGER ptr_ob1.ai AFTER INSERT ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.au AFTER UPDATE ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.ad AFTER DELETE ON ptr_ob1.t11 FOR EACH ROW SET @a:= old.sr;
+INSERT INTO ptr_ob1.t11 VALUES(4, 5, 6),(7, 8, 9);
+SELECT @a;
+@a
+8
+UPDATE ptr_ob1.t11 SET i=10 WHERE sr=5;
+SELECT @a;
+@a
+5
+DELETE FROM ptr_ob1.t11 WHERE sr=8;
+SELECT @a;
+@a
+8
+Now alter the table
+ALTER TABLE ptr_ob1.t11 DROP COLUMN j;
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+INSERT INTO ptr_ob1.t11 VALUES(11, 12);
+SELECT @a;
+@a
+12
+Firing existing triggers and calling procedures.
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Insert after backup');
+INSERT INTO ptr_ob2.t2 VALUES(10, 'af_bk1'),(2, 'af_bk2'),(7,'af_bk3'),(2,'af_bk4');
+DELETE FROM ptr_ob2.t2 WHERE id=10;
+SELECT @del_sum;
+@del_sum
+127
+CALL ptr_ob1.p1('procedure p1 af_bkup for view v1', 3);
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+CALL ptr_ob1.p2('procedure p2 called af_bkup for trg2');
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+CALL ptr_ob1.p3('procedure p3 called af_bkup for trg6');
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+Checking the data contents after backup.
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+SET TIMESTAMP=@a+4;
+FLUSH LOGS;
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+**** Execute mysqlbinlog to recover the data from start to backup ****
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+**** Now perform another recovery to recover data after backup ****
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST2 *** :
+Perform Restore and recover transactions after backup by executing
+mysqlbinlog utility using binlog position.
+
+Perfrom Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Now use binlog position to recover data after backup
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST3 *** :
+This test will recover data and objects using binlog dates
+till point of backup and after backup.
+
+Use mysqlbinlog dates to recover data till point of backup.
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Use mysqlbinlog dates to recover data after backup
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST4 *** :
+Perform Restore and recover objects after backup by executing mysqlbinlog
+utility using binlog dates.
+
+Perform Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+use binlog dates to recover data after backup.
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST5 *** :
+Do complete recovery of data after backup using binlog position. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST6 *** :
+Do complete recovery of data after backup using binlog dates. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+
+*** DROP ptr_ob1 and ptr_ob2 DATABASE ****
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result 2008-10-08 04:26:25 +0000
@@ -0,0 +1,2106 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name Value
+storage_engine #
+SET GLOBAL BINLOG_FORMAT='STATEMENT';
+SET BINLOG_FORMAT='STATEMENT';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+STATEMENT
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data and objects using binlog position
+till point of backup and after backup.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+CREATE DATABASE IF NOT EXISTS ptr_ob1;
+CREATE DATABASE IF NOT EXISTS ptr_ob2;
+USE ptr_ob1;
+**** Creating tables ****
+CREATE TABLE ptr_ob1.t1(
+id INT,
+a INT,
+b CHAR(5)
+);
+CREATE TABLE ptr_ob1.t2(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+data CHAR(50)
+);
+CREATE TABLE ptr_ob1.t3(
+srno INT AUTO_INCREMENT,
+PRIMARY KEY(srno),
+name VARCHAR(30) NOT NULL,
+old_a INT
+);
+CREATE TABLE ptr_ob2.t1(
+id INT,
+b CHAR(5)
+);
+CREATE TABLE ptr_ob2.t2(id SMALLINT);
+INSERT INTO ptr_ob2.t1 VALUES(11,'set1'),(21,'set2'),(3,'set3'),(4,'set4');
+INSERT INTO ptr_ob2.t2 VALUES(91),(5),(26),(33),(5);
+**** Creating views ****
+CREATE VIEW ptr_ob1.v AS SELECT * FROM ptr_ob1.t1;
+CREATE VIEW ptr_ob1.v1 AS SELECT * FROM ptr_ob2.t1;
+CREATE TABLE ptr_ob1.tv1(id SMALLINT);
+INSERT INTO ptr_ob1.tv1 VALUES(1),(2),(3),(3),(5);
+SELECT * FROM ptr_ob1.tv1 UNION ALL SELECT * FROM ptr_ob2.t2;
+id
+1
+2
+3
+3
+5
+91
+5
+26
+33
+5
+CREATE VIEW ptr_ob2.v1 AS SELECT * FROM ptr_ob1.tv1 UNION ALL
+SELECT * FROM ptr_ob2.t2 ORDER BY id;
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+26
+33
+91
+#### Creating view from another view ####
+CREATE VIEW ptr_ob1.vv AS SELECT SUM(id) from ptr_ob2.v1 GROUP BY id;
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+26
+33
+91
+**** Creating Triggers ****
+CREATE TRIGGER ptr_ob1.trg1 BEFORE INSERT ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END;||
+INSERT INTO ptr_ob1.t1 VALUES(1,20, 'bb1'), (2,50, 'bb2'),(3,80,'bb3');
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+2 50 bb2
+3 80 bb3
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT ON ptr_ob1.t2 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END;||
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL, 'Normal Insert1'),(NULL, 'Normal Insert2'),
+(NULL, 'Normal Insert3'),(NULL, 'Normal Insert4');
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+CREATE TRIGGER ptr_ob2.trg3 BEFORE DELETE ON ptr_ob2.t2 FOR EACH ROW
+SET @del_sum:= @del_sum + old.id;||
+SET @del_sum:= 0;||
+DELETE FROM ptr_ob2.t2 WHERE id=26;
+DELETE FROM ptr_ob2.t2 WHERE id=91;
+SELECT @del_sum;
+@del_sum
+117
+CREATE TRIGGER ptr_ob1.trg4 AFTER DELETE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END;||
+DELETE FROM ptr_ob1.t1 WHERE id=2;
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 80 bb3
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 set3
+4 set4
+2 bb2
+CREATE TRIGGER ptr_ob1.trg5 BEFORE UPDATE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END;
+||
+UPDATE ptr_ob1.t1 SET a='85' WHERE b='bb3';
+SELECT @id, @a_old, @a_new;
+@id @a_old @a_new
+3 80 85
+CREATE TRIGGER ptr_ob2.trg6 AFTER UPDATE ON ptr_ob2.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END;
+||
+UPDATE ptr_ob2.t1 SET b='alert' WHERE id=3;
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+
+**** Creating stored Procedures and functions ****
+
+#### The procedure p1 will insert VALUES in view ####
+CREATE PROCEDURE ptr_ob1.p1(details CHAR(40), id INT)
+BEGIN
+INSERT INTO ptr_ob1.v1 VALUES(1,'fired');
+END;
+||
+#### Procedure p2 will trigger trg2 ####
+CREATE PROCEDURE ptr_ob1.p2(content VARCHAR(40))
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Trigger fired from procedure p2');
+END;||
+#### Procedure p3 will trigger trg6 ####
+CREATE PROCEDURE ptr_ob1.p3(info TEXT)
+BEGIN
+UPDATE ptr_ob2.t1 SET b='#up#' WHERE id=4;
+END;||
+#### Procedure p4 will call view ####
+CREATE PROCEDURE ptr_ob2.p4()
+BEGIN
+SELECT * FROM ptr_ob2.v1;
+END;
+||
+#### Function f1() ####
+CREATE FUNCTION f1() RETURNS INT
+RETURN (SELECT COUNT(*) FROM ptr_ob1.v1);||
+SELECT f1();
+f1()
+5
+CALL ptr_ob1.p1('procedure p1 called for view v1', 1);
+CALL ptr_ob1.p1('procedure p1 called for view v1', 2);
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 set4
+2 bb2
+1 fired
+1 fired
+CALL ptr_ob1.p2('procedure p2 called for trg2');
+CALL ptr_ob1.p2('procedure p2 again called for trg2');
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+CALL ptr_ob1.p3('procedure p3 called for trg6');
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+** Checking data contents in all the tables before performing backup **
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+set timestamp=@a+2;
+Make some changes to objects.
+ALTER VIEW ptr_ob1.v AS SELECT id, a FROM ptr_ob1.t1;
+ALTER TABLE ptr_ob1.vv RENAME TO ptr_ob1.vva;
+ALTER TABLE ptr_ob2.t2 ADD COLUMN af_backup VARCHAR(30);
+ALTER TABLE ptr_ob1.t3 CHANGE name name TEXT;
+DESCRIBE ptr_ob1.t3;
+Field Type Null Key Default Extra
+srno int(11) NO PRI NULL auto_increment
+name text YES NULL
+old_a int(11) YES NULL
+ALTER PROCEDURE ptr_ob2.p4 COMMENT 'AFTER BACKUP';
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+Creating some new objects
+CREATE TABLE ptr_ob1.t11 (i INT, sr INT, j INT) engine=myisam;
+INSERT INTO ptr_ob1.t11 VALUES (1, 2, 3);
+CREATE TRIGGER ptr_ob1.ai AFTER INSERT ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.au AFTER UPDATE ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.ad AFTER DELETE ON ptr_ob1.t11 FOR EACH ROW SET @a:= old.sr;
+INSERT INTO ptr_ob1.t11 VALUES(4, 5, 6),(7, 8, 9);
+SELECT @a;
+@a
+8
+UPDATE ptr_ob1.t11 SET i=10 WHERE sr=5;
+SELECT @a;
+@a
+5
+DELETE FROM ptr_ob1.t11 WHERE sr=8;
+SELECT @a;
+@a
+8
+Now alter the table
+ALTER TABLE ptr_ob1.t11 DROP COLUMN j;
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+INSERT INTO ptr_ob1.t11 VALUES(11, 12);
+SELECT @a;
+@a
+12
+Firing existing triggers and calling procedures.
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Insert after backup');
+INSERT INTO ptr_ob2.t2 VALUES(10, 'af_bk1'),(2, 'af_bk2'),(7,'af_bk3'),(2,'af_bk4');
+DELETE FROM ptr_ob2.t2 WHERE id=10;
+SELECT @del_sum;
+@del_sum
+127
+CALL ptr_ob1.p1('procedure p1 af_bkup for view v1', 3);
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+CALL ptr_ob1.p2('procedure p2 called af_bkup for trg2');
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+CALL ptr_ob1.p3('procedure p3 called af_bkup for trg6');
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+Checking the data contents after backup.
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+SET TIMESTAMP=@a+4;
+FLUSH LOGS;
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+**** Execute mysqlbinlog to recover the data from start to backup ****
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+**** Now perform another recovery to recover data after backup ****
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST2 *** :
+Perform Restore and recover transactions after backup by executing
+mysqlbinlog utility using binlog position.
+
+Perfrom Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Now use binlog position to recover data after backup
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST3 *** :
+This test will recover data and objects using binlog dates
+till point of backup and after backup.
+
+Use mysqlbinlog dates to recover data till point of backup.
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vv VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Use mysqlbinlog dates to recover data after backup
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER AFTER BACKUP # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+ai INSERT t11 SET @a:= new.sr # # root@localhost # # #
+au UPDATE t11 SET @a:= new.sr # # root@localhost # # #
+ad DELETE t11 SET @a:= old.sr # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t11 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW
+vva VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+v1 VIEW
+SELECT * FROM ptr_ob1.t1;
+id a b
+1 20 bb1
+3 85 bb3
+SELECT * FROM ptr_ob1.v;
+id a
+1 20
+3 85
+SELECT * FROM ptr_ob1.t2;
+id data
+1 Normal Insert1
+2 Normal Insert2
+3 Normal Insert3
+4 Normal Insert4
+5 Trigger fired from after update of ptr_ob2.t1
+6 Trigger fired from procedure p2
+7 Trigger fired from procedure p2
+8 Trigger fired from after update of ptr_ob2.t1
+9 Insert after backup
+10 Trigger fired from procedure p2
+11 Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno name old_a
+1 t1 20
+2 t1 50
+3 t1 80
+4 trigger fired for AFTER INSERT 100
+5 trigger fired for AFTER INSERT 100
+6 trigger fired for AFTER INSERT 100
+7 trigger fired for AFTER INSERT 100
+8 trigger fired for AFTER INSERT 100
+9 trigger fired for AFTER INSERT 100
+10 trigger fired for AFTER INSERT 100
+11 trigger fired for AFTER INSERT 100
+12 trigger fired for AFTER INSERT 100
+13 trigger fired for AFTER INSERT 100
+14 trigger fired for AFTER INSERT 100
+SELECT * FROM ptr_ob2.t1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.v1;
+id b
+11 set1
+21 set2
+3 alert
+4 #up#
+2 bb2
+1 fired
+1 fired
+1 fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i sr
+1 2
+10 5
+11 12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST4 *** :
+Perform Restore and recover objects after backup by executing mysqlbinlog
+utility using binlog dates.
+
+Perform Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
+ptr_ob1 p1 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p2 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob1 p3 PROCEDURE root@localhost # # DEFINER # # #
+ptr_ob2 p4 PROCEDURE root@localhost # # DEFINER # # #
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg1 INSERT t1 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END # # root@localhost # # #
+trg5 UPDATE t1 BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END # # root@localhost # # #
+trg4 DELETE t1 BEGIN
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END # # root@localhost # # #
+trg2 INSERT t2 BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END # # root@localhost # # #
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
+trg6 UPDATE t1 BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');
+END # # root@localhost # # #
+trg3 DELETE t2 SET @del_sum:= @del_sum + old.id # # root@localhost # # #
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1 Table_type
+t1 BASE TABLE
+t2 BASE TABLE
+t3 BASE TABLE
+tv1 BASE TABLE
+v VIEW
+v1 VIEW