#At file:///data0/wl-4228/mysql-6.0-backup/
2696 Hema Sridharan 2008-09-16
WL#4228(Test support for point in time recovery)
added:
mysql-test/suite/backup/include/backup_ptr.inc
mysql-test/suite/backup/include/backup_ptr_commit.inc
mysql-test/suite/backup/include/backup_ptr_objects.inc
mysql-test/suite/backup/include/not_have_falcon.inc
mysql-test/suite/backup/include/not_have_innodb.inc
mysql-test/suite/backup/include/not_have_memory.inc
mysql-test/suite/backup/include/not_have_myisam.inc
mysql-test/suite/backup/r/backup_ptr_commit_mixed.result
mysql-test/suite/backup/r/backup_ptr_commit_row.result
mysql-test/suite/backup/r/backup_ptr_commit_stmt.result
mysql-test/suite/backup/r/backup_ptr_mixed.result
mysql-test/suite/backup/r/backup_ptr_objects_mixed.result
mysql-test/suite/backup/r/backup_ptr_objects_row.result
mysql-test/suite/backup/r/backup_ptr_objects_stmt.result
mysql-test/suite/backup/r/backup_ptr_row.result
mysql-test/suite/backup/r/backup_ptr_stmt.result
mysql-test/suite/backup/t/backup_ptr_commit_mixed.test
mysql-test/suite/backup/t/backup_ptr_commit_row.test
mysql-test/suite/backup/t/backup_ptr_commit_stmt.test
mysql-test/suite/backup/t/backup_ptr_mixed.test
mysql-test/suite/backup/t/backup_ptr_objects_mixed.test
mysql-test/suite/backup/t/backup_ptr_objects_row.test
mysql-test/suite/backup/t/backup_ptr_objects_stmt.test
mysql-test/suite/backup/t/backup_ptr_row.test
mysql-test/suite/backup/t/backup_ptr_stmt.test
=== added file 'mysql-test/suite/backup/include/backup_ptr.inc'
--- a/mysql-test/suite/backup/include/backup_ptr.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/backup_ptr.inc 2008-09-16 20:05:46 +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/include/backup_ptr_commit.inc'
--- a/mysql-test/suite/backup/include/backup_ptr_commit.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/backup_ptr_commit.inc 2008-09-16 20:05:46 +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 committed data using binlog position
+--echo till point of backup and after backup. In this test we will commit
+--echo the data during backup. 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 after and before backup 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/include/backup_ptr_objects.inc'
--- a/mysql-test/suite/backup/include/backup_ptr_objects.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/backup_ptr_objects.inc 2008-09-16 20:05:46 +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/include/not_have_falcon.inc'
--- a/mysql-test/suite/backup/include/not_have_falcon.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/not_have_falcon.inc 2008-09-16 20:05:46 +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/include/not_have_innodb.inc'
--- a/mysql-test/suite/backup/include/not_have_innodb.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/not_have_innodb.inc 2008-09-16 20:05:46 +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/include/not_have_memory.inc'
--- a/mysql-test/suite/backup/include/not_have_memory.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/not_have_memory.inc 2008-09-16 20:05:46 +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/include/not_have_myisam.inc'
--- a/mysql-test/suite/backup/include/not_have_myisam.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/not_have_myisam.inc 2008-09-16 20:05:46 +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/r/backup_ptr_commit_mixed.result'
--- a/mysql-test/suite/backup/r/backup_ptr_commit_mixed.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_ptr_commit_mixed.result 2008-09-16 20:05:46 +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 committed data using binlog position
+till point of backup and after backup. In this test we will commit
+the data during backup. 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 after and before backup 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/r/backup_ptr_commit_row.result'
--- a/mysql-test/suite/backup/r/backup_ptr_commit_row.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_ptr_commit_row.result 2008-09-16 20:05:46 +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 committed data using binlog position
+till point of backup and after backup. In this test we will commit
+the data during backup. 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 after and before backup 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/r/backup_ptr_commit_stmt.result'
--- a/mysql-test/suite/backup/r/backup_ptr_commit_stmt.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_ptr_commit_stmt.result 2008-09-16 20:05:46 +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 committed data using binlog position
+till point of backup and after backup. In this test we will commit
+the data during backup. 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 after and before backup 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/r/backup_ptr_mixed.result'
--- a/mysql-test/suite/backup/r/backup_ptr_mixed.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_ptr_mixed.result 2008-09-16 20:05:46 +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/r/backup_ptr_objects_mixed.result'
--- a/mysql-test/suite/backup/r/backup_ptr_objects_mixed.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_ptr_objects_mixed.result 2008-09-16 20:05:46 +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/r/backup_ptr_objects_row.result'
--- a/mysql-test/suite/backup/r/backup_ptr_objects_row.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_ptr_objects_row.result 2008-09-16 20:05:46 +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/r/backup_ptr_objects_stmt.result'
--- a/mysql-test/suite/backup/r/backup_ptr_objects_stmt.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_ptr_objects_stmt.result 2008-09-16 20:05:46 +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
+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/r/backup_ptr_row.result'
--- a/mysql-test/suite/backup/r/backup_ptr_row.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_ptr_row.result 2008-09-16 20:05:46 +0000
@@ -0,0 +1,843 @@
+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 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