List:Commits« Previous MessageNext Message »
From:lars-erik.bjork Date:October 26 2008 9:45am
Subject:bzr commit into mysql-6.0-falcon-team branch (lars-erik.bjork:2874)
View as plain text  
#At file:///home/lb200670/devel/mysql/trampoline/

 2874 lars-erik.bjork@stripped	2008-10-26 [merge]
      Merging, and adding newline to falcon_year_4digit.test
added:
  mysql-test/suite/backup/
  mysql-test/suite/backup/r/
  mysql-test/suite/backup/r/backup_commit_backup.result
  mysql-test/suite/backup/t/
  mysql-test/suite/backup/t/backup_commit_backup.test
  mysql-test/suite/backup/t/disabled.def
  mysql-test/suite/backup_engines/include/backup_ptr.inc
  mysql-test/suite/backup_engines/include/backup_ptr_commit.inc
  mysql-test/suite/backup_engines/include/backup_ptr_objects.inc
  mysql-test/suite/backup_engines/include/not_have_falcon.inc
  mysql-test/suite/backup_engines/include/not_have_innodb.inc
  mysql-test/suite/backup_engines/include/not_have_memory.inc
  mysql-test/suite/backup_engines/include/not_have_myisam.inc
  mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result
  mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result
  mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result
  mysql-test/suite/backup_engines/r/backup_ptr_mixed.result
  mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result
  mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result
  mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result
  mysql-test/suite/backup_engines/r/backup_ptr_row.result
  mysql-test/suite/backup_engines/r/backup_ptr_stmt.result
  mysql-test/suite/backup_engines/t/backup_ptr_commit_mixed.test
  mysql-test/suite/backup_engines/t/backup_ptr_commit_row.test
  mysql-test/suite/backup_engines/t/backup_ptr_commit_stmt.test
  mysql-test/suite/backup_engines/t/backup_ptr_mixed.test
  mysql-test/suite/backup_engines/t/backup_ptr_objects_mixed.test
  mysql-test/suite/backup_engines/t/backup_ptr_objects_row.test
  mysql-test/suite/backup_engines/t/backup_ptr_objects_stmt.test
  mysql-test/suite/backup_engines/t/backup_ptr_row.test
  mysql-test/suite/backup_engines/t/backup_ptr_stmt.test
renamed:
  mysql-test/r/backup.result => mysql-test/suite/backup/r/backup.result
  mysql-test/r/backup_backupdir.result => mysql-test/suite/backup/r/backup_backupdir.result
  mysql-test/r/backup_blob.result => mysql-test/suite/backup/r/backup_blob.result
  mysql-test/r/backup_charsets.result => mysql-test/suite/backup/r/backup_charsets.result
  mysql-test/r/backup_commit_blocker.result => mysql-test/suite/backup/r/backup_commit_blocker.result
  mysql-test/r/backup_commit_restore.result => mysql-test/suite/backup/r/backup_commit_restore.result
  mysql-test/r/backup_compression.result => mysql-test/suite/backup/r/backup_compression.result
  mysql-test/r/backup_concurrent.result => mysql-test/suite/backup/r/backup_concurrent.result
  mysql-test/r/backup_db_grants.result => mysql-test/suite/backup/r/backup_db_grants.result
  mysql-test/r/backup_ddl_blocker.result => mysql-test/suite/backup/r/backup_ddl_blocker.result
  mysql-test/r/backup_default.result => mysql-test/suite/backup/r/backup_default.result
  mysql-test/r/backup_errors.result => mysql-test/suite/backup/r/backup_errors.result
  mysql-test/r/backup_fkey.result => mysql-test/suite/backup/r/backup_fkey.result
  mysql-test/r/backup_lock_myisam.result => mysql-test/suite/backup/r/backup_lock_myisam.result
  mysql-test/r/backup_logs.result => mysql-test/suite/backup/r/backup_logs.result
  mysql-test/r/backup_logs_output.result => mysql-test/suite/backup/r/backup_logs_output.result
  mysql-test/r/backup_many_dbs.result => mysql-test/suite/backup/r/backup_many_dbs.result
  mysql-test/r/backup_multi_blocks.result => mysql-test/suite/backup/r/backup_multi_blocks.result
  mysql-test/r/backup_myisam1.result => mysql-test/suite/backup/r/backup_myisam1.result
  mysql-test/r/backup_myisam2.result => mysql-test/suite/backup/r/backup_myisam2.result
  mysql-test/r/backup_no_be.result => mysql-test/suite/backup/r/backup_no_be.result
  mysql-test/r/backup_no_data.result => mysql-test/suite/backup/r/backup_no_data.result
  mysql-test/r/backup_no_engine.result => mysql-test/suite/backup/r/backup_no_engine.result
  mysql-test/r/backup_nodata_driver.result => mysql-test/suite/backup/r/backup_nodata_driver.result
  mysql-test/r/backup_objects.result => mysql-test/suite/backup/r/backup_objects.result
  mysql-test/r/backup_procedures.result => mysql-test/suite/backup/r/backup_procedures.result
  mysql-test/r/backup_securefilepriv.result => mysql-test/suite/backup/r/backup_securefilepriv.result
  mysql-test/r/backup_security.result => mysql-test/suite/backup/r/backup_security.result
  mysql-test/r/backup_snapshot.result => mysql-test/suite/backup/r/backup_snapshot.result
  mysql-test/r/backup_tablespace.result => mysql-test/suite/backup/r/backup_tablespace.result
  mysql-test/r/backup_timeout.result => mysql-test/suite/backup/r/backup_timeout.result
  mysql-test/r/backup_triggers_and_events.result => mysql-test/suite/backup/r/backup_triggers_and_events.result
  mysql-test/r/backup_view_on_view.result => mysql-test/suite/backup/r/backup_view_on_view.result
  mysql-test/r/backup_views.result => mysql-test/suite/backup/r/backup_views.result
  mysql-test/suite/backup => mysql-test/suite/backup_engines
  mysql-test/t/backup.test => mysql-test/suite/backup/t/backup.test
  mysql-test/t/backup_backupdir.test => mysql-test/suite/backup/t/backup_backupdir.test
  mysql-test/t/backup_blob.test => mysql-test/suite/backup/t/backup_blob.test
  mysql-test/t/backup_charsets.test => mysql-test/suite/backup/t/backup_charsets.test
  mysql-test/t/backup_commit_blocker.test => mysql-test/suite/backup/t/backup_commit_blocker.test
  mysql-test/t/backup_commit_restore.test => mysql-test/suite/backup/t/backup_commit_restore.test
  mysql-test/t/backup_compression.test => mysql-test/suite/backup/t/backup_compression.test
  mysql-test/t/backup_concurrent.test => mysql-test/suite/backup/t/backup_concurrent.test
  mysql-test/t/backup_db_grants.test => mysql-test/suite/backup/t/backup_db_grants.test
  mysql-test/t/backup_ddl_blocker.test => mysql-test/suite/backup/t/backup_ddl_blocker.test
  mysql-test/t/backup_default.test => mysql-test/suite/backup/t/backup_default.test
  mysql-test/t/backup_errors.test => mysql-test/suite/backup/t/backup_errors.test
  mysql-test/t/backup_fkey.test => mysql-test/suite/backup/t/backup_fkey.test
  mysql-test/t/backup_lock_myisam.test => mysql-test/suite/backup/t/backup_lock_myisam.test
  mysql-test/t/backup_logs.test => mysql-test/suite/backup/t/backup_logs.test
  mysql-test/t/backup_logs_output.test => mysql-test/suite/backup/t/backup_logs_output.test
  mysql-test/t/backup_many_dbs.test => mysql-test/suite/backup/t/backup_many_dbs.test
  mysql-test/t/backup_multi_blocks.test => mysql-test/suite/backup/t/backup_multi_blocks.test
  mysql-test/t/backup_myisam1-master.opt => mysql-test/suite/backup/t/backup_myisam1-master.opt
  mysql-test/t/backup_myisam1.test => mysql-test/suite/backup/t/backup_myisam1.test
  mysql-test/t/backup_myisam2.test => mysql-test/suite/backup/t/backup_myisam2.test
  mysql-test/t/backup_no_be.test => mysql-test/suite/backup/t/backup_no_be.test
  mysql-test/t/backup_no_data.test => mysql-test/suite/backup/t/backup_no_data.test
  mysql-test/t/backup_no_engine.test => mysql-test/suite/backup/t/backup_no_engine.test
  mysql-test/t/backup_nodata_driver.test => mysql-test/suite/backup/t/backup_nodata_driver.test
  mysql-test/t/backup_objects.test => mysql-test/suite/backup/t/backup_objects.test
  mysql-test/t/backup_procedures.test => mysql-test/suite/backup/t/backup_procedures.test
  mysql-test/t/backup_securefilepriv-master.opt => mysql-test/suite/backup/t/backup_securefilepriv-master.opt
  mysql-test/t/backup_securefilepriv.test => mysql-test/suite/backup/t/backup_securefilepriv.test
  mysql-test/t/backup_security.test => mysql-test/suite/backup/t/backup_security.test
  mysql-test/t/backup_snapshot.opt => mysql-test/suite/backup/t/backup_snapshot.opt
  mysql-test/t/backup_snapshot.test => mysql-test/suite/backup/t/backup_snapshot.test
  mysql-test/t/backup_tablespace.test => mysql-test/suite/backup/t/backup_tablespace.test
  mysql-test/t/backup_timeout.test => mysql-test/suite/backup/t/backup_timeout.test
  mysql-test/t/backup_triggers_and_events.test => mysql-test/suite/backup/t/backup_triggers_and_events.test
  mysql-test/t/backup_view_on_view.test => mysql-test/suite/backup/t/backup_view_on_view.test
  mysql-test/t/backup_views.test => mysql-test/suite/backup/t/backup_views.test
modified:
  .bzrignore
  include/errmsg.h
  libmysql/Makefile.am
  libmysql/Makefile.shared
  libmysql/errmsg.c
  libmysql/libmysql.c
  libmysqld/libmysqld.c
  mysql-test/lib/mtr_report.pl
  mysql-test/r/binlog_format_basic.result
  mysql-test/r/create.result
  mysql-test/r/log_tables.result
  mysql-test/r/mysql.result
  mysql-test/r/partition.result
  mysql-test/r/partition_innodb.result
  mysql-test/r/plugin.result
  mysql-test/r/sp.result
  mysql-test/r/storage_engine_basic.result
  mysql-test/r/variables.result
  mysql-test/suite/backup_engines/t/backup_functions.test
  mysql-test/suite/backup_engines/t/backup_procedures.test
  mysql-test/suite/backup_engines/t/backup_triggers.test
  mysql-test/suite/falcon/r/falcon_bugs.result
  mysql-test/suite/falcon/t/falcon_bugs.test
  mysql-test/suite/falcon/t/falcon_year_4digit.test
  mysql-test/t/binlog_format_basic.test
  mysql-test/t/ps.test
  mysql-test/t/ps_1general.test
  mysql-test/t/query_cache.test
  mysql-test/t/sp.test
  mysql-test/t/subselect3.test
  mysys/my_largepage.c
  scripts/make_win_bin_dist
  sql-common/client.c
  sql/Makefile.am
  sql/backup/backup_info.cc
  sql/backup/backup_info.h
  sql/backup/backup_kernel.h
  sql/backup/backup_test.cc
  sql/backup/data_backup.cc
  sql/backup/error.h
  sql/backup/image_info.h
  sql/backup/kernel.cc
  sql/backup/logger.cc
  sql/backup/logger.h
  sql/backup/stream_v1.c
  sql/backup/stream_v1_transport.c
  sql/filesort.cc
  sql/handler.cc
  sql/log.cc
  sql/mysql_priv.h
  sql/mysqld.cc
  sql/net_serv.cc
  sql/probes.d
  sql/probes.h
  sql/scheduler.cc
  sql/share/errmsg.txt
  sql/si_logs.cc
  sql/si_logs.h
  sql/si_objects.cc
  sql/si_objects.h
  sql/sp_head.cc
  sql/sql_cache.cc
  sql/sql_class.cc
  sql/sql_connect.cc
  sql/sql_cursor.cc
  sql/sql_delete.cc
  sql/sql_insert.cc
  sql/sql_parse.cc
  sql/sql_prepare.cc
  sql/sql_select.cc
  sql/sql_table.cc
  sql/sql_update.cc
  storage/falcon/Bitmap.cpp
  storage/falcon/Cache.cpp
  storage/falcon/Database.cpp
  storage/falcon/NNode.h
  storage/falcon/StorageConnection.cpp
  storage/falcon/StorageConnection.h
  storage/falcon/StorageTable.cpp
  storage/falcon/StorageTable.h
  storage/falcon/StorageTableShare.cpp
  storage/falcon/StorageTableShare.h
  storage/falcon/StorageVersion.h
  storage/falcon/SyncHandler.cpp
  storage/falcon/SyncHandler.h
  storage/falcon/Table.cpp
  storage/falcon/TransactionManager.cpp
  storage/falcon/Types.h
  storage/falcon/ha_falcon.cpp
  storage/falcon/ha_falcon.h
  storage/falcon/plug.in
  support-files/my-huge.cnf.sh
  support-files/my-large.cnf.sh
  support-files/my-medium.cnf.sh
  support-files/my-small.cnf.sh
  support-files/mysql.spec.sh
  tests/mysql_client_test.c
  mysql-test/suite/backup/r/backup.result
  mysql-test/suite/backup/r/backup_errors.result
  mysql-test/suite/backup/t/backup.test
  mysql-test/suite/backup/t/backup_errors.test
  mysql-test/suite/backup/t/backup_no_data.test

=== modified file '.bzrignore'
--- a/.bzrignore	2008-10-01 12:02:28 +0000
+++ b/.bzrignore	2008-10-16 12:39:30 +0000
@@ -1898,3 +1898,4 @@ mysql-test/tps.log
 libmysqld/event_parse_data.cc
 client/transaction.h
 libmysqld/transaction.cc
+libmysqld/rpl_handler.cc

=== modified file 'include/errmsg.h'
--- a/include/errmsg.h	2008-05-20 16:36:26 +0000
+++ b/include/errmsg.h	2008-10-17 12:39:34 +0000
@@ -97,6 +97,7 @@ extern const char *client_errors[];	/* E
 #define CR_SERVER_LOST_EXTENDED			2055
 #define CR_STMT_CLOSED				2056
 #define CR_NEW_STMT_METADATA                    2057
-#define CR_ERROR_LAST  /*Copy last error nr:*/  2057
+#define CR_ALREADY_CONNECTED                    2058
+#define CR_ERROR_LAST  /*Copy last error nr:*/  2058
 /* Add error numbers before CR_ERROR_LAST and change it accordingly. */
 

=== modified file 'libmysql/Makefile.am'
--- a/libmysql/Makefile.am	2008-09-29 17:47:27 +0000
+++ b/libmysql/Makefile.am	2008-10-10 16:23:30 +0000
@@ -67,6 +67,8 @@ link_sources:
 	  done; \
 	  rm -f net.c; \
 	  @LN_CP_F@ $(top_srcdir)/sql/net_serv.cc net.c ; \
+	  rm -f probes.h; \
+	  @LN_CP_F@ $(top_srcdir)/sql/probes.h probes.h
 	  rm -f password.c; \
 	  @LN_CP_F@ $(top_srcdir)/sql/password.c password.c
 	  echo timestamp > link_sources

=== modified file 'libmysql/Makefile.shared'
--- a/libmysql/Makefile.shared	2008-05-29 15:44:11 +0000
+++ b/libmysql/Makefile.shared	2008-10-02 12:08:09 +0000
@@ -107,7 +107,7 @@ clean-local:
 	      `echo $(sql_cmn_objects) | sed "s;\.lo;.c;g"` \
 	       $(CHARSET_SRCS) $(CHARSET_OBJS) \
 	       $(mystringsextra) $(mysysheaders) $(vioheaders) \
-               net.c
+               net.c probes.h
 
 conf_to_src_SOURCES = conf_to_src.c
 conf_to_src_LDADD=

=== modified file 'libmysql/errmsg.c'
--- a/libmysql/errmsg.c	2008-05-20 16:36:26 +0000
+++ b/libmysql/errmsg.c	2008-10-17 12:39:34 +0000
@@ -85,6 +85,7 @@ const char *client_errors[]=
   "Lost connection to MySQL server at '%s', system error: %d",
   "Statement closed indirectly because of a preceeding %s() call",
   "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+  "This handle is already connected. Use a separate handle for each connection."
   ""
 };
 
@@ -151,6 +152,7 @@ const char *client_errors[]=
   "Lost connection to MySQL server at '%s', system error: %d",
   "Statement closed indirectly because of a preceeding %s() call",
   "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+  "This handle is already connected. Use a separate handle for each connection."
   ""
 };
 
@@ -215,6 +217,7 @@ const char *client_errors[]=
   "Lost connection to MySQL server at '%s', system error: %d",
   "Statement closed indirectly because of a preceeding %s() call",
   "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+  "This handle is already connected. Use a separate handle for each connection."
   ""
 };
 #endif

=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c	2008-08-07 17:52:43 +0000
+++ b/libmysql/libmysql.c	2008-10-17 11:03:46 +0000
@@ -1748,19 +1748,21 @@ static void alloc_stmt_fields(MYSQL_STMT
 	 field= stmt->fields;
        field && fields < end; fields++, field++)
   {
-    field->catalog  = strdup_root(alloc,fields->catalog);
-    field->db       = strdup_root(alloc,fields->db);
-    field->table    = strdup_root(alloc,fields->table);
-    field->org_table= strdup_root(alloc,fields->org_table);
-    field->name     = strdup_root(alloc,fields->name);
-    field->org_name = strdup_root(alloc,fields->org_name);
-    field->charsetnr= fields->charsetnr;
-    field->length   = fields->length;
-    field->type     = fields->type;
-    field->flags    = fields->flags;
-    field->decimals = fields->decimals;
-    field->def      = fields->def ? strdup_root(alloc,fields->def): 0;
-    field->max_length= 0;
+    *field= *fields; /* To copy all numeric parts. */
+    field->catalog=   strmake_root(alloc, fields->catalog,
+                                   fields->catalog_length);
+    field->db=        strmake_root(alloc, fields->db, fields->db_length);
+    field->table=     strmake_root(alloc, fields->table, fields->table_length);
+    field->org_table= strmake_root(alloc, fields->org_table,
+                                   fields->org_table_length);
+    field->name=      strmake_root(alloc, fields->name, fields->name_length);
+    field->org_name=  strmake_root(alloc, fields->org_name,
+                                   fields->org_name_length);
+    field->def      = fields->def ? strmake_root(alloc, fields->def,
+                                                 fields->def_length) : 0;
+    field->def_length= field->def ? fields->def_length : 0;
+    field->extension= 0; /* Avoid dangling links. */
+    field->max_length= 0; /* max_length is set in mysql_stmt_store_result() */
   }
 }
 

=== modified file 'libmysqld/libmysqld.c'
--- a/libmysqld/libmysqld.c	2008-03-27 18:40:00 +0000
+++ b/libmysqld/libmysqld.c	2008-10-17 15:11:28 +0000
@@ -28,6 +28,7 @@
 #include <sys/stat.h>
 #include <signal.h>
 #include <time.h>
+#include <sql_common.h>
 #include "client_settings.h"
 #ifdef	 HAVE_PWD_H
 #include <pwd.h>
@@ -81,14 +82,6 @@ static my_bool is_NT(void)
 ** Shut down connection
 **************************************************************************/
 
-static void end_server(MYSQL *mysql)
-{
-  DBUG_ENTER("end_server");
-  free_old_query(mysql);
-  DBUG_VOID_RETURN;
-}
-
-
 int mysql_init_character_set(MYSQL *mysql);
 
 MYSQL * STDCALL
@@ -104,6 +97,13 @@ mysql_real_connect(MYSQL *mysql,const ch
 		      db ? db : "(Null)",
 		      user ? user : "(Null)"));
 
+  /* Test whether we're already connected */
+  if (mysql->server_version)
+  {
+    set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
+    DBUG_RETURN(0);
+  }
+
   if (!host || !host[0])
     host= mysql->options.host;
 
@@ -215,7 +215,7 @@ error:
   {
     /* Free alloced memory */
     my_bool free_me=mysql->free_me;
-    end_server(mysql);
+    free_old_query(mysql);
     mysql->free_me=0;
     mysql_close(mysql);
     mysql->free_me=free_me;

=== modified file 'mysql-test/lib/mtr_report.pl'
--- a/mysql-test/lib/mtr_report.pl	2008-10-02 08:52:13 +0000
+++ b/mysql-test/lib/mtr_report.pl	2008-10-16 14:30:35 +0000
@@ -329,43 +329,43 @@ sub mtr_report_stats ($) {
                 /Slave SQL:.*(?:Error_code: \d+|Query:.*)/ or
 		
 		# backup_errors test is supposed to trigger lots of backup related errors
-		($testname eq 'main.backup_errors') and
+		($testname eq 'backup.backup_errors') and
 		(
-		  /Backup:/ or /Restore:/ or /Can't open the backup log tables/
+		  /Backup:/ or /Restore:/ or /Can't open the backup logs as tables/
 		) or
 
 		# backup_backupdir test is supposed to trigger backup related errors
-		($testname eq 'main.backup_backupdir') and
+		($testname eq 'backup.backup_backupdir') and
 		(
 		  /Backup:/ or /Can't write to backup location/
 		) or
                 
 		# backup_concurrent performs a backup that should fail
-		($testname eq 'main.backup_concurrent') and
+		($testname eq 'backup.backup_concurrent') and
 		(
 		  /Can't execute this command because another BACKUP\/RESTORE operation is in progress/
 		) or
                 
 		# backup_db_grants test is supposed to trigger lots of restore warnings
-		($testname eq 'main.backup_db_grants') and
+		($testname eq 'backup.backup_db_grants') and
 		(
 		  /Restore:/ or /was skipped because the user does not exist/
 		) or
                 
 		# The tablespace test triggers error below on purpose
-		($testname eq 'main.backup_tablespace') and
+		($testname eq 'backup.backup_tablespace') and
 		(
 		  /Restore: Tablespace .* needed by tables being restored has changed on the server/
 		) or
                 
 		# The backup_securefilepriv test triggers error below on purpose
-		($testname eq 'main.backup_securefilepriv') and
+		($testname eq 'backup.backup_securefilepriv') and
 		(
 		  /Backup: The MySQL server is running with the /
 		) or
 		
 		# The views test triggers errors below on purpose
-		($testname eq 'main.backup_views') and
+		($testname eq 'backup.backup_views') and
 		(
 		  /Backup: Failed to add view/ or
 		  /Backup: Failed to obtain meta-data for view/ or
@@ -373,11 +373,11 @@ sub mtr_report_stats ($) {
 		) or
  	 
 		# ignore warning generated when backup engine selection algorithm is tested
-		($testname eq 'main.backup_no_be') and /Backup: Cannot create backup engine/ or
+		($testname eq 'backup.backup_no_be') and /Backup: Cannot create backup engine/ or
 		# ignore warnings generated when backup privilege is tested
-		($testname eq 'main.backup_security') and /(Backup|Restore): Access denied; you need the SUPER/ or
+		($testname eq 'backup.backup_security') and /(Backup|Restore): Access denied; you need the SUPER/ or
 		
-                ($testname eq 'main.backup_myisam1') and
+                ($testname eq 'backup.backup_myisam1') and
                 (/Backup: Can't initialize MyISAM backup driver/) or
 		/Sort aborted/ or
 		/Time-out in NDB/ or

=== modified file 'mysql-test/r/binlog_format_basic.result'
--- a/mysql-test/r/binlog_format_basic.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/binlog_format_basic.result	2008-10-22 14:08:10 +0000
@@ -1,3 +1,6 @@
+SELECT @@GLOBAL.binlog_format;
+@@GLOBAL.binlog_format
+MIXED
 '#---------------------BS_STVARS_002_01----------------------#'
 SELECT COUNT(@@GLOBAL.binlog_format);
 COUNT(@@GLOBAL.binlog_format)

=== modified file 'mysql-test/r/create.result'
--- a/mysql-test/r/create.result	2008-10-02 14:03:57 +0000
+++ b/mysql-test/r/create.result	2008-10-17 14:13:24 +0000
@@ -228,7 +228,7 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=MEMORY DEFAULT CHARSET=latin1
 drop table t1;
 SET SESSION storage_engine="gemini";
-ERROR 42000: Unknown table engine 'gemini'
+ERROR 42000: Unknown storage engine 'gemini'
 SELECT @@storage_engine;
 @@storage_engine
 MEMORY
@@ -389,7 +389,7 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=MEMORY DEFAULT CHARSET=latin1
 drop table t1;
 SET SESSION storage_engine="gemini";
-ERROR 42000: Unknown table engine 'gemini'
+ERROR 42000: Unknown storage engine 'gemini'
 SELECT @@storage_engine;
 @@storage_engine
 MEMORY

=== modified file 'mysql-test/r/log_tables.result'
--- a/mysql-test/r/log_tables.result	2008-09-29 18:20:59 +0000
+++ b/mysql-test/r/log_tables.result	2008-10-17 14:13:24 +0000
@@ -235,7 +235,7 @@ set @save_storage_engine= @@session.stor
 set storage_engine= MEMORY;
 alter table mysql.slow_log engine=NonExistentEngine;
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 alter table mysql.slow_log engine=memory;
 ERROR HY000: This storage engine cannot be used for log tables"
 set storage_engine= @save_storage_engine;

=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result	2008-07-23 11:28:20 +0000
+++ b/mysql-test/r/mysql.result	2008-10-17 14:13:24 +0000
@@ -378,9 +378,9 @@ WARNING: --server-arg option not support
 +---+
 | 1 | 
 +---+
-Warning (Code 1286): Unknown table engine 'nonexistent'
+Warning (Code 1286): Unknown storage engine 'nonexistent'
 Warning (Code 1266): Using storage engine MyISAM for table 't2'
-Warning (Code 1286): Unknown table engine 'nonexistent2'
+Warning (Code 1286): Unknown storage engine 'nonexistent2'
 Warning (Code 1266): Using storage engine MyISAM for table 't2'
 Error (Code 1050): Table 't2' already exists
 drop tables t1, t2;

=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2008-10-07 15:40:12 +0000
+++ b/mysql-test/r/partition.result	2008-10-17 14:13:24 +0000
@@ -2,30 +2,30 @@ drop table if exists t1, t2;
 CREATE TABLE t1 (a INT)
 ENGINE=NonExistentEngine;
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 Warning	1266	Using storage engine MyISAM for table 't1'
 DROP TABLE t1;
 CREATE TABLE t1 (a INT)
 ENGINE=NonExistentEngine
 PARTITION BY HASH (a);
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 Warning	1266	Using storage engine MyISAM for table 't1'
 DROP TABLE t1;
 CREATE TABLE t1 (a INT)
 ENGINE=Memory;
 ALTER TABLE t1 ENGINE=NonExistentEngine;
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 ALTER TABLE t1
 PARTITION BY HASH (a)
 (PARTITION p0 ENGINE=Memory,
 PARTITION p1 ENGINE=NonExistentEngine);
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 ALTER TABLE t1 ENGINE=NonExistentEngine;
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (

=== modified file 'mysql-test/r/partition_innodb.result'
--- a/mysql-test/r/partition_innodb.result	2008-07-07 17:54:50 +0000
+++ b/mysql-test/r/partition_innodb.result	2008-10-17 14:13:24 +0000
@@ -66,7 +66,7 @@ create table t1 (a int)
 engine = x
 partition by key (a);
 Warnings:
-Warning	1286	Unknown table engine 'x'
+Warning	1286	Unknown storage engine 'x'
 Warning	1266	Using storage engine MyISAM for table 't1'
 show create table t1;
 Table	Create Table
@@ -80,7 +80,7 @@ partition by list (a)
 (partition p0 values in (0));
 alter table t1 engine = x;
 Warnings:
-Warning	1286	Unknown table engine 'x'
+Warning	1286	Unknown storage engine 'x'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (

=== modified file 'mysql-test/r/plugin.result'
--- a/mysql-test/r/plugin.result	2008-02-24 13:12:17 +0000
+++ b/mysql-test/r/plugin.result	2008-10-17 14:13:24 +0000
@@ -1,6 +1,6 @@
 CREATE TABLE t1(a int) ENGINE=EXAMPLE;
 Warnings:
-Warning	1286	Unknown table engine 'EXAMPLE'
+Warning	1286	Unknown storage engine 'EXAMPLE'
 Warning	1266	Using storage engine MyISAM for table 't1'
 DROP TABLE t1;
 INSTALL PLUGIN example SONAME 'ha_example.so';

=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result	2008-09-25 11:46:17 +0000
+++ b/mysql-test/r/sp.result	2008-10-16 12:39:30 +0000
@@ -6948,3 +6948,21 @@ drop procedure p;
 # ------------------------------------------------------------------
 # -- End of 5.1 tests
 # ------------------------------------------------------------------
+DROP FUNCTION IF EXISTS f1;
+DROP TABLE IF EXISTS t_non_existing;
+DROP TABLE IF EXISTS t1;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+DECLARE v INT;
+SELECT a INTO v FROM t_non_existing;
+RETURN 1;
+END|
+CREATE TABLE t1 (a INT) ENGINE = myisam;
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1 WHERE a = f1();
+ERROR 42S02: Table 'test.t_non_existing' doesn't exist
+DROP FUNCTION f1;
+DROP TABLE t1;
+# ------------------------------------------------------------------
+# -- End of 6.0 tests
+# ------------------------------------------------------------------

=== modified file 'mysql-test/r/storage_engine_basic.result'
--- a/mysql-test/r/storage_engine_basic.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/storage_engine_basic.result	2008-10-17 14:13:24 +0000
@@ -60,13 +60,13 @@ ERROR 42000: Incorrect argument type to 
 SET @@global.storage_engine = 65530.34.;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
 SET @@global.storage_engine = FILE;
-ERROR 42000: Unknown table engine 'FILE'
+ERROR 42000: Unknown storage engine 'FILE'
 SET @@session.storage_engine = 8199;
 ERROR 42000: Incorrect argument type to variable 'storage_engine'
 SET @@session.storage_engine = 65530.34.;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
 SET @@session.storage_engine = RECORD;
-ERROR 42000: Unknown table engine 'RECORD'
+ERROR 42000: Unknown storage engine 'RECORD'
 '#------------------FN_DYNVARS_005_05-----------------------#'
 SELECT @@global.storage_engine =
 VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES

=== modified file 'mysql-test/r/variables.result'
--- a/mysql-test/r/variables.result	2008-05-29 12:56:51 +0000
+++ b/mysql-test/r/variables.result	2008-10-17 14:13:24 +0000
@@ -378,7 +378,7 @@ ERROR HY000: Unknown system variable 'un
 set max_join_size="hello";
 ERROR 42000: Incorrect argument type to variable 'max_join_size'
 set storage_engine=UNKNOWN_TABLE_TYPE;
-ERROR 42000: Unknown table engine 'UNKNOWN_TABLE_TYPE'
+ERROR 42000: Unknown storage engine 'UNKNOWN_TABLE_TYPE'
 set storage_engine=MERGE, big_tables=2;
 ERROR 42000: Variable 'big_tables' can't be set to the value of '2'
 show local variables like 'storage_engine';

=== added directory 'mysql-test/suite/backup'
=== added directory 'mysql-test/suite/backup/r'
=== renamed file 'mysql-test/r/backup.result' => 'mysql-test/suite/backup/r/backup.result'
--- a/mysql-test/r/backup.result	2008-07-01 20:32:27 +0000
+++ b/mysql-test/suite/backup/r/backup.result	2008-10-07 17:15:44 +0000
@@ -10,17 +10,13 @@ CREATE TABLE `building` (
 `dir_code` char(4),
 `building` char(6)
 ) ENGINE=MYISAM DEFAULT CHARSET=latin1;
-LOCK TABLES `building` WRITE;
 INSERT INTO `building` VALUES ('N41','1300'),('N01','1453'),('M00','1000'),('N41','1301'),('N41','1305');
-UNLOCK TABLES;
 CREATE TABLE `directorate` (
 `dir_code` char(4),
 `dir_name` char(30),
 `dir_head_id` char(9)
 ) ENGINE=MYISAM DEFAULT CHARSET=latin1;
-LOCK TABLES `directorate` WRITE;
 INSERT INTO `directorate` VALUES ('N41','Development','333445555'),('N01','Human Resources','123654321'),('M00','Management','333444444');
-UNLOCK TABLES;
 USE db2;
 CREATE TABLE `staff` (
 `id` char(9),
@@ -31,17 +27,13 @@ CREATE TABLE `staff` (
 `salary` int(11),
 `mgr_id` char(9)
 ) ENGINE=MYISAM DEFAULT CHARSET=latin1;
-LOCK TABLES `staff` WRITE;
 INSERT INTO `staff` VALUES ('333445555','John','Q','Smith','M',30000,'333444444'),('123763153','William','E','Walters','M',25000,'123654321'),('333444444','Alicia','F','St.Cruz','F',25000,NULL),('921312388','Goy','X','Hong','F',40000,'123654321'),('800122337','Rajesh','G','Kardakarna','M',38000,'333445555'),('820123637','Monty','C','Smythe','M',38000,'333445555'),('830132335','Richard','E','Jones','M',38000,'333445555'),('333445665','Edward','E','Engles','M',25000,'333445555'),('123654321','Beware','D','Borg','F',55000,'333444444'),('123456789','Wilma','N','Maxima','F',43000,'333445555');
-UNLOCK TABLES;
 CREATE TABLE `tasking` (
 `id` char(9),
 `project_number` char(9),
 `hours_worked` double(10,2)
 ) ENGINE=blackhole DEFAULT CHARSET=latin1;
-LOCK TABLES `tasking` WRITE;
 INSERT INTO `tasking` VALUES ('333445555','405',23),('123763153','405',33.5),('921312388','601',44),('800122337','300',13),('820123637','300',9.5),('830132335','401',8.5),('333445555','300',11),('921312388','500',13),('800122337','300',44),('820123637','401',500.5),('830132335','400',12),('333445665','600',300.25),('123654321','607',444.75),('123456789','300',1000);
-UNLOCK TABLES;
 backup: Activate synchronization points for BACKUP.
 Depending on the driver used, one of the sync points is used,
 and the result differs in PROCESSLIST state and info.
@@ -67,12 +59,20 @@ breakpoints: Sending finish signal to wa
 SET DEBUG_SYNC= 'now SIGNAL finish';
 backup_id
 #
+SELECT MAX(backup_id) FROM mysql.backup_history INTO @bid;
+SELECT validity_point_time FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_time;
+SELECT binlog_file FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_file;
+SELECT binlog_pos FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_pos;
 DROP DATABASE db1;
 DROP DATABASE db2;
 USE mysql;
 RESTORE FROM 'test.ba';
 backup_id
 #
+SELECT MAX(backup_id) FROM mysql.backup_history INTO @bid;
 SHOW CREATE DATABASE db1;
 Database	Create Database
 db1	CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 */
@@ -132,6 +132,18 @@ tasking	CREATE TABLE `tasking` (
   `project_number` char(9) DEFAULT NULL,
   `hours_worked` double(10,2) DEFAULT NULL
 ) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1
+SELECT validity_point_time = @vp_time FROM mysql.backup_history
+WHERE backup_id = @bid;
+validity_point_time = @vp_time
+1
+SELECT binlog_file = @vp_file FROM mysql.backup_history
+WHERE backup_id = @bid;
+binlog_file = @vp_file
+1
+SELECT binlog_pos = @vp_pos FROM mysql.backup_history
+WHERE backup_id = @bid;
+binlog_pos = @vp_pos
+1
 DROP DATABASE db1;
 DROP DATABASE db2;
 DROP DATABASE db3;

=== renamed file 'mysql-test/r/backup_backupdir.result' => 'mysql-test/suite/backup/r/backup_backupdir.result'
=== renamed file 'mysql-test/r/backup_blob.result' => 'mysql-test/suite/backup/r/backup_blob.result'
=== renamed file 'mysql-test/r/backup_charsets.result' => 'mysql-test/suite/backup/r/backup_charsets.result'
=== added file 'mysql-test/suite/backup/r/backup_commit_backup.result'
--- a/mysql-test/suite/backup/r/backup_commit_backup.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_commit_backup.result	2008-10-07 17:15:44 +0000
@@ -0,0 +1,324 @@
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+CREATE TABLE db1.t1 (s1 CHAR(3)) ENGINE=innodb;
+CREATE TABLE db1.t2 (s1 CHAR(3)) ENGINE=falcon;
+CREATE TABLE db1.t3 (s1 CHAR(3)) ENGINE=memory;
+CREATE TABLE db1.t4 (s1 CHAR(3)) ENGINE=myisam;
+CREATE TABLE db2.t1 (s1 CHAR(3)) ENGINE=innodb;
+CREATE TABLE db2.t2 (s1 CHAR(3)) ENGINE=falcon;
+CREATE TABLE db2.t3 (s1 CHAR(3)) ENGINE=myisam;
+connection B - starting transaction B
+SET autocommit=0;
+BEGIN;
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+INSERT INTO db1.t1 VALUES ('b1');
+INSERT INTO db1.t2 VALUES ('b1');
+INSERT INTO db1.t3 VALUES ('b1');
+INSERT INTO db1.t4 VALUES ('b1');
+INSERT INTO db2.t1 VALUES ('b1');
+INSERT INTO db2.t2 VALUES ('b1');
+INSERT INTO db2.t3 VALUES ('b1');
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+SELECT * FROM db1.t2;
+s1
+SELECT * FROM db1.t3;
+s1
+b1
+SELECT * FROM db1.t4;
+s1
+b1
+SELECT * FROM db2.t1;
+s1
+SELECT * FROM db2.t2;
+s1
+SELECT * FROM db2.t3;
+s1
+b1
+SELECT release_lock("sync");
+release_lock("sync")
+1
+connection A - starting transaction A
+SET autocommit=0;
+BEGIN;
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+INSERT INTO db1.t1 VALUES ('a1');
+INSERT INTO db1.t2 VALUES ('a1');
+INSERT INTO db1.t3 VALUES ('a1');
+INSERT INTO db1.t4 VALUES ('a1');
+INSERT INTO db2.t1 VALUES ('a1');
+INSERT INTO db2.t2 VALUES ('a1');
+INSERT INTO db2.t3 VALUES ('a1');
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+SELECT * FROM db1.t2;
+s1
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+SELECT * FROM db2.t1;
+s1
+SELECT * FROM db2.t2;
+s1
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+SELECT release_lock("sync");
+release_lock("sync")
+1
+connection B - performing BACKUP which commits transaction B
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+INSERT INTO db1.t1 VALUES ('b2');
+INSERT INTO db1.t2 VALUES ('b2');
+INSERT INTO db1.t3 VALUES ('b2');
+INSERT INTO db1.t4 VALUES ('b2');
+INSERT INTO db2.t1 VALUES ('b2');
+INSERT INTO db2.t2 VALUES ('b2');
+INSERT INTO db2.t3 VALUES ('b2');
+BACKUP DATABASE db1 TO 'db1.bak';
+backup_id
+#
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+b1
+b2
+SELECT * FROM db1.t2;
+s1
+b1
+b2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+SELECT * FROM db2.t1;
+s1
+b1
+b2
+SELECT * FROM db2.t2;
+s1
+b1
+b2
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+b2
+SELECT release_lock("sync");
+release_lock("sync")
+1
+connection B - doing ROLLBACK which should be a no-op after the implicit commit
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+ROLLBACK;
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+b1
+b2
+SELECT * FROM db1.t2;
+s1
+b1
+b2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+SELECT * FROM db2.t1;
+s1
+b1
+b2
+SELECT * FROM db2.t2;
+s1
+b1
+b2
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+b2
+SELECT release_lock("sync");
+release_lock("sync")
+1
+connection A - finishing transaction A
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+INSERT INTO db1.t1 VALUES ('a2');
+INSERT INTO db1.t2 VALUES ('a2');
+INSERT INTO db1.t3 VALUES ('a2');
+INSERT INTO db1.t4 VALUES ('a2');
+INSERT INTO db2.t1 VALUES ('a2');
+INSERT INTO db2.t2 VALUES ('a2');
+INSERT INTO db2.t3 VALUES ('a2');
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+b1
+b2
+SELECT * FROM db1.t2;
+s1
+b1
+b2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db2.t1;
+s1
+b1
+b2
+SELECT * FROM db2.t2;
+s1
+b1
+b2
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+b2
+a2
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+COMMIT;
+SELECT release_lock("sync");
+release_lock("sync")
+1
+SELECT get_lock("sync",10);
+get_lock("sync",10)
+1
+SELECT * FROM db1.t1;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db1.t2;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db2.t1;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db2.t2;
+s1
+b1
+a1
+b2
+a2
+SELECT * FROM db2.t3;
+s1
+b1
+a1
+b2
+a2
+SELECT release_lock("sync");
+release_lock("sync")
+1
+Checking contents of the backup image
+RESTORE FROM 'db1.bak';
+backup_id
+#
+SELECT * FROM db1.t1;
+s1
+b1
+b2
+SELECT * FROM db1.t2;
+s1
+b1
+b2
+SELECT * FROM db1.t3;
+s1
+b1
+a1
+b2
+SELECT * FROM db1.t4;
+s1
+b1
+a1
+b2
+DROP DATABASE db1;
+DROP DATABASE db2;

=== renamed file 'mysql-test/r/backup_commit_blocker.result' => 'mysql-test/suite/backup/r/backup_commit_blocker.result'
=== renamed file 'mysql-test/r/backup_commit_restore.result' => 'mysql-test/suite/backup/r/backup_commit_restore.result'
=== renamed file 'mysql-test/r/backup_compression.result' => 'mysql-test/suite/backup/r/backup_compression.result'
=== renamed file 'mysql-test/r/backup_concurrent.result' => 'mysql-test/suite/backup/r/backup_concurrent.result'
=== renamed file 'mysql-test/r/backup_db_grants.result' => 'mysql-test/suite/backup/r/backup_db_grants.result'
=== renamed file 'mysql-test/r/backup_ddl_blocker.result' => 'mysql-test/suite/backup/r/backup_ddl_blocker.result'
=== renamed file 'mysql-test/r/backup_default.result' => 'mysql-test/suite/backup/r/backup_default.result'
=== renamed file 'mysql-test/r/backup_errors.result' => 'mysql-test/suite/backup/r/backup_errors.result'
--- a/mysql-test/r/backup_errors.result	2008-08-27 17:35:10 +0000
+++ b/mysql-test/suite/backup/r/backup_errors.result	2008-10-07 17:15:44 +0000
@@ -75,7 +75,7 @@ backup_id
 DROP TABLE mysql.backup_history;
 Backup the database;
 BACKUP DATABASE test_ob_error TO 'ob_err.bak';
-ERROR 42S02: Table 'mysql.backup_history' doesn't exist
+ERROR HY000: Can't open the backup logs as tables. Check 'mysql.backup_history' and 'mysql.backup_progress' or run mysql_upgrade to repair.
 SHOW ERRORS;
 Level	Code	Message
 Error	#	Table 'mysql.backup_history' doesn't exist
@@ -86,7 +86,7 @@ DROP TABLE test.ob_copy;
 DROP TABLE mysql.backup_progress;
 Backup the database;
 BACKUP DATABASE test_ob_error TO 'ob_err.bak';
-ERROR 42S02: Table 'mysql.backup_progress' doesn't exist
+ERROR HY000: Can't open the backup logs as tables. Check 'mysql.backup_history' and 'mysql.backup_progress' or run mysql_upgrade to repair.
 SHOW ERRORS;
 Level	Code	Message
 Error	#	Table 'mysql.backup_progress' doesn't exist

=== renamed file 'mysql-test/r/backup_fkey.result' => 'mysql-test/suite/backup/r/backup_fkey.result'
=== renamed file 'mysql-test/r/backup_lock_myisam.result' => 'mysql-test/suite/backup/r/backup_lock_myisam.result'
=== renamed file 'mysql-test/r/backup_logs.result' => 'mysql-test/suite/backup/r/backup_logs.result'
=== renamed file 'mysql-test/r/backup_logs_output.result' => 'mysql-test/suite/backup/r/backup_logs_output.result'
=== renamed file 'mysql-test/r/backup_many_dbs.result' => 'mysql-test/suite/backup/r/backup_many_dbs.result'
=== renamed file 'mysql-test/r/backup_multi_blocks.result' => 'mysql-test/suite/backup/r/backup_multi_blocks.result'
=== renamed file 'mysql-test/r/backup_myisam1.result' => 'mysql-test/suite/backup/r/backup_myisam1.result'
=== renamed file 'mysql-test/r/backup_myisam2.result' => 'mysql-test/suite/backup/r/backup_myisam2.result'
=== renamed file 'mysql-test/r/backup_no_be.result' => 'mysql-test/suite/backup/r/backup_no_be.result'
=== renamed file 'mysql-test/r/backup_no_data.result' => 'mysql-test/suite/backup/r/backup_no_data.result'
=== renamed file 'mysql-test/r/backup_no_engine.result' => 'mysql-test/suite/backup/r/backup_no_engine.result'
=== renamed file 'mysql-test/r/backup_nodata_driver.result' => 'mysql-test/suite/backup/r/backup_nodata_driver.result'
=== renamed file 'mysql-test/r/backup_objects.result' => 'mysql-test/suite/backup/r/backup_objects.result'
=== renamed file 'mysql-test/r/backup_procedures.result' => 'mysql-test/suite/backup/r/backup_procedures.result'
=== renamed file 'mysql-test/r/backup_securefilepriv.result' => 'mysql-test/suite/backup/r/backup_securefilepriv.result'
=== renamed file 'mysql-test/r/backup_security.result' => 'mysql-test/suite/backup/r/backup_security.result'
=== renamed file 'mysql-test/r/backup_snapshot.result' => 'mysql-test/suite/backup/r/backup_snapshot.result'
=== renamed file 'mysql-test/r/backup_tablespace.result' => 'mysql-test/suite/backup/r/backup_tablespace.result'
=== renamed file 'mysql-test/r/backup_timeout.result' => 'mysql-test/suite/backup/r/backup_timeout.result'
=== renamed file 'mysql-test/r/backup_triggers_and_events.result' => 'mysql-test/suite/backup/r/backup_triggers_and_events.result'
=== renamed file 'mysql-test/r/backup_view_on_view.result' => 'mysql-test/suite/backup/r/backup_view_on_view.result'
=== renamed file 'mysql-test/r/backup_views.result' => 'mysql-test/suite/backup/r/backup_views.result'
=== added directory 'mysql-test/suite/backup/t'
=== renamed file 'mysql-test/t/backup.test' => 'mysql-test/suite/backup/t/backup.test'
--- a/mysql-test/t/backup.test	2008-07-01 20:32:27 +0000
+++ b/mysql-test/suite/backup/t/backup.test	2008-10-07 17:15:44 +0000
@@ -1,6 +1,7 @@
 --source include/have_innodb.inc
 --source include/not_embedded.inc
 --source include/have_debug_sync.inc
+--source include/have_log_bin.inc
 
 SET DEBUG_SYNC= 'RESET';
 
@@ -32,9 +33,7 @@ CREATE TABLE `building` (
 # Dumping data for table `building`
 #
 
-LOCK TABLES `building` WRITE;
 INSERT INTO `building` VALUES ('N41','1300'),('N01','1453'),('M00','1000'),('N41','1301'),('N41','1305');
-UNLOCK TABLES;
 
 
 #
@@ -51,9 +50,7 @@ CREATE TABLE `directorate` (
 # Dumping data for table `directorate`
 #
 
-LOCK TABLES `directorate` WRITE;
 INSERT INTO `directorate` VALUES ('N41','Development','333445555'),('N01','Human Resources','123654321'),('M00','Management','333444444');
-UNLOCK TABLES;
 
 USE db2;
 
@@ -75,9 +72,7 @@ CREATE TABLE `staff` (
 # Dumping data for table `staff`
 #
 
-LOCK TABLES `staff` WRITE;
 INSERT INTO `staff` VALUES ('333445555','John','Q','Smith','M',30000,'333444444'),('123763153','William','E','Walters','M',25000,'123654321'),('333444444','Alicia','F','St.Cruz','F',25000,NULL),('921312388','Goy','X','Hong','F',40000,'123654321'),('800122337','Rajesh','G','Kardakarna','M',38000,'333445555'),('820123637','Monty','C','Smythe','M',38000,'333445555'),('830132335','Richard','E','Jones','M',38000,'333445555'),('333445665','Edward','E','Engles','M',25000,'333445555'),('123654321','Beware','D','Borg','F',55000,'333444444'),('123456789','Wilma','N','Maxima','F',43000,'333445555');
-UNLOCK TABLES;
 
 #
 # Table structure for table `tasking`
@@ -93,9 +88,7 @@ CREATE TABLE `tasking` (
 # Dumping data for table `tasking`
 #
 
-LOCK TABLES `tasking` WRITE;
 INSERT INTO `tasking` VALUES ('333445555','405',23),('123763153','405',33.5),('921312388','601',44),('800122337','300',13),('820123637','300',9.5),('830132335','401',8.5),('333445555','300',11),('921312388','500',13),('800122337','300',44),('820123637','401',500.5),('830132335','400',12),('333445665','600',300.25),('123654321','607',444.75),('123456789','300',1000);
-UNLOCK TABLES;
 
 #
 # Get a lock to check for locking thread in process list
@@ -132,6 +125,18 @@ connection backup;
 --replace_column 1 #
 reap;
 
+# get backup_id of the BACKUP operation. 
+SELECT MAX(backup_id) FROM mysql.backup_history INTO @bid;
+
+# store VP time and binlog position
+
+SELECT validity_point_time FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_time;
+SELECT binlog_file FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_file;
+SELECT binlog_pos FROM mysql.backup_history
+WHERE backup_id = @bid INTO @vp_pos;
+
 DROP DATABASE db1;
 DROP DATABASE db2;
 
@@ -140,9 +145,15 @@ DROP DATABASE db2;
 
 USE mysql;
 
+# wait few seconds so that restore time != backup time
+--sleep 2
+
 --replace_column 1 #
 RESTORE FROM 'test.ba';
 
+# determine id of RESTORE operation
+SELECT MAX(backup_id) FROM mysql.backup_history INTO @bid;
+
 --remove_file $MYSQLTEST_VARDIR/master-data/test.ba
 
 SHOW CREATE DATABASE db1;
@@ -167,6 +178,15 @@ CHECK TABLE staff EXTENDED;
 SELECT * FROM staff;
 SHOW CREATE TABLE tasking;
 
+# check that VP info was correctly read and reported
+
+SELECT validity_point_time = @vp_time FROM mysql.backup_history
+WHERE backup_id = @bid; 
+SELECT binlog_file = @vp_file FROM mysql.backup_history
+WHERE backup_id = @bid; 
+SELECT binlog_pos = @vp_pos FROM mysql.backup_history
+WHERE backup_id = @bid; 
+
 DROP DATABASE db1;
 DROP DATABASE db2;
 DROP DATABASE db3;

=== renamed file 'mysql-test/t/backup_backupdir.test' => 'mysql-test/suite/backup/t/backup_backupdir.test'
=== renamed file 'mysql-test/t/backup_blob.test' => 'mysql-test/suite/backup/t/backup_blob.test'
=== renamed file 'mysql-test/t/backup_charsets.test' => 'mysql-test/suite/backup/t/backup_charsets.test'
=== added file 'mysql-test/suite/backup/t/backup_commit_backup.test'
--- a/mysql-test/suite/backup/t/backup_commit_backup.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_commit_backup.test	2008-10-07 17:15:44 +0000
@@ -0,0 +1,230 @@
+#
+# This test tests interraction of BACKUP command with transactions in
+# the same and different connection (BUG#38261)
+#
+# BACKUP should commit ongoing transaction in the same connection but
+# should not interferre with transactions executing in other connections.
+#
+
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/have_falcon.inc
+
+
+LET $BDIR=`select @@backupdir`;
+
+disable_warnings;
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+error 0,1;
+remove_file $BDIR/db1.bak;
+enable_warnings;
+
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+CREATE TABLE db1.t1 (s1 CHAR(3)) ENGINE=innodb; # CS driver
+CREATE TABLE db1.t2 (s1 CHAR(3)) ENGINE=falcon; # CS driver
+CREATE TABLE db1.t3 (s1 CHAR(3)) ENGINE=memory; # default driver
+CREATE TABLE db1.t4 (s1 CHAR(3)) ENGINE=myisam; # native driver
+
+CREATE TABLE db2.t1 (s1 CHAR(3)) ENGINE=innodb; # trx1
+CREATE TABLE db2.t2 (s1 CHAR(3)) ENGINE=falcon; # trx2
+CREATE TABLE db2.t3 (s1 CHAR(3)) ENGINE=myisam; # non-trx
+
+
+# Create test connections. The setup is as follows
+#
+# connA		connB
+# -----		-----
+#		BEGIN
+#		insert data
+# BEGIN
+# insert data
+#		insert data
+#		BACKUP
+#		ROLLBACK
+# insert data
+# COMMIT	
+#
+# The default connection is used to check contents of the tables after each
+# operation.
+#
+# Note: we use "sync" lock to synchronize connections.  Without it, data 
+# inserted in one thread could be not always seen in another one, which would
+# made test non-deterministic.
+
+  connect(connA, localhost, root,,);
+    connect(connB, localhost, root,,);
+
+    connection connB;
+    echo connection B - starting transaction B; 
+    #------------------
+    SET autocommit=0;
+    BEGIN;
+
+    SELECT get_lock("sync",10);
+    INSERT INTO db1.t1 VALUES ('b1');
+    INSERT INTO db1.t2 VALUES ('b1');
+    INSERT INTO db1.t3 VALUES ('b1');
+    INSERT INTO db1.t4 VALUES ('b1');
+
+    INSERT INTO db2.t1 VALUES ('b1');
+    INSERT INTO db2.t2 VALUES ('b1');
+    INSERT INTO db2.t3 VALUES ('b1');
+    SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+  connection connA;
+  echo connection A - starting transaction A;
+  #------------------
+  SET autocommit=0;
+  BEGIN;
+
+  SELECT get_lock("sync",10);
+  INSERT INTO db1.t1 VALUES ('a1');
+  INSERT INTO db1.t2 VALUES ('a1');
+  INSERT INTO db1.t3 VALUES ('a1');
+  INSERT INTO db1.t4 VALUES ('a1');
+
+  INSERT INTO db2.t1 VALUES ('a1');
+  INSERT INTO db2.t2 VALUES ('a1');
+  INSERT INTO db2.t3 VALUES ('a1');
+  SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+    connection connB;
+    echo connection B - performing BACKUP which commits transaction B;
+    #------------------
+    SELECT get_lock("sync",10);
+    INSERT INTO db1.t1 VALUES ('b2');
+    INSERT INTO db1.t2 VALUES ('b2');
+    INSERT INTO db1.t3 VALUES ('b2');
+    INSERT INTO db1.t4 VALUES ('b2');
+
+    INSERT INTO db2.t1 VALUES ('b2');
+    INSERT INTO db2.t2 VALUES ('b2');
+    INSERT INTO db2.t3 VALUES ('b2');
+
+    replace_column 1 #;
+    BACKUP DATABASE db1 TO 'db1.bak';
+    SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+    connection connB;
+    echo connection B - doing ROLLBACK which should be a no-op after the implicit commit;
+    #------------------
+    SELECT get_lock("sync",10);
+    ROLLBACK;
+    SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+  connection connA;
+  echo connection A - finishing transaction A;
+  #------------------
+  SELECT get_lock("sync",10);
+  INSERT INTO db1.t1 VALUES ('a2');
+  INSERT INTO db1.t2 VALUES ('a2');
+  INSERT INTO db1.t3 VALUES ('a2');
+  INSERT INTO db1.t4 VALUES ('a2');
+
+  INSERT INTO db2.t1 VALUES ('a2');
+  INSERT INTO db2.t2 VALUES ('a2');
+  INSERT INTO db2.t3 VALUES ('a2');
+  SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+  connection connA;
+  #------------------
+  SELECT get_lock("sync",10);
+  COMMIT;
+  SELECT release_lock("sync");
+
+connection default;
+#------------------
+SELECT get_lock("sync",10);
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+SELECT * FROM db2.t1;
+SELECT * FROM db2.t2;
+SELECT * FROM db2.t3;
+SELECT release_lock("sync");
+
+echo Checking contents of the backup image;
+
+replace_column 1 #;
+RESTORE FROM 'db1.bak';
+
+SELECT * FROM db1.t1;
+SELECT * FROM db1.t2;
+SELECT * FROM db1.t3;
+SELECT * FROM db1.t4;
+
+# Cleanup
+
+DROP DATABASE db1;
+DROP DATABASE db2;
+remove_file $BDIR/db1.bak;

=== renamed file 'mysql-test/t/backup_commit_blocker.test' => 'mysql-test/suite/backup/t/backup_commit_blocker.test'
=== renamed file 'mysql-test/t/backup_commit_restore.test' => 'mysql-test/suite/backup/t/backup_commit_restore.test'
=== renamed file 'mysql-test/t/backup_compression.test' => 'mysql-test/suite/backup/t/backup_compression.test'
=== renamed file 'mysql-test/t/backup_concurrent.test' => 'mysql-test/suite/backup/t/backup_concurrent.test'
=== renamed file 'mysql-test/t/backup_db_grants.test' => 'mysql-test/suite/backup/t/backup_db_grants.test'
=== renamed file 'mysql-test/t/backup_ddl_blocker.test' => 'mysql-test/suite/backup/t/backup_ddl_blocker.test'
=== renamed file 'mysql-test/t/backup_default.test' => 'mysql-test/suite/backup/t/backup_default.test'
=== renamed file 'mysql-test/t/backup_errors.test' => 'mysql-test/suite/backup/t/backup_errors.test'
--- a/mysql-test/t/backup_errors.test	2008-08-27 17:35:10 +0000
+++ b/mysql-test/suite/backup/t/backup_errors.test	2008-10-07 17:15:44 +0000
@@ -181,7 +181,7 @@ DROP TABLE mysql.backup_history;
 
 # Try to backup the database (should be error).
 --echo Backup the database;
---error ER_NO_SUCH_TABLE
+--error ER_BACKUP_PROGRESS_TABLES
 BACKUP DATABASE test_ob_error TO 'ob_err.bak';
 --error 0,1
 --remove_file $MYSQLTEST_VARDIR/master-data/ob_err.bak
@@ -198,7 +198,7 @@ DROP TABLE mysql.backup_progress;
 
 # Try to backup the database (should be error).
 --echo Backup the database;
---error ER_NO_SUCH_TABLE
+--error ER_BACKUP_PROGRESS_TABLES
 BACKUP DATABASE test_ob_error TO 'ob_err.bak';
 --error 0,1
 --remove_file $MYSQLTEST_VARDIR/master-data/ob_err.bak

=== renamed file 'mysql-test/t/backup_fkey.test' => 'mysql-test/suite/backup/t/backup_fkey.test'
=== renamed file 'mysql-test/t/backup_lock_myisam.test' => 'mysql-test/suite/backup/t/backup_lock_myisam.test'
=== renamed file 'mysql-test/t/backup_logs.test' => 'mysql-test/suite/backup/t/backup_logs.test'
=== renamed file 'mysql-test/t/backup_logs_output.test' => 'mysql-test/suite/backup/t/backup_logs_output.test'
=== renamed file 'mysql-test/t/backup_many_dbs.test' => 'mysql-test/suite/backup/t/backup_many_dbs.test'
=== renamed file 'mysql-test/t/backup_multi_blocks.test' => 'mysql-test/suite/backup/t/backup_multi_blocks.test'
=== renamed file 'mysql-test/t/backup_myisam1-master.opt' => 'mysql-test/suite/backup/t/backup_myisam1-master.opt'
=== renamed file 'mysql-test/t/backup_myisam1.test' => 'mysql-test/suite/backup/t/backup_myisam1.test'
=== renamed file 'mysql-test/t/backup_myisam2.test' => 'mysql-test/suite/backup/t/backup_myisam2.test'
=== renamed file 'mysql-test/t/backup_no_be.test' => 'mysql-test/suite/backup/t/backup_no_be.test'
=== renamed file 'mysql-test/t/backup_no_data.test' => 'mysql-test/suite/backup/t/backup_no_data.test'
--- a/mysql-test/t/backup_no_data.test	2008-02-14 20:57:18 +0000
+++ b/mysql-test/suite/backup/t/backup_no_data.test	2008-10-09 09:55:08 +0000
@@ -1,6 +1,8 @@
 --source include/not_embedded.inc
 
 --disable_warnings
+--rmdir $MYSQLTEST_VARDIR/master-data/test
+--mkdir $MYSQLTEST_VARDIR/master-data/test
 DROP DATABASE IF EXISTS empty_db;
 DROP DATABASE IF EXISTS other_db;
 --enable_warnings

=== renamed file 'mysql-test/t/backup_no_engine.test' => 'mysql-test/suite/backup/t/backup_no_engine.test'
=== renamed file 'mysql-test/t/backup_nodata_driver.test' => 'mysql-test/suite/backup/t/backup_nodata_driver.test'
=== renamed file 'mysql-test/t/backup_objects.test' => 'mysql-test/suite/backup/t/backup_objects.test'
=== renamed file 'mysql-test/t/backup_procedures.test' => 'mysql-test/suite/backup/t/backup_procedures.test'
=== renamed file 'mysql-test/t/backup_securefilepriv-master.opt' => 'mysql-test/suite/backup/t/backup_securefilepriv-master.opt'
=== renamed file 'mysql-test/t/backup_securefilepriv.test' => 'mysql-test/suite/backup/t/backup_securefilepriv.test'
=== renamed file 'mysql-test/t/backup_security.test' => 'mysql-test/suite/backup/t/backup_security.test'
=== renamed file 'mysql-test/t/backup_snapshot.opt' => 'mysql-test/suite/backup/t/backup_snapshot.opt'
=== renamed file 'mysql-test/t/backup_snapshot.test' => 'mysql-test/suite/backup/t/backup_snapshot.test'
=== renamed file 'mysql-test/t/backup_tablespace.test' => 'mysql-test/suite/backup/t/backup_tablespace.test'
=== renamed file 'mysql-test/t/backup_timeout.test' => 'mysql-test/suite/backup/t/backup_timeout.test'
=== renamed file 'mysql-test/t/backup_triggers_and_events.test' => 'mysql-test/suite/backup/t/backup_triggers_and_events.test'
=== renamed file 'mysql-test/t/backup_view_on_view.test' => 'mysql-test/suite/backup/t/backup_view_on_view.test'
=== renamed file 'mysql-test/t/backup_views.test' => 'mysql-test/suite/backup/t/backup_views.test'
=== added file 'mysql-test/suite/backup/t/disabled.def'
--- a/mysql-test/suite/backup/t/disabled.def	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/disabled.def	2008-10-09 11:45:40 +0000
@@ -0,0 +1,16 @@
+##############################################################################
+#
+#  List the test cases that are to be disabled temporarily.
+#
+#  Separate the test case name and the comment with ':'.
+#
+#    <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
+#
+#  Do not use any TAB characters for whitespace.
+#
+##############################################################################
+backup_no_engine     : Bug#36021 2008-04-13 rsomla server crashes when openning table with unknown storage engine
+backup_triggers_and_events  : Bug#37762 2008-07-01 rafal Test fails on remove_file for unknown reasons
+backup_no_be                : Bug#38023 2008-07-16 rafal Test triggers valgrind warnings described in the bug
+backup_no_data       : Bug#17823 2008-10-09 rafal Tests in main suite leave undeleted files causing this test to fail
+backup_ddl_blocker   : Bug#17823 2008-10-09 rafal Tests in main suite leave undeleted files causing this test to fail

=== renamed directory 'mysql-test/suite/backup' => 'mysql-test/suite/backup_engines'
=== added file 'mysql-test/suite/backup_engines/include/backup_ptr.inc'
--- a/mysql-test/suite/backup_engines/include/backup_ptr.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/backup_ptr.inc	2008-10-08 04:26:25 +0000
@@ -0,0 +1,386 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserved during 
+# backup. In this test we perform both Data Manipulation Operations and 
+# Data Definition Operations. We recover the data after and before backup
+# using both binlog positions and binlog dates.
+###############################################################################
+
+
+--source include/not_embedded.inc
+--source include/have_log_bin.inc
+SELECT @@BINLOG_FORMAT;
+RESET MASTER;
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr.bak; 
+
+--echo **START TEST**
+--echo **** TEST1 ****
+--echo  This test will recover data using binlog position
+--echo  till point of backup and after backup.
+--echo
+
+#We set constant timestamp inside the test.
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+
+# Create database
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+--echo **** Creating tables ****
+CREATE TABLE ptr.t1(id INT, a CHAR(4));
+INSERT INTO ptr.t1 VALUES(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+SELECT * FROM ptr.t1;
+
+CREATE TABLE ptr.t3(id INT, b CHAR(4));
+INSERT INTO ptr.t3 VALUES
+(11,'aa'),(22,'bb'),(33,'cc'),(44,'dd'),(55,'ee');
+
+CREATE TABLE ptr.t2(id INT, deletes_data VARCHAR(30), updates_data TEXT);
+INSERT INTO ptr.t2 VALUES
+(100,'data1 for testing','update data1'),
+(200,'data2 for testing','update data2'),
+(300,'data3 for testing','update data3'),
+(400,'data4 for testing','update data4'),
+(500,'data5 for testing','update data5'),
+(100,'data1 for testing','update data1'),
+(600,'data6 for testing','update data6');
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT COUNT(*) FROM ptr.t2;
+
+--echo **** Creating tables with different datatypes ****
+
+CREATE TABLE ptr.d1(
+rint INT,
+tint TINYINT,
+sint SMALLINT,
+bint BIGINT,
+mint MEDIUMINT,
+name CHAR(100),
+city  VARCHAR(100),
+fl FLOAT(7,4),
+pers DECIMAL(8,2),
+sal DOUBLE,
+colours SET('red','blue','yellow'),
+continent ENUM('Asia', 'Europe','Africa','Antartica'),
+ts TIMESTAMP DEFAULT 0,
+dob DATE,
+y YEAR
+);
+
+CREATE TABLE ptr.d2(
+region TEXT,
+summary LONGTEXT,
+data BLOB,
+details MEDIUMBLOB,
+queries TINYTEXT,
+query2 TINYBLOB,
+extract LONGBLOB,
+paras MEDIUMTEXT
+);
+
+INSERT INTO ptr.d1 VALUES
+(785,127,7288,278829899,3777,'testing1','sweden','678.299',200.23,829899.909,
+'yellow','Asia','2008-06-01 16:23:30','1984-09-08','1984');
+
+INSERT INTO ptr.d2 VALUES
+('xxxxxxxx','Testofonline backup','aaaaaaaaaa','bbbbbbbbbbb','hhhhhhhhhhh',
+'kkkkkkkkkkkkk','mmmmmmmmmmmm','onlinebackup1');
+
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo **** Perform Data Manipulation Operations ****
+--echo ## Delete ##
+DELETE FROM ptr.t2 WHERE deletes_data='data4 for testing';
+DELETE FROM ptr.t2 WHERE id=100 LIMIT 1;
+
+--echo ## Insert and Select ##
+--echo **** Now ptr.t2 will have 5 counts in the table ****
+--echo 
+SELECT COUNT(*) FROM ptr.t2;
+INSERT INTO ptr.t2 VALUES
+(800,'data1 for replacement','replace data1');
+
+--echo ## Replace ##
+REPLACE INTO ptr.t2 
+SET id=800, deletes_data='data replaced', updates_data='replace over';
+
+--echo ## Union ##
+SELECT * FROM ptr.t1 UNION SELECT * FROM ptr.t3;
+
+--echo ## Update ##
+UPDATE ptr.t2 SET updates_data='##VALUE UPDATED##' WHERE id=300;
+
+--echo  Now table t2 will have 6 counts with one updated and replaced values 
+SELECT COUNT(*) FROM ptr.t2;
+SELECT * FROM ptr.t2 ORDER BY id;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.d1;
+DESCRIBE ptr.d2;
+
+#--echo ## Perform table maintenence operations ##
+#We disable the table maintenence operations as it is supported by only
+#Myisam and Innodb engines. Falcon engine does not support table maintenance
+#operations.
+ 
+#ANALYZE TABLE d1;
+#ANALYZE TABLE t2;
+#CHECK TABLE d1;
+#CHECK TABLE t2;
+
+--echo **** Perform Data Definition Operations ****
+
+--echo ## ALTER ##
+ALTER TABLE ptr.t2 ADD COLUMN changes CHAR(20);
+
+UPDATE ptr.t2 SET changes='altered' WHERE id=200;
+UPDATE ptr.t2 SET changes='altered' WHERE id=100;
+
+ALTER TABLE ptr.t3 MODIFY b VARCHAR(4);
+
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+--echo **** Now we will check the data contents in all the tables again ****
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo ** Perform Backup operation and gather binlog position and dates **
+--echo ** Backup data **
+LET $backup_id = `BACKUP DATABASE ptr TO 'ptr.bak'`;
+set timestamp=@a+2;
+LET $binlog_pos = `SELECT binlog_pos FROM mysql.backup_history WHERE backup_id =$backup_id`;
+LET $binlog_file =query_get_value(SHOW MASTER STATUS, File, 1);
+
+--echo
+--echo Now execute some operations in the table after performing backup.
+--echo
+
+--echo
+--echo **** Perform some data manipulation operations ****
+
+INSERT INTO ptr.t1 VALUES(6,'f'),(7,'g');
+INSERT INTO ptr.d1 VALUES
+(10001,120,6550,7278634657,90667,'After backup','Minneapolis',782.9901,
+789.23,97806.456,'blue','Antartica','2008-08-07 15:12:44','1954-12-23','1954');
+
+INSERT INTO ptr.t3 VALUES(1,'ff'),(3,'kk');
+SELECT * FROM t1 UNION SELECT * FROM t3 ORDER BY a;
+
+UPDATE ptr.t3 SET b='mm' where b='kk';
+SELECT * FROM ptr.t3;
+
+DELETE FROM ptr.t2 WHERE id=200;
+SELECT * FROM ptr.t2 ORDER BY id;
+
+--echo
+--echo **** Perform some data definition operations ****
+
+ALTER TABLE ptr.t2 DROP COLUMN changes;
+ALTER TABLE ptr.t3 ENGINE=MEMORY;
+CREATE TABLE definition(details LONGTEXT);
+INSERT INTO definition VALUES
+('Performing some data definition statements for PTR');
+
+DESCRIBE ptr.t2;
+DESCRIBE ptr.definition;
+
+--echo
+--echo **** The tables t1, t2, t3 and t4 has changes ****
+--echo **** New table "definition" is created after backup *****
+--echo
+
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+SET TIMESTAMP=@a+4;
+LET $binpos=query_get_value(SHOW MASTER STATUS, Position, 1);
+LET $binfile=query_get_value(SHOW MASTER STATUS, File, 1);
+
+# Rotate logs. This frees the previous log so that we can dump it.
+FLUSH LOGS;
+DROP DATABASE ptr;
+
+--echo **** Execute mysqlbinlog to recover the data from start to backup ****
+
+--exec $MYSQL_BINLOG --database=ptr $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/q1.bin
+--exec $MYSQL_BINLOG --database=ptr --stop-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+# Verify that the table we just dropped has been restored
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo **** Now perform another recovery to recover data after backup ****
+--exec $MYSQL_BINLOG --database=ptr --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+DROP DATABASE ptr;
+
+--echo *** TEST2 *** :
+--echo Perform Restore and recover transactions after backup by executing 
+--echo mysqlbinlog utility using binlog position.
+
+--echo Perform restore operation 
+--replace_column 1 #
+RESTORE FROM 'ptr.bak';
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo Recovering data contents after backup
+--exec $MYSQL_BINLOG --database=ptr --start-position=$binlog_pos  $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+DROP DATABASE ptr;
+
+--echo *** TEST3 *** :
+--echo This test will recover data using binlog dates
+--echo till point of backup and after backup.
+
+--echo  Now use binlog dates to recover the data till point of backup.
+
+--exec $MYSQL_BINLOG --database=ptr --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--echo We execute binlog to recover data after backup using binlog dates.
+
+--exec $MYSQL_BINLOG --database=ptr --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+DROP DATABASE ptr;
+
+--echo *** TEST4 *** :
+--echo Perform Restore and recover transactions after backup by executing
+--echo mysqlbinlog utility using binlog dates.
+
+--replace_column 1 #
+RESTORE FROM 'ptr.bak';
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+--exec $MYSQL_BINLOG --database=ptr --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+SHOW DATABASES;
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+DROP DATABASE ptr;
+
+--echo *** TEST5 *** :
+--echo Do complete recovery of data after backup using binlog position. Ensure 
+--echo that presence of backup operation in the binlog shouldn't have any impact
+
+--exec $MYSQL_BINLOG --database=ptr  --stop-position=$binpos $MYSQLTEST_VARDIR/log/$binfile |$MYSQL
+
+SHOW DATABASES;
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+DROP DATABASE ptr;
+
+--echo *** TEST6 *** :
+--echo Do complete recovery of data after backup using binlog dates. Ensure
+--echo that presence of backup operation in the binlog shouldn't have any impact
+
+--exec $MYSQL_BINLOG --database=ptr --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+SHOW DATABASES;
+SHOW TABLES FROM ptr;
+
+DESCRIBE ptr.t1;
+DESCRIBE ptr.t2;
+DESCRIBE ptr.t3;
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2 ORDER BY id;
+SELECT * FROM ptr.t3;
+SELECT * FROM ptr.d1;
+SELECT * FROM ptr.d2;
+
+# Test cleanup section
+
+--echo
+--echo ***  DROP ptr DATABASE ****
+--echo
+
+DROP DATABASE ptr;
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr.bak

=== added file 'mysql-test/suite/backup_engines/include/backup_ptr_commit.inc'
--- a/mysql-test/suite/backup_engines/include/backup_ptr_commit.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/backup_ptr_commit.inc	2008-10-08 04:26:25 +0000
@@ -0,0 +1,226 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery includes committed 
+# transactions in the backup. In this test we will commit the data during 
+# backup. This can be accomplished by using debug_sync points.
+###############################################################################
+
+
+--source include/have_debug_sync.inc
+--source include/have_innodb.inc
+--source include/not_embedded.inc
+--source include/have_log_bin.inc
+SELECT @@BINLOG_FORMAT;
+RESET MASTER;
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr_objects.bak;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connect (con3,localhost,root,,);
+
+connection con1;
+
+--echo **START TEST**
+--echo *** TEST1 ***
+--echo This test will recover data that were committed during backup
+--echo operation. This is acheived by means of debug_sync points
+--echo which pauses the backup database operation during commit.
+--echo
+
+#We set constant timestamp inside the test.
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+
+--disable_warnings
+SET DEBUG_SYNC= 'RESET';
+
+# Create database
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+--echo
+--echo con1: ***Creating Tables***
+
+CREATE TABLE ptr.t1(id INT, details CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t1 VALUES
+(1,'testing1'),(2,'testing2'),(3,'testing3'),
+(4,'testing4'),(5,'testing5'),(6,'testing6');
+
+CREATE TABLE ptr.t2(id INT, info CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t2 VALUES(201, 'aa1'),(202,'aa2');
+
+CREATE TABLE ptr.t3(id INT, name CHAR(20))ENGINE=INNODB;
+INSERT intO ptr.t3 VALUES(1,'ab1'),(2,'ab2'),(3,'ab3'),(4,'ab4'),(5,'ab5');
+
+--echo
+--echo con2:
+connection con2;
+START TRANSACTION;
+INSERT intO ptr.t2 VALUES(203, 'During backup-1'),(204,'During backup-2');
+UPDATE ptr.t3 SET name='hh1' WHERE id=1;
+DELETE FROM ptr.t1 WHERE id=5;
+DELETE FROM ptr.t1 WHERE id=6;
+
+--echo con1:
+connection con1;
+--echo The values should be: t1=6 t2=2 t3=5
+
+SELECT * FROM ptr.t1;
+SELECT COUNT(*) FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT COUNT(*) FROM ptr.t2;
+SELECT * FROM ptr.t3;
+SELECT COUNT(*) FROM ptr.t3;
+
+# Activate the sync point for BACKUP.
+# When BACKUP reaches the sync point it emits the signal bup_sync
+# and waits for another thread to emit the signal bup_finish.
+SET DEBUG_SYNC= 'before_backup_data_init SIGNAL bup_sync
+                 WAIT_FOR bup_finish';
+send BACKUP DATABASE ptr TO 'ptr_commit.bak';
+
+--echo
+--echo con3: Waiting for BACKUP to reach the breakpoint
+connection con3;
+# If BACKUP did already reach its sync point, then the signal is already
+# present. If not, we wait until BACKUP emits it.
+SET DEBUG_SYNC= 'now WAIT_FOR bup_sync';
+
+--echo con2:
+connection con2;
+COMMIT;
+
+--echo
+--echo con3: Signalling that BACKUP can finish
+connection con3;
+SET DEBUG_SYNC= 'now SIGNAL bup_finish';
+
+--echo con1:
+connection con1;
+--echo con1: Fetching result of BACKUP
+--replace_column 1 #
+reap;
+set timestamp=@a+2;
+
+--echo con2:
+connection con2;
+--echo After commit the values of will be: t1=4, t2=4, t3=5
+SELECT COUNT(*) FROM ptr.t1;
+SELECT * FROM ptr.t1;
+SELECT COUNT(*) FROM ptr.t2;
+SELECT * FROM ptr.t2;
+SELECT COUNT(*) FROM ptr.t3;
+SELECT * FROM ptr.t3;
+
+LET $binlog_file =query_get_value(SHOW MASTER STATUS, File, 1);
+LET $binlog_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
+
+--echo con1:
+connection con1;
+--echo **** Perform some operations after backup ****
+INSERT intO ptr.t1 VALUES(10,'After Backup1'),(20,'After Backup2');
+UPDATE ptr.t2 SET info='After Backup-1' WHERE id=202;
+UPDATE ptr.t3 SET name='After Backup-1' WHERE id=2;
+set timestamp=@a+4;
+FLUSH LOGS;
+
+--echo Values in table after backup: t1=6,t2=4(202 updated), t3=5(2 updated)
+SELECT COUNT(*) FROM ptr.t1;
+SELECT * FROM ptr.t1;
+SELECT COUNT(*) FROM ptr.t2;
+SELECT * FROM ptr.t2;
+SELECT COUNT(*) FROM ptr.t3;
+SELECT * FROM ptr.t3;
+
+DROP DATABASE ptr;
+
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/qcommit.bin
+--exec $MYSQL_BINLOG --stop-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+--echo *** Recovering data till point of backup using mysql binlog_position ***
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--echo *** Recover data after backup ***
+--exec $MYSQL_BINLOG --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+DROP DATABASE ptr;
+
+--echo *** TEST2 ***
+--echo Perform Restore and Recover committed data using mysqlbinlog position
+--echo after backup.
+--echo
+
+--echo Perform restore operation
+--replace_column 1 #
+RESTORE FROM 'ptr_commit.bak';
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--exec $MYSQL_BINLOG --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+--echo *** Recover data using binlog position after backup ***
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+DROP DATABASE ptr;
+
+--echo *** TEST3 ***
+--echo Recover committed data during backup and after backup operation
+--echo using mysqlbinlog dates
+--echo 
+
+--echo use binlog dates to recover data till backup.
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--echo use binlog dates to recover data after backup.
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+--echo *** Now recover data after backup using binlog dates ***
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--echo *** TEST4 *** 
+--echo Perform Restore and Recover committed data using mysqlbinlog position
+--echo after backup.
+
+--echo Perform restore operation
+--replace_column 1 #
+RESTORE FROM 'ptr_commit.bak';
+SHOW TABLES FROM ptr;
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+--echo *** Now recover data after backup using binlog dates ***
+
+SELECT * FROM ptr.t1;
+SELECT * FROM ptr.t2;
+SELECT * FROM ptr.t3;
+
+# Test cleanup section
+
+--echo
+--echo ***  DROP ptr DATABASE ****
+--echo
+
+DROP DATABASE ptr;
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr_commit.bak
+SET DEBUG_SYNC= 'RESET';

=== added file 'mysql-test/suite/backup_engines/include/backup_ptr_objects.inc'
--- a/mysql-test/suite/backup_engines/include/backup_ptr_objects.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/backup_ptr_objects.inc	2008-10-08 04:26:25 +0000
@@ -0,0 +1,630 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery preserves all the      
+# objects during backup. We include objects like tables, views, triggers,
+# stored procedures and stored functions. This test also verifies the
+# dependencies in objects are recovered properly using mysql binlog position
+# binlog dates.
+###############################################################################
+
+--source include/not_embedded.inc
+--source include/have_log_bin.inc
+SELECT @@BINLOG_FORMAT;
+RESET MASTER;
+
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr_objects.bak;
+
+--echo **START TEST**
+--echo *** TEST1 ***
+--echo This test will recover data and objects using binlog position
+--echo till point of backup and after backup.
+--echo
+
+#We set constant timestamp inside the test.
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+
+#
+# Two databases are created ptr_ob1 and ptr_ob2.
+# ptr_ob1 has tables t1, t2, t3, tv1 and views v ,v1, vv.
+# v --> ptr_ob1.t1, v1 --> ptr_ob2.t1, vv --> ptr_ob2.v1
+# ptr_ob2 has tables t1, t2 and views v1.
+# v1 --> ptr_ob1.tv1 + ptr_ob2.t2
+# trg1(before insert), trg2(after insert), trg4(after delete) and 
+# trg5(before update) are in ptr_ob1.
+# trg3(before delete) and trg6(after update) are in ptr_ob2.
+# procedure p1, p2 and p3 are created in ptr_ob1 and p4 in ptr_ob2.
+#
+
+# Create database
+CREATE DATABASE IF NOT EXISTS ptr_ob1;
+CREATE DATABASE IF NOT EXISTS ptr_ob2;
+USE ptr_ob1;
+
+--echo **** Creating tables ****
+
+CREATE TABLE ptr_ob1.t1(
+ id INT, 
+ a INT, 
+ b CHAR(5)
+);
+
+CREATE TABLE ptr_ob1.t2(
+  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+  data CHAR(50)
+);
+
+CREATE TABLE ptr_ob1.t3(
+ srno INT AUTO_INCREMENT, 
+ PRIMARY KEY(srno), 
+ name VARCHAR(30) NOT NULL, 
+ old_a INT
+); 
+
+CREATE TABLE ptr_ob2.t1(
+ id INT, 
+ b CHAR(5)
+);
+
+CREATE TABLE ptr_ob2.t2(id SMALLINT);
+
+INSERT INTO ptr_ob2.t1 VALUES(11,'set1'),(21,'set2'),(3,'set3'),(4,'set4');
+INSERT INTO ptr_ob2.t2 VALUES(91),(5),(26),(33),(5);
+
+--echo **** Creating views ****
+
+CREATE VIEW ptr_ob1.v AS SELECT * FROM ptr_ob1.t1;
+CREATE VIEW ptr_ob1.v1 AS SELECT * FROM ptr_ob2.t1;
+
+CREATE TABLE ptr_ob1.tv1(id SMALLINT);
+INSERT INTO ptr_ob1.tv1  VALUES(1),(2),(3),(3),(5);
+SELECT * FROM ptr_ob1.tv1 UNION ALL SELECT * FROM ptr_ob2.t2;
+CREATE VIEW ptr_ob2.v1 AS SELECT * FROM ptr_ob1.tv1  UNION ALL 
+SELECT * FROM ptr_ob2.t2 ORDER BY id;
+SELECT * FROM ptr_ob2.v1;
+
+--echo #### Creating view from another view ####
+CREATE VIEW ptr_ob1.vv AS SELECT SUM(id) from ptr_ob2.v1 GROUP BY id;
+SELECT * FROM ptr_ob1.vv;
+
+--echo **** Creating Triggers ****
+
+delimiter ||;
+CREATE TRIGGER ptr_ob1.trg1 BEFORE INSERT ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+ INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END;||
+delimiter ;||
+
+INSERT INTO ptr_ob1.t1 VALUES(1,20, 'bb1'), (2,50, 'bb2'),(3,80,'bb3');
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.t3;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT ON ptr_ob1.t2 FOR EACH ROW
+BEGIN
+ INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END;||
+delimiter ;||
+
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL, 'Normal Insert1'),(NULL, 'Normal Insert2'),
+(NULL, 'Normal Insert3'),(NULL, 'Normal Insert4');
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob2.trg3 BEFORE DELETE ON ptr_ob2.t2 FOR EACH ROW
+ SET @del_sum:= @del_sum + old.id;||
+ SET @del_sum:= 0;||
+delimiter ;||
+
+DELETE FROM ptr_ob2.t2 WHERE id=26;
+DELETE FROM ptr_ob2.t2 WHERE id=91;
+SELECT @del_sum;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob1.trg4 AFTER DELETE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN 
+ INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END;||
+delimiter ;||
+
+DELETE FROM ptr_ob1.t1 WHERE id=2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob2.t1;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob1.trg5 BEFORE UPDATE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+ SET @id=old.id;
+ SET @a_old=old.a;
+ SET @a_new=new.a;
+END;
+||
+delimiter ;||
+
+UPDATE ptr_ob1.t1 SET a='85' WHERE b='bb3';
+SELECT @id, @a_old, @a_new;
+
+delimiter ||;
+CREATE TRIGGER ptr_ob2.trg6 AFTER UPDATE ON ptr_ob2.t1 FOR EACH ROW
+BEGIN
+ INSERT INTO ptr_ob1.t2 VALUES
+ (NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END;
+||
+delimiter ;||
+
+UPDATE ptr_ob2.t1 SET b='alert' WHERE id=3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.v1;
+
+--echo
+--echo **** Creating stored Procedures and functions ****
+--echo
+
+--echo #### The procedure p1 will insert VALUES in view ####
+delimiter ||;
+CREATE PROCEDURE ptr_ob1.p1(details CHAR(40), id INT)
+BEGIN
+  INSERT INTO ptr_ob1.v1 VALUES(1,'fired');
+END;
+||
+
+--echo #### Procedure p2 will trigger trg2 ####
+
+CREATE PROCEDURE ptr_ob1.p2(content VARCHAR(40))
+BEGIN
+ INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Trigger fired from procedure p2');
+END;||
+
+--echo #### Procedure p3 will trigger trg6 ####
+
+CREATE PROCEDURE ptr_ob1.p3(info TEXT)
+BEGIN
+ UPDATE ptr_ob2.t1 SET b='#up#' WHERE id=4;
+END;||
+
+--echo #### Procedure p4 will call view ####
+
+CREATE PROCEDURE ptr_ob2.p4() 
+BEGIN
+ SELECT * FROM ptr_ob2.v1;
+END;
+||
+
+--echo #### Function f1() ####
+
+CREATE FUNCTION f1() RETURNS INT
+RETURN (SELECT COUNT(*) FROM ptr_ob1.v1);||
+DELIMITER ;||
+
+SELECT f1();
+
+CALL ptr_ob1.p1('procedure p1 called for view v1', 1);
+CALL ptr_ob1.p1('procedure p1 called for view v1', 2);
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob2.t1;
+
+CALL ptr_ob1.p2('procedure p2 called for trg2');
+CALL ptr_ob1.p2('procedure p2 again called for trg2');
+
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+
+CALL ptr_ob1.p3('procedure p3 called for trg6');
+
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.t2;
+
+CALL ptr_ob2.p4();
+
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT * FROM ptr_ob1.tv1;
+
+--echo ** Checking data contents in all the tables before performing backup **
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+# Perform  backup operation and obtain binlog position and dates.
+LET $backup_id = `BACKUP DATABASE ptr_ob1, ptr_ob2 TO 'ptr_objects.bak'`;
+set timestamp=@a+2;
+LET $binlog_pos = `SELECT binlog_pos FROM mysql.backup_history WHERE backup_id =$backup_id`;
+LET $binlog_file =query_get_value(SHOW MASTER STATUS, File, 1);
+
+--echo Make some changes to objects.
+
+ALTER VIEW ptr_ob1.v AS SELECT id, a FROM ptr_ob1.t1;
+ALTER TABLE ptr_ob1.vv RENAME TO ptr_ob1.vva;
+ALTER TABLE ptr_ob2.t2 ADD COLUMN af_backup VARCHAR(30);
+ALTER TABLE ptr_ob1.t3 CHANGE name name TEXT;
+DESCRIBE ptr_ob1.t3;
+ALTER PROCEDURE ptr_ob2.p4 COMMENT 'AFTER BACKUP';
+SELECT * FROM ptr_ob1.v;
+
+--echo Creating some new objects
+
+CREATE TABLE ptr_ob1.t11 (i INT, sr INT, j INT) engine=myisam;
+INSERT INTO ptr_ob1.t11 VALUES (1, 2, 3);
+CREATE TRIGGER ptr_ob1.ai AFTER INSERT ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.au AFTER UPDATE ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.ad AFTER DELETE ON ptr_ob1.t11 FOR EACH ROW SET @a:= old.sr;
+
+INSERT INTO ptr_ob1.t11 VALUES(4, 5, 6),(7, 8, 9);
+SELECT @a;
+UPDATE ptr_ob1.t11 SET i=10 WHERE sr=5;
+SELECT @a;
+DELETE FROM ptr_ob1.t11 WHERE sr=8;
+SELECT @a;
+
+--echo Now alter the table 
+
+ALTER TABLE ptr_ob1.t11 DROP COLUMN j;
+SELECT * FROM ptr_ob1.t11;
+INSERT INTO ptr_ob1.t11 VALUES(11, 12);
+SELECT @a;
+
+--echo Firing existing triggers and calling procedures.
+
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Insert after backup');
+INSERT INTO ptr_ob2.t2 VALUES(10, 'af_bk1'),(2, 'af_bk2'),(7,'af_bk3'),(2,'af_bk4');
+DELETE FROM ptr_ob2.t2 WHERE id=10;
+SELECT @del_sum;
+
+CALL ptr_ob1.p1('procedure p1 af_bkup for view v1', 3);
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob2.t1;
+
+CALL ptr_ob1.p2('procedure p2 called  af_bkup for trg2');
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+
+CALL ptr_ob1.p3('procedure p3 called af_bkup for trg6');
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.t2;
+
+CALL ptr_ob2.p4();
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.tv1;
+
+# Changes made after backup are:
+# ptr_ob1.v is altered, ptr_ob1.vv is renamed as vva.
+# ptr_ob2.t2 has new column added, ptr_ob1.t3 has datatype change.
+# Table ptr_ob1.t11 is created and triggers ptr_ob1.ai, au, ad is created.
+# procedure ptr_ob2.p4 is altered.
+
+--echo Checking the data contents after backup.
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+SET TIMESTAMP=@a+4;
+LET $binpos=query_get_value(SHOW MASTER STATUS, Position, 1);
+LET $binfile=query_get_value(SHOW MASTER STATUS, File, 1);
+
+# Rotate logs. This frees the previous log so that we can dump it.
+FLUSH LOGS;
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo **** Execute mysqlbinlog to recover the data from start to backup ****
+
+--exec $MYSQL_BINLOG  $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/qobject.bin
+--exec $MYSQL_BINLOG  --stop-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+# Verify that the table we just dropped has been restored
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+--echo **** Now perform another recovery to recover data after backup ****
+
+--exec $MYSQL_BINLOG --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST2 *** :
+--echo Perform Restore and recover transactions after backup by executing 
+--echo mysqlbinlog utility using binlog position.
+--echo
+
+--echo Perfrom Restore operation
+--replace_column 1 #
+RESTORE FROM 'ptr_objects.bak';
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+--echo Now use binlog position to recover data after backup
+--exec $MYSQL_BINLOG --start-position=$binlog_pos $MYSQLTEST_VARDIR/log/$binlog_file |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST3 *** :
+--echo This test will recover data and objects using binlog dates
+--echo till point of backup and after backup.
+--echo
+
+--echo Use mysqlbinlog dates to recover data till point of backup.
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+--echo Use mysqlbinlog dates to recover data after backup 
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST4 *** :
+--echo Perform Restore and recover objects after backup by executing mysqlbinlog
+--echo utility using binlog dates.
+--echo
+
+--echo Perform Restore operation
+--replace_column 1 #
+RESTORE FROM 'ptr_objects.bak';
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vv;
+SELECT ptr_ob1.f1();
+
+--echo use binlog dates to recover data after backup.
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:24" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST5 *** :
+--echo Do complete recovery of data after backup using binlog position. Ensure
+--echo that presence of backup operation in the binlog shouldn't have any impact
+
+--exec $MYSQL_BINLOG  --stop-position=$binpos $MYSQLTEST_VARDIR/log/$binfile |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+
+--echo *** TEST6 *** :
+--echo Do complete recovery of data after backup using binlog dates. Ensure
+--echo that presence of backup operation in the binlog shouldn't have any impact
+
+--exec $MYSQL_BINLOG --start-datetime="2010-01-21 15:32:22" --stop-datetime="2010-01-21 15:32:26" $MYSQLTEST_VARDIR/log/master-bin.000001 |$MYSQL
+
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW PROCEDURE STATUS;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob1;
+--replace_column 5 # 6 # 9 # 10 # 11 #
+SHOW TRIGGERS FROM ptr_ob2;
+SHOW FULL TABLES FROM ptr_ob1;
+SHOW FULL TABLES FROM ptr_ob2;
+SELECT * FROM ptr_ob1.t1;
+SELECT * FROM ptr_ob1.v;
+SELECT * FROM ptr_ob1.t2;
+SELECT * FROM ptr_ob1.t3;
+SELECT * FROM ptr_ob2.t1;
+SELECT * FROM ptr_ob1.v1;
+SELECT * FROM ptr_ob1.tv1;
+SELECT * FROM ptr_ob2.v1;
+SELECT * FROM ptr_ob1.vva;
+SELECT * FROM ptr_ob1.t11;
+SELECT ptr_ob1.f1();
+
+# Test cleanup section
+
+--echo
+--echo ***  DROP ptr_ob1 and ptr_ob2 DATABASE ****
+--echo
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+--remove_file $MYSQLTEST_VARDIR/master-data/ptr_objects.bak
+
+
+

=== added file 'mysql-test/suite/backup_engines/include/not_have_falcon.inc'
--- a/mysql-test/suite/backup_engines/include/not_have_falcon.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/not_have_falcon.inc	2008-10-08 04:26:25 +0000
@@ -0,0 +1,9 @@
+# We will disable Falcon storage engine if we include not_have_falcon.inc
+# in our test case.
+
+--replace_result $ENGINE ENGINE
+if(`SELECT '$ENGINE'='falcon'`)
+{
+ skip "This test does not support Falcon engine";
+}
+

=== added file 'mysql-test/suite/backup_engines/include/not_have_innodb.inc'
--- a/mysql-test/suite/backup_engines/include/not_have_innodb.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/not_have_innodb.inc	2008-10-08 04:26:25 +0000
@@ -0,0 +1,10 @@
+# We will disable Innodb storage engine if we include not_have_innodb.inc
+# in our test case.
+
+
+--replace_result $ENGINE ENGINE
+if(`SELECT '$ENGINE'='innodb'`)
+{
+ skip "This test does not support Innodb engine";
+}
+

=== added file 'mysql-test/suite/backup_engines/include/not_have_memory.inc'
--- a/mysql-test/suite/backup_engines/include/not_have_memory.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/not_have_memory.inc	2008-10-08 04:26:25 +0000
@@ -0,0 +1,10 @@
+# We will disable Memory storage engine if we include not_have_memory.inc
+# in our test case.
+
+
+--replace_result $ENGINE ENGINE
+if(`SELECT '$ENGINE'='memory'`)
+{
+ skip "This test does not support memory engine";
+}
+

=== added file 'mysql-test/suite/backup_engines/include/not_have_myisam.inc'
--- a/mysql-test/suite/backup_engines/include/not_have_myisam.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/include/not_have_myisam.inc	2008-10-08 04:26:25 +0000
@@ -0,0 +1,10 @@
+# We will disable Myisam storage engine if we include not_have_myisam.inc
+# in our test case.
+
+
+--replace_result $ENGINE ENGINE
+if(`SELECT '$ENGINE'='myisam'`)
+{
+ skip "This test does not support Myisam engine";
+}
+

=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result	2008-10-08 04:26:25 +0000
@@ -0,0 +1,360 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name	Value
+storage_engine	#
+SET GLOBAL BINLOG_FORMAT='MIXED';
+SET BINLOG_FORMAT='MIXED';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+MIXED
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data that were committed during backup
+operation. This is acheived by means of debug_sync points
+which pauses the backup database operation during commit.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+SET DEBUG_SYNC= 'RESET';
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+con1: ***Creating Tables***
+CREATE TABLE ptr.t1(id INT, details CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t1 VALUES
+(1,'testing1'),(2,'testing2'),(3,'testing3'),
+(4,'testing4'),(5,'testing5'),(6,'testing6');
+CREATE TABLE ptr.t2(id INT, info CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t2 VALUES(201, 'aa1'),(202,'aa2');
+CREATE TABLE ptr.t3(id INT, name CHAR(20))ENGINE=INNODB;
+INSERT intO ptr.t3 VALUES(1,'ab1'),(2,'ab2'),(3,'ab3'),(4,'ab4'),(5,'ab5');
+
+con2:
+START TRANSACTION;
+INSERT intO ptr.t2 VALUES(203, 'During backup-1'),(204,'During backup-2');
+UPDATE ptr.t3 SET name='hh1' WHERE id=1;
+DELETE FROM ptr.t1 WHERE id=5;
+DELETE FROM ptr.t1 WHERE id=6;
+con1:
+The values should be: t1=6 t2=2 t3=5
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+5	testing5
+6	testing6
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+2
+SELECT * FROM ptr.t3;
+id	name
+1	ab1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SET DEBUG_SYNC= 'before_backup_data_init SIGNAL bup_sync
+                 WAIT_FOR bup_finish';
+BACKUP DATABASE ptr TO 'ptr_commit.bak';
+
+con3: Waiting for BACKUP to reach the breakpoint
+SET DEBUG_SYNC= 'now WAIT_FOR bup_sync';
+con2:
+COMMIT;
+
+con3: Signalling that BACKUP can finish
+SET DEBUG_SYNC= 'now SIGNAL bup_finish';
+con1:
+con1: Fetching result of BACKUP
+backup_id
+#
+set timestamp=@a+2;
+con2:
+After commit the values of will be: t1=4, t2=4, t3=5
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+4
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+con1:
+**** Perform some operations after backup ****
+INSERT intO ptr.t1 VALUES(10,'After Backup1'),(20,'After Backup2');
+UPDATE ptr.t2 SET info='After Backup-1' WHERE id=202;
+UPDATE ptr.t3 SET name='After Backup-1' WHERE id=2;
+set timestamp=@a+4;
+FLUSH LOGS;
+Values in table after backup: t1=6,t2=4(202 updated), t3=5(2 updated)
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+DROP DATABASE ptr;
+*** Recovering data till point of backup using mysql binlog_position ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+*** Recover data after backup ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+DROP DATABASE ptr;
+*** TEST2 ***
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+*** Recover data using binlog position after backup ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+DROP DATABASE ptr;
+*** TEST3 ***
+Recover committed data during backup and after backup operation
+using mysqlbinlog dates
+
+use binlog dates to recover data till backup.
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+use binlog dates to recover data after backup.
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+*** TEST4 *** 
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+
+***  DROP ptr DATABASE ****
+
+DROP DATABASE ptr;
+SET DEBUG_SYNC= 'RESET';

=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result	2008-10-08 04:26:25 +0000
@@ -0,0 +1,360 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name	Value
+storage_engine	#
+SET GLOBAL BINLOG_FORMAT='ROW';
+SET BINLOG_FORMAT='ROW';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+ROW
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data that were committed during backup
+operation. This is acheived by means of debug_sync points
+which pauses the backup database operation during commit.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+SET DEBUG_SYNC= 'RESET';
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+con1: ***Creating Tables***
+CREATE TABLE ptr.t1(id INT, details CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t1 VALUES
+(1,'testing1'),(2,'testing2'),(3,'testing3'),
+(4,'testing4'),(5,'testing5'),(6,'testing6');
+CREATE TABLE ptr.t2(id INT, info CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t2 VALUES(201, 'aa1'),(202,'aa2');
+CREATE TABLE ptr.t3(id INT, name CHAR(20))ENGINE=INNODB;
+INSERT intO ptr.t3 VALUES(1,'ab1'),(2,'ab2'),(3,'ab3'),(4,'ab4'),(5,'ab5');
+
+con2:
+START TRANSACTION;
+INSERT intO ptr.t2 VALUES(203, 'During backup-1'),(204,'During backup-2');
+UPDATE ptr.t3 SET name='hh1' WHERE id=1;
+DELETE FROM ptr.t1 WHERE id=5;
+DELETE FROM ptr.t1 WHERE id=6;
+con1:
+The values should be: t1=6 t2=2 t3=5
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+5	testing5
+6	testing6
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+2
+SELECT * FROM ptr.t3;
+id	name
+1	ab1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SET DEBUG_SYNC= 'before_backup_data_init SIGNAL bup_sync
+                 WAIT_FOR bup_finish';
+BACKUP DATABASE ptr TO 'ptr_commit.bak';
+
+con3: Waiting for BACKUP to reach the breakpoint
+SET DEBUG_SYNC= 'now WAIT_FOR bup_sync';
+con2:
+COMMIT;
+
+con3: Signalling that BACKUP can finish
+SET DEBUG_SYNC= 'now SIGNAL bup_finish';
+con1:
+con1: Fetching result of BACKUP
+backup_id
+#
+set timestamp=@a+2;
+con2:
+After commit the values of will be: t1=4, t2=4, t3=5
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+4
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+con1:
+**** Perform some operations after backup ****
+INSERT intO ptr.t1 VALUES(10,'After Backup1'),(20,'After Backup2');
+UPDATE ptr.t2 SET info='After Backup-1' WHERE id=202;
+UPDATE ptr.t3 SET name='After Backup-1' WHERE id=2;
+set timestamp=@a+4;
+FLUSH LOGS;
+Values in table after backup: t1=6,t2=4(202 updated), t3=5(2 updated)
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+DROP DATABASE ptr;
+*** Recovering data till point of backup using mysql binlog_position ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+*** Recover data after backup ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+DROP DATABASE ptr;
+*** TEST2 ***
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+*** Recover data using binlog position after backup ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+DROP DATABASE ptr;
+*** TEST3 ***
+Recover committed data during backup and after backup operation
+using mysqlbinlog dates
+
+use binlog dates to recover data till backup.
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+use binlog dates to recover data after backup.
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+*** TEST4 *** 
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+
+***  DROP ptr DATABASE ****
+
+DROP DATABASE ptr;
+SET DEBUG_SYNC= 'RESET';

=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result	2008-10-08 04:26:25 +0000
@@ -0,0 +1,360 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name	Value
+storage_engine	#
+SET GLOBAL BINLOG_FORMAT='STATEMENT';
+SET BINLOG_FORMAT='STATEMENT';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+STATEMENT
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data that were committed during backup
+operation. This is acheived by means of debug_sync points
+which pauses the backup database operation during commit.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+SET DEBUG_SYNC= 'RESET';
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+
+con1: ***Creating Tables***
+CREATE TABLE ptr.t1(id INT, details CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t1 VALUES
+(1,'testing1'),(2,'testing2'),(3,'testing3'),
+(4,'testing4'),(5,'testing5'),(6,'testing6');
+CREATE TABLE ptr.t2(id INT, info CHAR(30))ENGINE=INNODB;
+INSERT intO ptr.t2 VALUES(201, 'aa1'),(202,'aa2');
+CREATE TABLE ptr.t3(id INT, name CHAR(20))ENGINE=INNODB;
+INSERT intO ptr.t3 VALUES(1,'ab1'),(2,'ab2'),(3,'ab3'),(4,'ab4'),(5,'ab5');
+
+con2:
+START TRANSACTION;
+INSERT intO ptr.t2 VALUES(203, 'During backup-1'),(204,'During backup-2');
+UPDATE ptr.t3 SET name='hh1' WHERE id=1;
+DELETE FROM ptr.t1 WHERE id=5;
+DELETE FROM ptr.t1 WHERE id=6;
+con1:
+The values should be: t1=6 t2=2 t3=5
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+5	testing5
+6	testing6
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+2
+SELECT * FROM ptr.t3;
+id	name
+1	ab1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SET DEBUG_SYNC= 'before_backup_data_init SIGNAL bup_sync
+                 WAIT_FOR bup_finish';
+BACKUP DATABASE ptr TO 'ptr_commit.bak';
+
+con3: Waiting for BACKUP to reach the breakpoint
+SET DEBUG_SYNC= 'now WAIT_FOR bup_sync';
+con2:
+COMMIT;
+
+con3: Signalling that BACKUP can finish
+SET DEBUG_SYNC= 'now SIGNAL bup_finish';
+con1:
+con1: Fetching result of BACKUP
+backup_id
+#
+set timestamp=@a+2;
+con2:
+After commit the values of will be: t1=4, t2=4, t3=5
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+4
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+con1:
+**** Perform some operations after backup ****
+INSERT intO ptr.t1 VALUES(10,'After Backup1'),(20,'After Backup2');
+UPDATE ptr.t2 SET info='After Backup-1' WHERE id=202;
+UPDATE ptr.t3 SET name='After Backup-1' WHERE id=2;
+set timestamp=@a+4;
+FLUSH LOGS;
+Values in table after backup: t1=6,t2=4(202 updated), t3=5(2 updated)
+SELECT COUNT(*) FROM ptr.t1;
+COUNT(*)
+6
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT COUNT(*) FROM ptr.t3;
+COUNT(*)
+5
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+DROP DATABASE ptr;
+*** Recovering data till point of backup using mysql binlog_position ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+*** Recover data after backup ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+DROP DATABASE ptr;
+*** TEST2 ***
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+*** Recover data using binlog position after backup ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+DROP DATABASE ptr;
+*** TEST3 ***
+Recover committed data during backup and after backup operation
+using mysqlbinlog dates
+
+use binlog dates to recover data till backup.
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+use binlog dates to recover data after backup.
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+*** TEST4 *** 
+Perform Restore and Recover committed data using mysqlbinlog position
+after backup.
+Perform restore operation
+RESTORE FROM 'ptr_commit.bak';
+backup_id
+#
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	aa2
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	ab2
+3	ab3
+4	ab4
+5	ab5
+*** Now recover data after backup using binlog dates ***
+SELECT * FROM ptr.t1;
+id	details
+1	testing1
+2	testing2
+3	testing3
+4	testing4
+10	After Backup1
+20	After Backup2
+SELECT * FROM ptr.t2;
+id	info
+201	aa1
+202	After Backup-1
+203	During backup-1
+204	During backup-2
+SELECT * FROM ptr.t3;
+id	name
+1	hh1
+2	After Backup-1
+3	ab3
+4	ab4
+5	ab5
+
+***  DROP ptr DATABASE ****
+
+DROP DATABASE ptr;
+SET DEBUG_SYNC= 'RESET';

=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_mixed.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_mixed.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_mixed.result	2008-10-08 04:26:25 +0000
@@ -0,0 +1,843 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name	Value
+storage_engine	#
+SET GLOBAL BINLOG_FORMAT='MIXED';
+SET BINLOG_FORMAT='MIXED';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+MIXED
+RESET MASTER;
+**START TEST**
+**** TEST1 ****
+This test will recover data using binlog position
+till point of backup and after backup.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+CREATE DATABASE IF NOT EXISTS ptr;
+USE ptr;
+**** Creating tables ****
+CREATE TABLE ptr.t1(id INT, a CHAR(4));
+INSERT INTO ptr.t1 VALUES(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+CREATE TABLE ptr.t3(id INT, b CHAR(4));
+INSERT INTO ptr.t3 VALUES
+(11,'aa'),(22,'bb'),(33,'cc'),(44,'dd'),(55,'ee');
+CREATE TABLE ptr.t2(id INT, deletes_data VARCHAR(30), updates_data TEXT);
+INSERT INTO ptr.t2 VALUES
+(100,'data1 for testing','update data1'),
+(200,'data2 for testing','update data2'),
+(300,'data3 for testing','update data3'),
+(400,'data4 for testing','update data4'),
+(500,'data5 for testing','update data5'),
+(100,'data1 for testing','update data1'),
+(600,'data6 for testing','update data6');
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+100	data1 for testing	update data1
+200	data2 for testing	update data2
+300	data3 for testing	update data3
+400	data4 for testing	update data4
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+7
+**** Creating tables with different datatypes ****
+CREATE TABLE ptr.d1(
+rint INT,
+tint TINYINT,
+sint SMALLINT,
+bint BIGINT,
+mint MEDIUMINT,
+name CHAR(100),
+city  VARCHAR(100),
+fl FLOAT(7,4),
+pers DECIMAL(8,2),
+sal DOUBLE,
+colours SET('red','blue','yellow'),
+continent ENUM('Asia', 'Europe','Africa','Antartica'),
+ts TIMESTAMP DEFAULT 0,
+dob DATE,
+y YEAR
+);
+CREATE TABLE ptr.d2(
+region TEXT,
+summary LONGTEXT,
+data BLOB,
+details MEDIUMBLOB,
+queries TINYTEXT,
+query2 TINYBLOB,
+extract LONGBLOB,
+paras MEDIUMTEXT
+);
+INSERT INTO ptr.d1 VALUES
+(785,127,7288,278829899,3777,'testing1','sweden','678.299',200.23,829899.909,
+'yellow','Asia','2008-06-01 16:23:30','1984-09-08','1984');
+INSERT INTO ptr.d2 VALUES
+('xxxxxxxx','Testofonline backup','aaaaaaaaaa','bbbbbbbbbbb','hhhhhhhhhhh',
+'kkkkkkkkkkkkk','mmmmmmmmmmmm','onlinebackup1');
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+**** Perform Data Manipulation Operations ****
+## Delete ##
+DELETE FROM ptr.t2 WHERE deletes_data='data4 for testing';
+DELETE FROM ptr.t2 WHERE id=100 LIMIT 1;
+## Insert and Select ##
+**** Now ptr.t2 will have 5 counts in the table ****
+
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+5
+INSERT INTO ptr.t2 VALUES
+(800,'data1 for replacement','replace data1');
+## Replace ##
+REPLACE INTO ptr.t2 
+SET id=800, deletes_data='data replaced', updates_data='replace over';
+## Union ##
+SELECT * FROM ptr.t1 UNION SELECT * FROM ptr.t3;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+## Update ##
+UPDATE ptr.t2 SET updates_data='##VALUE UPDATED##' WHERE id=300;
+Now table t2 will have 6 counts with one updated and replaced values 
+SELECT COUNT(*) FROM ptr.t2;
+COUNT(*)
+7
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+200	data2 for testing	update data2
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.d1;
+Field	Type	Null	Key	Default	Extra
+rint	int(11)	YES		NULL	
+tint	tinyint(4)	YES		NULL	
+sint	smallint(6)	YES		NULL	
+bint	bigint(20)	YES		NULL	
+mint	mediumint(9)	YES		NULL	
+name	char(100)	YES		NULL	
+city	varchar(100)	YES		NULL	
+fl	float(7,4)	YES		NULL	
+pers	decimal(8,2)	YES		NULL	
+sal	double	YES		NULL	
+colours	set('red','blue','yellow')	YES		NULL	
+continent	enum('Asia','Europe','Africa','Antartica')	YES		NULL	
+ts	timestamp	NO		0000-00-00 00:00:00	
+dob	date	YES		NULL	
+y	year(4)	YES		NULL	
+DESCRIBE ptr.d2;
+Field	Type	Null	Key	Default	Extra
+region	text	YES		NULL	
+summary	longtext	YES		NULL	
+data	blob	YES		NULL	
+details	mediumblob	YES		NULL	
+queries	tinytext	YES		NULL	
+query2	tinyblob	YES		NULL	
+extract	longblob	YES		NULL	
+paras	mediumtext	YES		NULL	
+**** Perform Data Definition Operations ****
+## ALTER ##
+ALTER TABLE ptr.t2 ADD COLUMN changes CHAR(20);
+UPDATE ptr.t2 SET changes='altered' WHERE id=200;
+UPDATE ptr.t2 SET changes='altered' WHERE id=100;
+ALTER TABLE ptr.t3 MODIFY b VARCHAR(4);
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+changes	char(20)	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+**** Now we will check the data contents in all the tables again ****
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data	changes
+100	data1 for testing	update data1	altered
+200	data2 for testing	update data2	altered
+300	data3 for testing	##VALUE UPDATED##	NULL
+500	data5 for testing	update data5	NULL
+600	data6 for testing	update data6	NULL
+800	data1 for replacement	replace data1	NULL
+800	data replaced	replace over	NULL
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+** Perform Backup operation and gather binlog position and dates **
+** Backup data **
+set timestamp=@a+2;
+
+Now execute some operations in the table after performing backup.
+
+
+**** Perform some data manipulation operations ****
+INSERT INTO ptr.t1 VALUES(6,'f'),(7,'g');
+INSERT INTO ptr.d1 VALUES
+(10001,120,6550,7278634657,90667,'After backup','Minneapolis',782.9901,
+789.23,97806.456,'blue','Antartica','2008-08-07 15:12:44','1954-12-23','1954');
+INSERT INTO ptr.t3 VALUES(1,'ff'),(3,'kk');
+SELECT * FROM t1 UNION SELECT * FROM t3 ORDER BY a;
+id	a
+1	a
+11	aa
+2	b
+22	bb
+3	c
+33	cc
+4	d
+44	dd
+5	e
+55	ee
+6	f
+1	ff
+7	g
+3	kk
+UPDATE ptr.t3 SET b='mm' where b='kk';
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+DELETE FROM ptr.t2 WHERE id=200;
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data	changes
+100	data1 for testing	update data1	altered
+300	data3 for testing	##VALUE UPDATED##	NULL
+500	data5 for testing	update data5	NULL
+600	data6 for testing	update data6	NULL
+800	data1 for replacement	replace data1	NULL
+800	data replaced	replace over	NULL
+
+**** Perform some data definition operations ****
+ALTER TABLE ptr.t2 DROP COLUMN changes;
+ALTER TABLE ptr.t3 ENGINE=MEMORY;
+CREATE TABLE definition(details LONGTEXT);
+INSERT INTO definition VALUES
+('Performing some data definition statements for PTR');
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.definition;
+Field	Type	Null	Key	Default	Extra
+details	longtext	YES		NULL	
+
+**** The tables t1, t2, t3 and t4 has changes ****
+**** New table "definition" is created after backup *****
+
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+SET TIMESTAMP=@a+4;
+FLUSH LOGS;
+DROP DATABASE ptr;
+**** Execute mysqlbinlog to recover the data from start to backup ****
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+t1
+t2
+t3
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data	changes
+100	data1 for testing	update data1	altered
+200	data2 for testing	update data2	altered
+300	data3 for testing	##VALUE UPDATED##	NULL
+500	data5 for testing	update data5	NULL
+600	data6 for testing	update data6	NULL
+800	data1 for replacement	replace data1	NULL
+800	data replaced	replace over	NULL
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+**** Now perform another recovery to recover data after backup ****
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+DROP DATABASE ptr;
+*** TEST2 *** :
+Perform Restore and recover transactions after backup by executing 
+mysqlbinlog utility using binlog position.
+Perform restore operation 
+RESTORE FROM 'ptr.bak';
+backup_id
+#
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data	changes
+100	data1 for testing	update data1	altered
+200	data2 for testing	update data2	altered
+300	data3 for testing	##VALUE UPDATED##	NULL
+500	data5 for testing	update data5	NULL
+600	data6 for testing	update data6	NULL
+800	data1 for replacement	replace data1	NULL
+800	data replaced	replace over	NULL
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+Recovering data contents after backup
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+DROP DATABASE ptr;
+*** TEST3 *** :
+This test will recover data using binlog dates
+till point of backup and after backup.
+Now use binlog dates to recover the data till point of backup.
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data	changes
+100	data1 for testing	update data1	altered
+200	data2 for testing	update data2	altered
+300	data3 for testing	##VALUE UPDATED##	NULL
+500	data5 for testing	update data5	NULL
+600	data6 for testing	update data6	NULL
+800	data1 for replacement	replace data1	NULL
+800	data replaced	replace over	NULL
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+We execute binlog to recover data after backup using binlog dates.
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+DROP DATABASE ptr;
+*** TEST4 *** :
+Perform Restore and recover transactions after backup by executing
+mysqlbinlog utility using binlog dates.
+RESTORE FROM 'ptr.bak';
+backup_id
+#
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+changes	char(20)	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data	changes
+100	data1 for testing	update data1	altered
+200	data2 for testing	update data2	altered
+300	data3 for testing	##VALUE UPDATED##	NULL
+500	data5 for testing	update data5	NULL
+600	data6 for testing	update data6	NULL
+800	data1 for replacement	replace data1	NULL
+800	data replaced	replace over	NULL
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+SHOW DATABASES;
+Database
+information_schema
+mysql
+ptr
+test
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+DROP DATABASE ptr;
+*** TEST5 *** :
+Do complete recovery of data after backup using binlog position. Ensure 
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW DATABASES;
+Database
+information_schema
+mysql
+ptr
+test
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+DROP DATABASE ptr;
+*** TEST6 *** :
+Do complete recovery of data after backup using binlog dates. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW DATABASES;
+Database
+information_schema
+mysql
+ptr
+test
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+
+***  DROP ptr DATABASE ****
+
+DROP DATABASE ptr;

=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result	2008-10-08 04:26:25 +0000
@@ -0,0 +1,2106 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name	Value
+storage_engine	#
+SET GLOBAL BINLOG_FORMAT='MIXED';
+SET BINLOG_FORMAT='MIXED';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+MIXED
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data and objects using binlog position
+till point of backup and after backup.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+CREATE DATABASE IF NOT EXISTS ptr_ob1;
+CREATE DATABASE IF NOT EXISTS ptr_ob2;
+USE ptr_ob1;
+**** Creating tables ****
+CREATE TABLE ptr_ob1.t1(
+id INT, 
+a INT, 
+b CHAR(5)
+);
+CREATE TABLE ptr_ob1.t2(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+data CHAR(50)
+);
+CREATE TABLE ptr_ob1.t3(
+srno INT AUTO_INCREMENT, 
+PRIMARY KEY(srno), 
+name VARCHAR(30) NOT NULL, 
+old_a INT
+);
+CREATE TABLE ptr_ob2.t1(
+id INT, 
+b CHAR(5)
+);
+CREATE TABLE ptr_ob2.t2(id SMALLINT);
+INSERT INTO ptr_ob2.t1 VALUES(11,'set1'),(21,'set2'),(3,'set3'),(4,'set4');
+INSERT INTO ptr_ob2.t2 VALUES(91),(5),(26),(33),(5);
+**** Creating views ****
+CREATE VIEW ptr_ob1.v AS SELECT * FROM ptr_ob1.t1;
+CREATE VIEW ptr_ob1.v1 AS SELECT * FROM ptr_ob2.t1;
+CREATE TABLE ptr_ob1.tv1(id SMALLINT);
+INSERT INTO ptr_ob1.tv1  VALUES(1),(2),(3),(3),(5);
+SELECT * FROM ptr_ob1.tv1 UNION ALL SELECT * FROM ptr_ob2.t2;
+id
+1
+2
+3
+3
+5
+91
+5
+26
+33
+5
+CREATE VIEW ptr_ob2.v1 AS SELECT * FROM ptr_ob1.tv1  UNION ALL 
+SELECT * FROM ptr_ob2.t2 ORDER BY id;
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+26
+33
+91
+#### Creating view from another view ####
+CREATE VIEW ptr_ob1.vv AS SELECT SUM(id) from ptr_ob2.v1 GROUP BY id;
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+26
+33
+91
+**** Creating Triggers ****
+CREATE TRIGGER ptr_ob1.trg1 BEFORE INSERT ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END;||
+INSERT INTO ptr_ob1.t1 VALUES(1,20, 'bb1'), (2,50, 'bb2'),(3,80,'bb3');
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+2	50	bb2
+3	80	bb3
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT ON ptr_ob1.t2 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END;||
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL, 'Normal Insert1'),(NULL, 'Normal Insert2'),
+(NULL, 'Normal Insert3'),(NULL, 'Normal Insert4');
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+CREATE TRIGGER ptr_ob2.trg3 BEFORE DELETE ON ptr_ob2.t2 FOR EACH ROW
+SET @del_sum:= @del_sum + old.id;||
+SET @del_sum:= 0;||
+DELETE FROM ptr_ob2.t2 WHERE id=26;
+DELETE FROM ptr_ob2.t2 WHERE id=91;
+SELECT @del_sum;
+@del_sum
+117
+CREATE TRIGGER ptr_ob1.trg4 AFTER DELETE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END;||
+DELETE FROM ptr_ob1.t1 WHERE id=2;
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	80	bb3
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	set3
+4	set4
+2	bb2
+CREATE TRIGGER ptr_ob1.trg5 BEFORE UPDATE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END;
+||
+UPDATE ptr_ob1.t1 SET a='85' WHERE b='bb3';
+SELECT @id, @a_old, @a_new;
+@id	@a_old	@a_new
+3	80	85
+CREATE TRIGGER ptr_ob2.trg6 AFTER UPDATE ON ptr_ob2.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END;
+||
+UPDATE ptr_ob2.t1 SET b='alert' WHERE id=3;
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+
+**** Creating stored Procedures and functions ****
+
+#### The procedure p1 will insert VALUES in view ####
+CREATE PROCEDURE ptr_ob1.p1(details CHAR(40), id INT)
+BEGIN
+INSERT INTO ptr_ob1.v1 VALUES(1,'fired');
+END;
+||
+#### Procedure p2 will trigger trg2 ####
+CREATE PROCEDURE ptr_ob1.p2(content VARCHAR(40))
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Trigger fired from procedure p2');
+END;||
+#### Procedure p3 will trigger trg6 ####
+CREATE PROCEDURE ptr_ob1.p3(info TEXT)
+BEGIN
+UPDATE ptr_ob2.t1 SET b='#up#' WHERE id=4;
+END;||
+#### Procedure p4 will call view ####
+CREATE PROCEDURE ptr_ob2.p4() 
+BEGIN
+SELECT * FROM ptr_ob2.v1;
+END;
+||
+#### Function f1() ####
+CREATE FUNCTION f1() RETURNS INT
+RETURN (SELECT COUNT(*) FROM ptr_ob1.v1);||
+SELECT f1();
+f1()
+5
+CALL ptr_ob1.p1('procedure p1 called for view v1', 1);
+CALL ptr_ob1.p1('procedure p1 called for view v1', 2);
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+1	fired
+1	fired
+CALL ptr_ob1.p2('procedure p2 called for trg2');
+CALL ptr_ob1.p2('procedure p2 again called for trg2');
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+CALL ptr_ob1.p3('procedure p3 called for trg6');
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+** Checking data contents in all the tables before performing backup **
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+set timestamp=@a+2;
+Make some changes to objects.
+ALTER VIEW ptr_ob1.v AS SELECT id, a FROM ptr_ob1.t1;
+ALTER TABLE ptr_ob1.vv RENAME TO ptr_ob1.vva;
+ALTER TABLE ptr_ob2.t2 ADD COLUMN af_backup VARCHAR(30);
+ALTER TABLE ptr_ob1.t3 CHANGE name name TEXT;
+DESCRIBE ptr_ob1.t3;
+Field	Type	Null	Key	Default	Extra
+srno	int(11)	NO	PRI	NULL	auto_increment
+name	text	YES		NULL	
+old_a	int(11)	YES		NULL	
+ALTER PROCEDURE ptr_ob2.p4 COMMENT 'AFTER BACKUP';
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+Creating some new objects
+CREATE TABLE ptr_ob1.t11 (i INT, sr INT, j INT) engine=myisam;
+INSERT INTO ptr_ob1.t11 VALUES (1, 2, 3);
+CREATE TRIGGER ptr_ob1.ai AFTER INSERT ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.au AFTER UPDATE ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.ad AFTER DELETE ON ptr_ob1.t11 FOR EACH ROW SET @a:= old.sr;
+INSERT INTO ptr_ob1.t11 VALUES(4, 5, 6),(7, 8, 9);
+SELECT @a;
+@a
+8
+UPDATE ptr_ob1.t11 SET i=10 WHERE sr=5;
+SELECT @a;
+@a
+5
+DELETE FROM ptr_ob1.t11 WHERE sr=8;
+SELECT @a;
+@a
+8
+Now alter the table 
+ALTER TABLE ptr_ob1.t11 DROP COLUMN j;
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+INSERT INTO ptr_ob1.t11 VALUES(11, 12);
+SELECT @a;
+@a
+12
+Firing existing triggers and calling procedures.
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Insert after backup');
+INSERT INTO ptr_ob2.t2 VALUES(10, 'af_bk1'),(2, 'af_bk2'),(7,'af_bk3'),(2,'af_bk4');
+DELETE FROM ptr_ob2.t2 WHERE id=10;
+SELECT @del_sum;
+@del_sum
+127
+CALL ptr_ob1.p1('procedure p1 af_bkup for view v1', 3);
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+CALL ptr_ob1.p2('procedure p2 called  af_bkup for trg2');
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+CALL ptr_ob1.p3('procedure p3 called af_bkup for trg6');
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+Checking the data contents after backup.
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+SET TIMESTAMP=@a+4;
+FLUSH LOGS;
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+**** Execute mysqlbinlog to recover the data from start to backup ****
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+**** Now perform another recovery to recover data after backup ****
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST2 *** :
+Perform Restore and recover transactions after backup by executing 
+mysqlbinlog utility using binlog position.
+
+Perfrom Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Now use binlog position to recover data after backup
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST3 *** :
+This test will recover data and objects using binlog dates
+till point of backup and after backup.
+
+Use mysqlbinlog dates to recover data till point of backup.
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Use mysqlbinlog dates to recover data after backup 
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST4 *** :
+Perform Restore and recover objects after backup by executing mysqlbinlog
+utility using binlog dates.
+
+Perform Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+use binlog dates to recover data after backup.
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST5 *** :
+Do complete recovery of data after backup using binlog position. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST6 *** :
+Do complete recovery of data after backup using binlog dates. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+
+***  DROP ptr_ob1 and ptr_ob2 DATABASE ****
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;

=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result	2008-10-08 04:26:25 +0000
@@ -0,0 +1,2106 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name	Value
+storage_engine	#
+SET GLOBAL BINLOG_FORMAT='ROW';
+SET BINLOG_FORMAT='ROW';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+ROW
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data and objects using binlog position
+till point of backup and after backup.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+CREATE DATABASE IF NOT EXISTS ptr_ob1;
+CREATE DATABASE IF NOT EXISTS ptr_ob2;
+USE ptr_ob1;
+**** Creating tables ****
+CREATE TABLE ptr_ob1.t1(
+id INT, 
+a INT, 
+b CHAR(5)
+);
+CREATE TABLE ptr_ob1.t2(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+data CHAR(50)
+);
+CREATE TABLE ptr_ob1.t3(
+srno INT AUTO_INCREMENT, 
+PRIMARY KEY(srno), 
+name VARCHAR(30) NOT NULL, 
+old_a INT
+);
+CREATE TABLE ptr_ob2.t1(
+id INT, 
+b CHAR(5)
+);
+CREATE TABLE ptr_ob2.t2(id SMALLINT);
+INSERT INTO ptr_ob2.t1 VALUES(11,'set1'),(21,'set2'),(3,'set3'),(4,'set4');
+INSERT INTO ptr_ob2.t2 VALUES(91),(5),(26),(33),(5);
+**** Creating views ****
+CREATE VIEW ptr_ob1.v AS SELECT * FROM ptr_ob1.t1;
+CREATE VIEW ptr_ob1.v1 AS SELECT * FROM ptr_ob2.t1;
+CREATE TABLE ptr_ob1.tv1(id SMALLINT);
+INSERT INTO ptr_ob1.tv1  VALUES(1),(2),(3),(3),(5);
+SELECT * FROM ptr_ob1.tv1 UNION ALL SELECT * FROM ptr_ob2.t2;
+id
+1
+2
+3
+3
+5
+91
+5
+26
+33
+5
+CREATE VIEW ptr_ob2.v1 AS SELECT * FROM ptr_ob1.tv1  UNION ALL 
+SELECT * FROM ptr_ob2.t2 ORDER BY id;
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+26
+33
+91
+#### Creating view from another view ####
+CREATE VIEW ptr_ob1.vv AS SELECT SUM(id) from ptr_ob2.v1 GROUP BY id;
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+26
+33
+91
+**** Creating Triggers ****
+CREATE TRIGGER ptr_ob1.trg1 BEFORE INSERT ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END;||
+INSERT INTO ptr_ob1.t1 VALUES(1,20, 'bb1'), (2,50, 'bb2'),(3,80,'bb3');
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+2	50	bb2
+3	80	bb3
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT ON ptr_ob1.t2 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END;||
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL, 'Normal Insert1'),(NULL, 'Normal Insert2'),
+(NULL, 'Normal Insert3'),(NULL, 'Normal Insert4');
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+CREATE TRIGGER ptr_ob2.trg3 BEFORE DELETE ON ptr_ob2.t2 FOR EACH ROW
+SET @del_sum:= @del_sum + old.id;||
+SET @del_sum:= 0;||
+DELETE FROM ptr_ob2.t2 WHERE id=26;
+DELETE FROM ptr_ob2.t2 WHERE id=91;
+SELECT @del_sum;
+@del_sum
+117
+CREATE TRIGGER ptr_ob1.trg4 AFTER DELETE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END;||
+DELETE FROM ptr_ob1.t1 WHERE id=2;
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	80	bb3
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	set3
+4	set4
+2	bb2
+CREATE TRIGGER ptr_ob1.trg5 BEFORE UPDATE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END;
+||
+UPDATE ptr_ob1.t1 SET a='85' WHERE b='bb3';
+SELECT @id, @a_old, @a_new;
+@id	@a_old	@a_new
+3	80	85
+CREATE TRIGGER ptr_ob2.trg6 AFTER UPDATE ON ptr_ob2.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END;
+||
+UPDATE ptr_ob2.t1 SET b='alert' WHERE id=3;
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+
+**** Creating stored Procedures and functions ****
+
+#### The procedure p1 will insert VALUES in view ####
+CREATE PROCEDURE ptr_ob1.p1(details CHAR(40), id INT)
+BEGIN
+INSERT INTO ptr_ob1.v1 VALUES(1,'fired');
+END;
+||
+#### Procedure p2 will trigger trg2 ####
+CREATE PROCEDURE ptr_ob1.p2(content VARCHAR(40))
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Trigger fired from procedure p2');
+END;||
+#### Procedure p3 will trigger trg6 ####
+CREATE PROCEDURE ptr_ob1.p3(info TEXT)
+BEGIN
+UPDATE ptr_ob2.t1 SET b='#up#' WHERE id=4;
+END;||
+#### Procedure p4 will call view ####
+CREATE PROCEDURE ptr_ob2.p4() 
+BEGIN
+SELECT * FROM ptr_ob2.v1;
+END;
+||
+#### Function f1() ####
+CREATE FUNCTION f1() RETURNS INT
+RETURN (SELECT COUNT(*) FROM ptr_ob1.v1);||
+SELECT f1();
+f1()
+5
+CALL ptr_ob1.p1('procedure p1 called for view v1', 1);
+CALL ptr_ob1.p1('procedure p1 called for view v1', 2);
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+1	fired
+1	fired
+CALL ptr_ob1.p2('procedure p2 called for trg2');
+CALL ptr_ob1.p2('procedure p2 again called for trg2');
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+CALL ptr_ob1.p3('procedure p3 called for trg6');
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+** Checking data contents in all the tables before performing backup **
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+set timestamp=@a+2;
+Make some changes to objects.
+ALTER VIEW ptr_ob1.v AS SELECT id, a FROM ptr_ob1.t1;
+ALTER TABLE ptr_ob1.vv RENAME TO ptr_ob1.vva;
+ALTER TABLE ptr_ob2.t2 ADD COLUMN af_backup VARCHAR(30);
+ALTER TABLE ptr_ob1.t3 CHANGE name name TEXT;
+DESCRIBE ptr_ob1.t3;
+Field	Type	Null	Key	Default	Extra
+srno	int(11)	NO	PRI	NULL	auto_increment
+name	text	YES		NULL	
+old_a	int(11)	YES		NULL	
+ALTER PROCEDURE ptr_ob2.p4 COMMENT 'AFTER BACKUP';
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+Creating some new objects
+CREATE TABLE ptr_ob1.t11 (i INT, sr INT, j INT) engine=myisam;
+INSERT INTO ptr_ob1.t11 VALUES (1, 2, 3);
+CREATE TRIGGER ptr_ob1.ai AFTER INSERT ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.au AFTER UPDATE ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.ad AFTER DELETE ON ptr_ob1.t11 FOR EACH ROW SET @a:= old.sr;
+INSERT INTO ptr_ob1.t11 VALUES(4, 5, 6),(7, 8, 9);
+SELECT @a;
+@a
+8
+UPDATE ptr_ob1.t11 SET i=10 WHERE sr=5;
+SELECT @a;
+@a
+5
+DELETE FROM ptr_ob1.t11 WHERE sr=8;
+SELECT @a;
+@a
+8
+Now alter the table 
+ALTER TABLE ptr_ob1.t11 DROP COLUMN j;
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+INSERT INTO ptr_ob1.t11 VALUES(11, 12);
+SELECT @a;
+@a
+12
+Firing existing triggers and calling procedures.
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Insert after backup');
+INSERT INTO ptr_ob2.t2 VALUES(10, 'af_bk1'),(2, 'af_bk2'),(7,'af_bk3'),(2,'af_bk4');
+DELETE FROM ptr_ob2.t2 WHERE id=10;
+SELECT @del_sum;
+@del_sum
+127
+CALL ptr_ob1.p1('procedure p1 af_bkup for view v1', 3);
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+CALL ptr_ob1.p2('procedure p2 called  af_bkup for trg2');
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+CALL ptr_ob1.p3('procedure p3 called af_bkup for trg6');
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+Checking the data contents after backup.
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+SET TIMESTAMP=@a+4;
+FLUSH LOGS;
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+**** Execute mysqlbinlog to recover the data from start to backup ****
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+**** Now perform another recovery to recover data after backup ****
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST2 *** :
+Perform Restore and recover transactions after backup by executing 
+mysqlbinlog utility using binlog position.
+
+Perfrom Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Now use binlog position to recover data after backup
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST3 *** :
+This test will recover data and objects using binlog dates
+till point of backup and after backup.
+
+Use mysqlbinlog dates to recover data till point of backup.
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Use mysqlbinlog dates to recover data after backup 
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST4 *** :
+Perform Restore and recover objects after backup by executing mysqlbinlog
+utility using binlog dates.
+
+Perform Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+use binlog dates to recover data after backup.
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST5 *** :
+Do complete recovery of data after backup using binlog position. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST6 *** :
+Do complete recovery of data after backup using binlog dates. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+
+***  DROP ptr_ob1 and ptr_ob2 DATABASE ****
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;

=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result	2008-10-08 04:26:25 +0000
@@ -0,0 +1,2106 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name	Value
+storage_engine	#
+SET GLOBAL BINLOG_FORMAT='STATEMENT';
+SET BINLOG_FORMAT='STATEMENT';
+SELECT @@BINLOG_FORMAT;
+@@BINLOG_FORMAT
+STATEMENT
+RESET MASTER;
+**START TEST**
+*** TEST1 ***
+This test will recover data and objects using binlog position
+till point of backup and after backup.
+
+SET @a=UNIX_TIMESTAMP("2010-01-21 15:32:22");
+SET timestamp=@a;
+CREATE DATABASE IF NOT EXISTS ptr_ob1;
+CREATE DATABASE IF NOT EXISTS ptr_ob2;
+USE ptr_ob1;
+**** Creating tables ****
+CREATE TABLE ptr_ob1.t1(
+id INT, 
+a INT, 
+b CHAR(5)
+);
+CREATE TABLE ptr_ob1.t2(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+data CHAR(50)
+);
+CREATE TABLE ptr_ob1.t3(
+srno INT AUTO_INCREMENT, 
+PRIMARY KEY(srno), 
+name VARCHAR(30) NOT NULL, 
+old_a INT
+);
+CREATE TABLE ptr_ob2.t1(
+id INT, 
+b CHAR(5)
+);
+CREATE TABLE ptr_ob2.t2(id SMALLINT);
+INSERT INTO ptr_ob2.t1 VALUES(11,'set1'),(21,'set2'),(3,'set3'),(4,'set4');
+INSERT INTO ptr_ob2.t2 VALUES(91),(5),(26),(33),(5);
+**** Creating views ****
+CREATE VIEW ptr_ob1.v AS SELECT * FROM ptr_ob1.t1;
+CREATE VIEW ptr_ob1.v1 AS SELECT * FROM ptr_ob2.t1;
+CREATE TABLE ptr_ob1.tv1(id SMALLINT);
+INSERT INTO ptr_ob1.tv1  VALUES(1),(2),(3),(3),(5);
+SELECT * FROM ptr_ob1.tv1 UNION ALL SELECT * FROM ptr_ob2.t2;
+id
+1
+2
+3
+3
+5
+91
+5
+26
+33
+5
+CREATE VIEW ptr_ob2.v1 AS SELECT * FROM ptr_ob1.tv1  UNION ALL 
+SELECT * FROM ptr_ob2.t2 ORDER BY id;
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+26
+33
+91
+#### Creating view from another view ####
+CREATE VIEW ptr_ob1.vv AS SELECT SUM(id) from ptr_ob2.v1 GROUP BY id;
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+26
+33
+91
+**** Creating Triggers ****
+CREATE TRIGGER ptr_ob1.trg1 BEFORE INSERT ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END;||
+INSERT INTO ptr_ob1.t1 VALUES(1,20, 'bb1'), (2,50, 'bb2'),(3,80,'bb3');
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+2	50	bb2
+3	80	bb3
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT ON ptr_ob1.t2 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END;||
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL, 'Normal Insert1'),(NULL, 'Normal Insert2'),
+(NULL, 'Normal Insert3'),(NULL, 'Normal Insert4');
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+CREATE TRIGGER ptr_ob2.trg3 BEFORE DELETE ON ptr_ob2.t2 FOR EACH ROW
+SET @del_sum:= @del_sum + old.id;||
+SET @del_sum:= 0;||
+DELETE FROM ptr_ob2.t2 WHERE id=26;
+DELETE FROM ptr_ob2.t2 WHERE id=91;
+SELECT @del_sum;
+@del_sum
+117
+CREATE TRIGGER ptr_ob1.trg4 AFTER DELETE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END;||
+DELETE FROM ptr_ob1.t1 WHERE id=2;
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	80	bb3
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	set3
+4	set4
+2	bb2
+CREATE TRIGGER ptr_ob1.trg5 BEFORE UPDATE ON ptr_ob1.t1 FOR EACH ROW
+BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END;
+||
+UPDATE ptr_ob1.t1 SET a='85' WHERE b='bb3';
+SELECT @id, @a_old, @a_new;
+@id	@a_old	@a_new
+3	80	85
+CREATE TRIGGER ptr_ob2.trg6 AFTER UPDATE ON ptr_ob2.t1 FOR EACH ROW
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END;
+||
+UPDATE ptr_ob2.t1 SET b='alert' WHERE id=3;
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+
+**** Creating stored Procedures and functions ****
+
+#### The procedure p1 will insert VALUES in view ####
+CREATE PROCEDURE ptr_ob1.p1(details CHAR(40), id INT)
+BEGIN
+INSERT INTO ptr_ob1.v1 VALUES(1,'fired');
+END;
+||
+#### Procedure p2 will trigger trg2 ####
+CREATE PROCEDURE ptr_ob1.p2(content VARCHAR(40))
+BEGIN
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Trigger fired from procedure p2');
+END;||
+#### Procedure p3 will trigger trg6 ####
+CREATE PROCEDURE ptr_ob1.p3(info TEXT)
+BEGIN
+UPDATE ptr_ob2.t1 SET b='#up#' WHERE id=4;
+END;||
+#### Procedure p4 will call view ####
+CREATE PROCEDURE ptr_ob2.p4() 
+BEGIN
+SELECT * FROM ptr_ob2.v1;
+END;
+||
+#### Function f1() ####
+CREATE FUNCTION f1() RETURNS INT
+RETURN (SELECT COUNT(*) FROM ptr_ob1.v1);||
+SELECT f1();
+f1()
+5
+CALL ptr_ob1.p1('procedure p1 called for view v1', 1);
+CALL ptr_ob1.p1('procedure p1 called for view v1', 2);
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	set4
+2	bb2
+1	fired
+1	fired
+CALL ptr_ob1.p2('procedure p2 called for trg2');
+CALL ptr_ob1.p2('procedure p2 again called for trg2');
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+CALL ptr_ob1.p3('procedure p3 called for trg6');
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+** Checking data contents in all the tables before performing backup **
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+set timestamp=@a+2;
+Make some changes to objects.
+ALTER VIEW ptr_ob1.v AS SELECT id, a FROM ptr_ob1.t1;
+ALTER TABLE ptr_ob1.vv RENAME TO ptr_ob1.vva;
+ALTER TABLE ptr_ob2.t2 ADD COLUMN af_backup VARCHAR(30);
+ALTER TABLE ptr_ob1.t3 CHANGE name name TEXT;
+DESCRIBE ptr_ob1.t3;
+Field	Type	Null	Key	Default	Extra
+srno	int(11)	NO	PRI	NULL	auto_increment
+name	text	YES		NULL	
+old_a	int(11)	YES		NULL	
+ALTER PROCEDURE ptr_ob2.p4 COMMENT 'AFTER BACKUP';
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+Creating some new objects
+CREATE TABLE ptr_ob1.t11 (i INT, sr INT, j INT) engine=myisam;
+INSERT INTO ptr_ob1.t11 VALUES (1, 2, 3);
+CREATE TRIGGER ptr_ob1.ai AFTER INSERT ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.au AFTER UPDATE ON ptr_ob1.t11 FOR EACH ROW SET @a:= new.sr;
+CREATE TRIGGER ptr_ob1.ad AFTER DELETE ON ptr_ob1.t11 FOR EACH ROW SET @a:= old.sr;
+INSERT INTO ptr_ob1.t11 VALUES(4, 5, 6),(7, 8, 9);
+SELECT @a;
+@a
+8
+UPDATE ptr_ob1.t11 SET i=10 WHERE sr=5;
+SELECT @a;
+@a
+5
+DELETE FROM ptr_ob1.t11 WHERE sr=8;
+SELECT @a;
+@a
+8
+Now alter the table 
+ALTER TABLE ptr_ob1.t11 DROP COLUMN j;
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+INSERT INTO ptr_ob1.t11 VALUES(11, 12);
+SELECT @a;
+@a
+12
+Firing existing triggers and calling procedures.
+INSERT INTO ptr_ob1.t2 VALUES(NULL, 'Insert after backup');
+INSERT INTO ptr_ob2.t2 VALUES(10, 'af_bk1'),(2, 'af_bk2'),(7,'af_bk3'),(2,'af_bk4');
+DELETE FROM ptr_ob2.t2 WHERE id=10;
+SELECT @del_sum;
+@del_sum
+127
+CALL ptr_ob1.p1('procedure p1 af_bkup for view v1', 3);
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+CALL ptr_ob1.p2('procedure p2 called  af_bkup for trg2');
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+CALL ptr_ob1.p3('procedure p3 called af_bkup for trg6');
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+CALL ptr_ob2.p4();
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+Checking the data contents after backup.
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+SET TIMESTAMP=@a+4;
+FLUSH LOGS;
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+**** Execute mysqlbinlog to recover the data from start to backup ****
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+**** Now perform another recovery to recover data after backup ****
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST2 *** :
+Perform Restore and recover transactions after backup by executing 
+mysqlbinlog utility using binlog position.
+
+Perfrom Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Now use binlog position to recover data after backup
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST3 *** :
+This test will recover data and objects using binlog dates
+till point of backup and after backup.
+
+Use mysqlbinlog dates to recover data till point of backup.
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+Use mysqlbinlog dates to recover data after backup 
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST4 *** :
+Perform Restore and recover objects after backup by executing mysqlbinlog
+utility using binlog dates.
+
+Perform Restore operation
+RESTORE FROM 'ptr_objects.bak';
+backup_id
+#
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vv	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+3
+3
+5
+5
+5
+33
+SELECT * FROM ptr_ob1.vv;
+SUM(id)
+1
+2
+6
+15
+33
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+7
+use binlog dates to recover data after backup.
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST5 *** :
+Do complete recovery of data after backup using binlog position. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;
+*** TEST6 *** :
+Do complete recovery of data after backup using binlog dates. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW PROCEDURE STATUS;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment	character_set_client	collation_connection	Database Collation
+ptr_ob1	p1	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p2	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob1	p3	PROCEDURE	root@localhost	#	#	DEFINER		#	#	#
+ptr_ob2	p4	PROCEDURE	root@localhost	#	#	DEFINER	AFTER BACKUP	#	#	#
+SHOW TRIGGERS FROM ptr_ob1;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg1	INSERT	t1	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 't1', new.a);
+END	#	#		root@localhost	#	#	#
+trg5	UPDATE	t1	BEGIN
+SET @id=old.id;
+SET @a_old=old.a;
+SET @a_new=new.a;
+END	#	#		root@localhost	#	#	#
+trg4	DELETE	t1	BEGIN 
+INSERT INTO ptr_ob2.t1(id, b) VALUES(old.id, old.b);
+END	#	#		root@localhost	#	#	#
+ai	INSERT	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+au	UPDATE	t11	SET @a:= new.sr	#	#		root@localhost	#	#	#
+ad	DELETE	t11	SET @a:= old.sr	#	#		root@localhost	#	#	#
+trg2	INSERT	t2	BEGIN
+INSERT INTO ptr_ob1.t3 VALUES(NULL, 'trigger fired for AFTER INSERT', 100);
+END	#	#		root@localhost	#	#	#
+SHOW TRIGGERS FROM ptr_ob2;
+Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
+trg6	UPDATE	t1	BEGIN
+INSERT INTO ptr_ob1.t2 VALUES
+(NULL,'Trigger fired from after update of ptr_ob2.t1');  
+END	#	#		root@localhost	#	#	#
+trg3	DELETE	t2	SET @del_sum:= @del_sum + old.id	#	#		root@localhost	#	#	#
+SHOW FULL TABLES FROM ptr_ob1;
+Tables_in_ptr_ob1	Table_type
+t1	BASE TABLE
+t11	BASE TABLE
+t2	BASE TABLE
+t3	BASE TABLE
+tv1	BASE TABLE
+v	VIEW
+v1	VIEW
+vva	VIEW
+SHOW FULL TABLES FROM ptr_ob2;
+Tables_in_ptr_ob2	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+v1	VIEW
+SELECT * FROM ptr_ob1.t1;
+id	a	b
+1	20	bb1
+3	85	bb3
+SELECT * FROM ptr_ob1.v;
+id	a
+1	20
+3	85
+SELECT * FROM ptr_ob1.t2;
+id	data
+1	Normal Insert1
+2	Normal Insert2
+3	Normal Insert3
+4	Normal Insert4
+5	Trigger fired from after update of ptr_ob2.t1
+6	Trigger fired from procedure p2
+7	Trigger fired from procedure p2
+8	Trigger fired from after update of ptr_ob2.t1
+9	Insert after backup
+10	Trigger fired from procedure p2
+11	Trigger fired from after update of ptr_ob2.t1
+SELECT * FROM ptr_ob1.t3;
+srno	name	old_a
+1	t1	20
+2	t1	50
+3	t1	80
+4	trigger fired for AFTER INSERT	100
+5	trigger fired for AFTER INSERT	100
+6	trigger fired for AFTER INSERT	100
+7	trigger fired for AFTER INSERT	100
+8	trigger fired for AFTER INSERT	100
+9	trigger fired for AFTER INSERT	100
+10	trigger fired for AFTER INSERT	100
+11	trigger fired for AFTER INSERT	100
+12	trigger fired for AFTER INSERT	100
+13	trigger fired for AFTER INSERT	100
+14	trigger fired for AFTER INSERT	100
+SELECT * FROM ptr_ob2.t1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.v1;
+id	b
+11	set1
+21	set2
+3	alert
+4	#up#
+2	bb2
+1	fired
+1	fired
+1	fired
+SELECT * FROM ptr_ob1.tv1;
+id
+1
+2
+3
+3
+5
+SELECT * FROM ptr_ob2.v1;
+id
+1
+2
+2
+2
+3
+3
+5
+5
+5
+7
+33
+SELECT * FROM ptr_ob1.vva;
+SUM(id)
+1
+6
+6
+15
+7
+33
+SELECT * FROM ptr_ob1.t11;
+i	sr
+1	2
+10	5
+11	12
+SELECT ptr_ob1.f1();
+ptr_ob1.f1()
+8
+
+***  DROP ptr_ob1 and ptr_ob2 DATABASE ****
+
+DROP DATABASE ptr_ob1;
+DROP DATABASE ptr_ob2;

=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_row.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_row.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_row.result	2008-10-08 04:26:25 +0000
@@ -0,0 +1,843 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name	Value
+storage_engine	#
+SET GLOBAL BINLOG_FORMAT='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
+300	data3 for testing	##VALUE UPDATED##	NULL
+500	data5 for testing	update data5	NULL
+600	data6 for testing	update data6	NULL
+800	data1 for replacement	replace data1	NULL
+800	data replaced	replace over	NULL
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+SHOW DATABASES;
+Database
+information_schema
+mysql
+ptr
+test
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+DROP DATABASE ptr;
+*** TEST5 *** :
+Do complete recovery of data after backup using binlog position. Ensure 
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW DATABASES;
+Database
+information_schema
+mysql
+ptr
+test
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+DROP DATABASE ptr;
+*** TEST6 *** :
+Do complete recovery of data after backup using binlog dates. Ensure
+that presence of backup operation in the binlog shouldn't have any impact
+SHOW DATABASES;
+Database
+information_schema
+mysql
+ptr
+test
+SHOW TABLES FROM ptr;
+Tables_in_ptr
+d1
+d2
+definition
+t1
+t2
+t3
+DESCRIBE ptr.t1;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+a	char(4)	YES		NULL	
+DESCRIBE ptr.t2;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+deletes_data	varchar(30)	YES		NULL	
+updates_data	text	YES		NULL	
+DESCRIBE ptr.t3;
+Field	Type	Null	Key	Default	Extra
+id	int(11)	YES		NULL	
+b	varchar(4)	YES		NULL	
+SELECT * FROM ptr.t1;
+id	a
+1	a
+2	b
+3	c
+4	d
+5	e
+6	f
+7	g
+SELECT * FROM ptr.t2 ORDER BY id;
+id	deletes_data	updates_data
+100	data1 for testing	update data1
+300	data3 for testing	##VALUE UPDATED##
+500	data5 for testing	update data5
+600	data6 for testing	update data6
+800	data1 for replacement	replace data1
+800	data replaced	replace over
+SELECT * FROM ptr.t3;
+id	b
+11	aa
+22	bb
+33	cc
+44	dd
+55	ee
+1	ff
+3	mm
+SELECT * FROM ptr.d1;
+rint	tint	sint	bint	mint	name	city	fl	pers	sal	colours	continent	ts	dob	y
+785	127	7288	278829899	3777	testing1	sweden	678.2990	200.23	829899.909	yellow	Asia	2008-06-01 16:23:30	1984-09-08	1984
+10001	120	6550	7278634657	90667	After backup	Minneapolis	782.9901	789.23	97806.456	blue	Antartica	2008-08-07 15:12:44	1954-12-23	1954
+SELECT * FROM ptr.d2;
+region	summary	data	details	queries	query2	extract	paras
+xxxxxxxx	Testofonline backup	aaaaaaaaaa	bbbbbbbbbbb	hhhhhhhhhhh	kkkkkkkkkkkkk	mmmmmmmmmmmm	onlinebackup1
+
+***  DROP ptr DATABASE ****
+
+DROP DATABASE ptr;

=== added file 'mysql-test/suite/backup_engines/r/backup_ptr_stmt.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_stmt.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_stmt.result	2008-10-08 04:26:25 +0000
@@ -0,0 +1,845 @@
+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 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;
+Warnings:
+Warning	1592	Statement is not safe to log in statement format.
+## 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;

=== modified file 'mysql-test/suite/backup_engines/t/backup_functions.test'
--- a/mysql-test/suite/backup/t/backup_functions.test	2008-08-12 03:22:05 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_functions.test	2008-10-07 17:15:44 +0000
@@ -5,7 +5,7 @@
 # after backup and Restore.
 ###############################################################################
 --source include/not_embedded.inc
---source suite/backup/include/backup_engine.inc
+--source suite/backup_engines/include/backup_engine.inc
 --source include/have_debug.inc
 
 connect (backup,localhost,root,,);

=== modified file 'mysql-test/suite/backup_engines/t/backup_procedures.test'
--- a/mysql-test/suite/backup/t/backup_procedures.test	2008-08-12 03:22:05 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_procedures.test	2008-10-07 17:15:44 +0000
@@ -5,7 +5,7 @@
 #  storage engines.
 ###############################################################################
 --source include/not_embedded.inc
---source suite/backup/include/backup_engine.inc
+--source suite/backup_engines/include/backup_engine.inc
 --source include/have_debug.inc
 
 connect (backup,localhost,root,,);

=== added file 'mysql-test/suite/backup_engines/t/backup_ptr_commit_mixed.test'
--- a/mysql-test/suite/backup_engines/t/backup_ptr_commit_mixed.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_ptr_commit_mixed.test	2008-10-08 04:26:25 +0000
@@ -0,0 +1,16 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserves all the
+# objects during backup
+###############################################################################
+
+--source suite/backup_engines/include/backup_engine.inc
+--source suite/backup_engines/include/not_have_falcon.inc
+--source suite/backup_engines/include/not_have_memory.inc
+--source suite/backup_engines/include/not_have_myisam.inc
+
+SET GLOBAL BINLOG_FORMAT='MIXED';
+SET BINLOG_FORMAT='MIXED';
+--source suite/backup_engines/include/backup_ptr_commit.inc
+

=== added file 'mysql-test/suite/backup_engines/t/backup_ptr_commit_row.test'
--- a/mysql-test/suite/backup_engines/t/backup_ptr_commit_row.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_ptr_commit_row.test	2008-10-08 04:26:25 +0000
@@ -0,0 +1,16 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserves all the
+# objects during backup
+###############################################################################
+
+--source suite/backup_engines/include/backup_engine.inc
+--source suite/backup_engines/include/not_have_falcon.inc
+--source suite/backup_engines/include/not_have_memory.inc
+--source suite/backup_engines/include/not_have_myisam.inc
+
+SET GLOBAL BINLOG_FORMAT='ROW';
+SET BINLOG_FORMAT='ROW';
+--source suite/backup_engines/include/backup_ptr_commit.inc
+

=== added file 'mysql-test/suite/backup_engines/t/backup_ptr_commit_stmt.test'
--- a/mysql-test/suite/backup_engines/t/backup_ptr_commit_stmt.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_ptr_commit_stmt.test	2008-10-08 04:26:25 +0000
@@ -0,0 +1,16 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserves all the
+# objects during backup
+###############################################################################
+
+--source suite/backup_engines/include/backup_engine.inc
+--source suite/backup_engines/include/not_have_falcon.inc
+--source suite/backup_engines/include/not_have_memory.inc
+--source suite/backup_engines/include/not_have_myisam.inc
+
+SET GLOBAL BINLOG_FORMAT='STATEMENT';
+SET BINLOG_FORMAT='STATEMENT';
+--source suite/backup_engines/include/backup_ptr_commit.inc
+

=== added file 'mysql-test/suite/backup_engines/t/backup_ptr_mixed.test'
--- a/mysql-test/suite/backup_engines/t/backup_ptr_mixed.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_ptr_mixed.test	2008-10-08 04:26:25 +0000
@@ -0,0 +1,13 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserved during backup
+###############################################################################
+--source suite/backup_engines/include/backup_engine.inc
+--source suite/backup_engines/include/not_have_memory.inc
+
+# Memory engine is skipped as it does not support TEXT datatype.
+SET GLOBAL BINLOG_FORMAT='MIXED';
+SET BINLOG_FORMAT='MIXED';
+--source suite/backup_engines/include/backup_ptr.inc
+

=== added file 'mysql-test/suite/backup_engines/t/backup_ptr_objects_mixed.test'
--- a/mysql-test/suite/backup_engines/t/backup_ptr_objects_mixed.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_ptr_objects_mixed.test	2008-10-08 04:26:25 +0000
@@ -0,0 +1,19 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserves all the      # objects during backup
+###############################################################################
+
+--source suite/backup_engines/include/backup_engine.inc
+--source suite/backup_engines/include/not_have_memory.inc
+--source suite/backup_engines/include/not_have_innodb.inc
+
+# Memory engine is skipped as it does not support TEXT datatype.
+# The innodb engine will be skipped for this test because of
+# Bug#38872. Once this bug is fixed, allow this test to run with
+# Innodb storage engine.
+
+SET GLOBAL BINLOG_FORMAT='MIXED';
+SET BINLOG_FORMAT='MIXED';
+--source suite/backup_engines/include/backup_ptr_objects.inc
+

=== added file 'mysql-test/suite/backup_engines/t/backup_ptr_objects_row.test'
--- a/mysql-test/suite/backup_engines/t/backup_ptr_objects_row.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_ptr_objects_row.test	2008-10-08 04:26:25 +0000
@@ -0,0 +1,14 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserves all the      # objects during backup
+###############################################################################
+
+--source suite/backup_engines/include/backup_engine.inc
+--source suite/backup_engines/include/not_have_memory.inc
+
+# Memory engine is skipped as it does not support TEXT datatype.
+SET GLOBAL BINLOG_FORMAT='ROW';
+SET BINLOG_FORMAT='ROW';
+--source suite/backup_engines/include/backup_ptr_objects.inc
+

=== added file 'mysql-test/suite/backup_engines/t/backup_ptr_objects_stmt.test'
--- a/mysql-test/suite/backup_engines/t/backup_ptr_objects_stmt.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_ptr_objects_stmt.test	2008-10-08 04:26:25 +0000
@@ -0,0 +1,23 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserves all the
+# objects during backup
+###############################################################################
+
+--source suite/backup_engines/include/backup_engine.inc
+--source suite/backup_engines/include/not_have_falcon.inc
+--source suite/backup_engines/include/not_have_memory.inc
+--source suite/backup_engines/include/not_have_innodb.inc
+
+# Falcon supports only row based logging, therefore we skip falcon
+# engine for this test.
+# Memory engine is skipped as it does not support TEXT datatype.
+# The innodb engine will be skipped for this test because of
+# Bug#38872. Once this bug is fixed, allow this test to run with
+# Innodb storage engine.
+
+SET GLOBAL BINLOG_FORMAT='STATEMENT';
+SET BINLOG_FORMAT='STATEMENT';
+--source suite/backup_engines/include/backup_ptr_objects.inc
+

=== added file 'mysql-test/suite/backup_engines/t/backup_ptr_row.test'
--- a/mysql-test/suite/backup_engines/t/backup_ptr_row.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_ptr_row.test	2008-10-08 04:26:25 +0000
@@ -0,0 +1,15 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserved during 
+# backup
+###############################################################################
+
+--source suite/backup_engines/include/backup_engine.inc
+--source suite/backup_engines/include/not_have_memory.inc
+
+# Memory engine is skipped as it does not support TEXT datatype.
+SET GLOBAL BINLOG_FORMAT='ROW';
+SET BINLOG_FORMAT='ROW';
+--source suite/backup_engines/include/backup_ptr.inc
+

=== added file 'mysql-test/suite/backup_engines/t/backup_ptr_stmt.test'
--- a/mysql-test/suite/backup_engines/t/backup_ptr_stmt.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_ptr_stmt.test	2008-10-08 04:26:25 +0000
@@ -0,0 +1,16 @@
+##########################################################################
+# Author: Hema
+# Date: 2008-07-30
+# Purpose: Test to ensure that point in time recovery is preserved during 
+# backup
+###############################################################################
+
+--source suite/backup_engines/include/backup_engine.inc
+--source suite/backup_engines/include/not_have_falcon.inc
+--source suite/backup_engines/include/not_have_memory.inc
+
+# Memory engine is skipped as it does not support TEXT datatype.
+SET GLOBAL BINLOG_FORMAT='STATEMENT';
+SET BINLOG_FORMAT='STATEMENT';
+--source suite/backup_engines/include/backup_ptr.inc
+

=== modified file 'mysql-test/suite/backup_engines/t/backup_triggers.test'
--- a/mysql-test/suite/backup/t/backup_triggers.test	2008-08-12 03:22:05 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_triggers.test	2008-10-07 17:15:44 +0000
@@ -7,7 +7,7 @@
 ###################################################################
 
 --source include/not_embedded.inc
---source suite/backup/include/backup_engine.inc
+--source suite/backup_engines/include/backup_engine.inc
 --source include/have_debug.inc
 
 connect (backup,localhost,root,,);

=== modified file 'mysql-test/suite/falcon/r/falcon_bugs.result'
--- a/mysql-test/suite/falcon/r/falcon_bugs.result	2007-11-26 15:50:23 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bugs.result	2008-10-02 21:05:39 +0000
@@ -3263,4 +3263,20 @@ count(*)
 select count(*) from t2 where b = 150;
 count(*)
 1
+#
+# Bug #36473 Assertion "! is_set()" fails in
+# Diagnostics_area::set_ok_status with Falcon
+# Ensure that we check the return value of update_auto_increment().
+#
+set @@storage_engine = falcon;
+drop table if exists t1;
+create table t1 (a tinyint(4) NOT NULL auto_increment, primary key (a));
+set @@sql_mode='strict_all_tables';
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+insert into t1 values (null);
+ERROR 22003: Out of range value for column 'a' at row 1
+set @@sql_mode=default;
+set auto_increment_offset=default;
+set auto_increment_increment=default;
 DROP TABLE t1, t2;

=== modified file 'mysql-test/suite/falcon/t/falcon_bugs.test'
--- a/mysql-test/suite/falcon/t/falcon_bugs.test	2007-12-19 18:55:35 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bugs.test	2008-10-02 21:05:39 +0000
@@ -1772,5 +1772,26 @@ update t1, t2 set t1.b = 150, t2.b = t1.
 select count(*) from t1 where b = 150;
 select count(*) from t2 where b = 150;
 
+
+--echo #
+--echo # Bug #36473 Assertion "! is_set()" fails in
+--echo # Diagnostics_area::set_ok_status with Falcon
+--echo # Ensure that we check the return value of update_auto_increment().
+--echo #
+set @@storage_engine = falcon;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a tinyint(4) NOT NULL auto_increment, primary key (a));
+set @@sql_mode='strict_all_tables';
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+--error ER_WARN_DATA_OUT_OF_RANGE
+insert into t1 values (null);
+set @@sql_mode=default;
+set auto_increment_offset=default;
+set auto_increment_increment=default;
+
 # Final cleanup.
 DROP TABLE t1, t2;

=== modified file 'mysql-test/suite/falcon/t/falcon_year_4digit.test'
--- a/mysql-test/suite/falcon/t/falcon_year_4digit.test	2008-10-26 07:59:06 +0000
+++ b/mysql-test/suite/falcon/t/falcon_year_4digit.test	2008-10-26 08:45:22 +0000
@@ -421,4 +421,4 @@ SELECT EXTRACT(YEAR FROM '2008-07-02');
 # --- Final cleanup                                 --- #
 # ----------------------------------------------------- #
 
-DROP TABLE t1;
\ No newline at end of file
+DROP TABLE t1;

=== modified file 'mysql-test/t/binlog_format_basic.test'
--- a/mysql-test/t/binlog_format_basic.test	2008-04-10 13:14:28 +0000
+++ b/mysql-test/t/binlog_format_basic.test	2008-10-22 14:00:45 +0000
@@ -22,6 +22,13 @@
 #                                                                             #
 ###############################################################################
 
+###################################################################
+# BUG#39812: Make statement replication default for 5.1 (to match 5.0)
+# We just verify that the default binlog_format is STATEMENT in 5.1.
+# In 6.0, it should be MIXED.
+###################################################################
+SELECT @@GLOBAL.binlog_format;
+
 --echo '#---------------------BS_STVARS_002_01----------------------#'
 ####################################################################
 #   Displaying default value                                       #

=== modified file 'mysql-test/t/ps.test'
--- a/mysql-test/t/ps.test	2008-08-07 17:52:43 +0000
+++ b/mysql-test/t/ps.test	2008-10-09 10:58:51 +0000
@@ -3195,6 +3195,15 @@ SELECT @a;
 DROP PROCEDURE p1;
 DROP PROCEDURE p2;
 
+#
+# Additional cleanup.
+#
+# Delete files which were created by "select ... into outfile ...".
+#
+
+let $datadir= `select @@datadir`;
+--remove_file $datadir/test/f1.txt
+
 --echo
 --echo # End of WL#4435.
 

=== modified file 'mysql-test/t/ps_1general.test'
--- a/mysql-test/t/ps_1general.test	2008-05-21 10:17:29 +0000
+++ b/mysql-test/t/ps_1general.test	2008-10-09 10:58:51 +0000
@@ -445,6 +445,8 @@ prepare stmt1 from ' load data infile ''
 into table t1 fields terminated by ''\t'' ';
 prepare stmt1 from ' select * into outfile ''data.txt'' from t1 ';
 execute stmt1 ;
+let $datadir=`select @@datadir`;
+--remove_file $datadir/test/data.txt
 ## 
 prepare stmt1 from ' optimize table t1 ' ;
 prepare stmt1 from ' analyze table t1 ' ;

=== modified file 'mysql-test/t/query_cache.test'
--- a/mysql-test/t/query_cache.test	2008-06-17 20:04:19 +0000
+++ b/mysql-test/t/query_cache.test	2008-10-09 10:58:51 +0000
@@ -427,6 +427,9 @@ select * from t1 into outfile "query_cac
 select * from t1 limit 1 into dumpfile "query_cache.dump.file";
 show status like "Qcache_queries_in_cache";
 drop table t1;
+let $datadir=`select @@datadir`;
+--remove_file $datadir/test/query_cache.dump.file
+--remove_file $datadir/test/query_cache.out.file
 
 #
 # test of SQL_SELECT_LIMIT

=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test	2008-09-25 11:46:17 +0000
+++ b/mysql-test/t/sp.test	2008-10-16 12:39:30 +0000
@@ -8220,3 +8220,35 @@ drop procedure p;
 --echo # ------------------------------------------------------------------
 --echo # -- End of 5.1 tests
 --echo # ------------------------------------------------------------------
+
+#
+# Bug#39255: Stored procedures: crash if function references nonexistent table
+#
+
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+DROP TABLE IF EXISTS t_non_existing;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+delimiter |;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+   DECLARE v INT;
+   SELECT a INTO v FROM t_non_existing;
+   RETURN 1;
+END|
+delimiter ;|
+
+CREATE TABLE t1 (a INT) ENGINE = myisam;
+INSERT INTO t1 VALUES (1);
+
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t1 WHERE a = f1();
+
+DROP FUNCTION f1;
+DROP TABLE t1;
+
+--echo # ------------------------------------------------------------------
+--echo # -- End of 6.0 tests
+--echo # ------------------------------------------------------------------

=== modified file 'mysql-test/t/subselect3.test'
--- a/mysql-test/t/subselect3.test	2008-08-20 01:52:25 +0000
+++ b/mysql-test/t/subselect3.test	2008-10-09 10:58:51 +0000
@@ -629,6 +629,8 @@ delete from t1;
 load data infile "subselect.out.file.1" into table t1;
 select * from t1;
 drop table t1;
+let $datadir=`select @@datadir`;
+--remove_file $datadir/test/subselect.out.file.1
 
 --echo End of 5.0 tests
 

=== modified file 'mysys/my_largepage.c'
--- a/mysys/my_largepage.c	2007-10-02 07:32:33 +0000
+++ b/mysys/my_largepage.c	2008-10-08 19:44:34 +0000
@@ -128,7 +128,7 @@ uchar* my_large_malloc_int(size_t size, 
   {
     if (my_flags & MY_WME)
       fprintf(stderr,
-              "Warning: Failed to allocate %lu bytesx from HugeTLB memory."
+              "Warning: Failed to allocate %lu bytes from HugeTLB memory."
               " errno %d\n", (ulong) size, errno);
 
     DBUG_RETURN(NULL);

=== modified file 'scripts/make_win_bin_dist'
--- a/scripts/make_win_bin_dist	2008-08-25 17:29:53 +0000
+++ b/scripts/make_win_bin_dist	2008-10-21 15:45:46 +0000
@@ -145,6 +145,7 @@ mkdir $DESTDIR
 mkdir $DESTDIR/bin
 cp client/$TARGET/*.exe                                  $DESTDIR/bin/
 cp extra/$TARGET/*.exe                                   $DESTDIR/bin/
+cp storage/maria/$TARGET/*.exe                           $DESTDIR/bin/ || true
 cp storage/myisam/$TARGET/*.exe                          $DESTDIR/bin/
 # Maria engine is optional, so clients might not exist
 if ls storage/maria/$TARGET/*.exe > /dev/null 2>&1; then

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2008-05-08 16:01:15 +0000
+++ b/sql-common/client.c	2008-10-17 12:39:34 +0000
@@ -1836,6 +1836,13 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,cons
 		      db ? db : "(Null)",
 		      user ? user : "(Null)"));
 
+  /* Test whether we're already connected */
+  if (net->vio)
+  {
+    set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
+    DBUG_RETURN(0);
+  }
+
   /* Don't give sigpipe errors if the client doesn't want them */
   set_sigpipe(mysql);
   mysql->methods= &client_methods;

=== modified file 'sql/Makefile.am'
--- a/sql/Makefile.am	2008-10-01 12:09:26 +0000
+++ b/sql/Makefile.am	2008-10-10 16:23:30 +0000
@@ -31,10 +31,19 @@ EXTRA_PROGRAMS =	gen_lex_hash
 bin_PROGRAMS =		mysql_tzinfo_to_sql
 DTRACE =                @DTRACE@
 DTRACEFLAGS =           @DTRACEFLAGS@
-DTRACEFILES =           handler.o \
-			filesort.o \
-			sql_insert.o \
+DTRACEFILES =           filesort.o \
+			handler.o \
+			mysqld.o \
+			net_serv.o \
+			scheduler.o \
+			sp_head.o \
+			sql_cache.o \
+			sql_connect.o \
+			sql_cursor.o \
 			sql_delete.o \
+			sql_insert.o \
+			sql_parse.o \
+			sql_prepare.o \
 			sql_select.o \
 			sql_update.o
 
@@ -218,8 +227,10 @@ install-exec-hook:
 
 SUFFIXES : .d
 
-.d.o : $(DTRACEFILES)
+.d.o :
 	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES)
 
+probes.o : $(DTRACEFILES)
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'sql/backup/backup_info.cc'
--- a/sql/backup/backup_info.cc	2008-08-20 13:23:10 +0000
+++ b/sql/backup/backup_info.cc	2008-10-21 15:45:46 +0000
@@ -593,7 +593,7 @@ int Backup_info::add_all_dbs()
   using namespace obs;
 
   int res= 0;
-  ObjIterator *dbit= get_databases(m_ctx.m_thd);
+  Obj_iterator *dbit= get_databases(m_ctx.m_thd);
   
   if (!dbit)
   {
@@ -655,7 +655,7 @@ int Backup_info::add_all_dbs()
 
   @returns 0 on success, error code otherwise.
  */
-int Backup_info::add_objects(Db &db, const obj_type type, obs::ObjIterator &it)
+int Backup_info::add_objects(Db &db, const obj_type type, obs::Obj_iterator &it)
 {
   obs::Obj *obj;
   
@@ -680,7 +680,7 @@ int Backup_info::add_db_items(Db &db)
 
   // Add tables.
 
-  ObjIterator *it= get_db_tables(m_ctx.m_thd, &db.name()); 
+  Obj_iterator *it= get_db_tables(m_ctx.m_thd, &db.name());
 
   if (!it)
   {
@@ -922,7 +922,7 @@ int Backup_info::add_view_deps(obs::Obj 
   
   // Get an iterator to iterate over base views of the given one.
 
-  obs::ObjIterator *it= obs::get_view_base_views(m_ctx.m_thd, db_name, name);
+  obs::Obj_iterator *it= obs::get_view_base_views(m_ctx.m_thd, db_name, name);
 
   if (!it)
     return ERROR;
@@ -1285,7 +1285,7 @@ int Backup_info::add_to_dep_list(const o
   Currently only global objects handled are tablespaces and databases.
  */
 class Backup_info::Global_iterator
- : public Image_info::Iterator
+ : public backup::Image_info::Iterator
 {
   /**
     Indicates whether tablespaces or databases are being currently enumerated.
@@ -1373,7 +1373,7 @@ Backup_info::Global_iterator::next()
   This iterator uses the dependency list maintained inside Backup_info
   instance to list objects in a dependency-respecting order.
  */ 
-class Backup_info::Perdb_iterator : public Image_info::Iterator
+class Backup_info::Perdb_iterator : public backup::Image_info::Iterator
 {
   Dep_node *ptr;
 

=== modified file 'sql/backup/backup_info.h'
--- a/sql/backup/backup_info.h	2008-08-20 13:23:10 +0000
+++ b/sql/backup/backup_info.h	2008-10-17 11:28:25 +0000
@@ -64,7 +64,7 @@ class Backup_info: public backup::Image_
   Table* add_table(Db&, obs::Obj*);
 
   int add_db_items(Db&);
-  int add_objects(Db&, const obj_type, obs::ObjIterator&);
+  int add_objects(Db&, const obj_type, obs::Obj_iterator&);
   int add_view_deps(obs::Obj&);
 
   struct Dep_node;

=== modified file 'sql/backup/backup_kernel.h'
--- a/sql/backup/backup_kernel.h	2008-09-02 09:04:39 +0000
+++ b/sql/backup/backup_kernel.h	2008-10-08 10:54:19 +0000
@@ -87,6 +87,11 @@ class Backup_restore_ctx: public backup:
       ongoing backup/restore operation.  If pointer is null, no
       operation is currently running. */
   static Backup_restore_ctx *current_op;
+  /**
+     Indicates if @c run_lock mutex was initialized and thus it should
+     be properly destroyed during shutdown. @sa backup_shutdown().
+   */
+  static bool run_lock_initialized;
   static pthread_mutex_t  run_lock; ///< To guard @c current_op.
 
   /** 

=== modified file 'sql/backup/backup_test.cc'
--- a/sql/backup/backup_test.cc	2008-09-05 14:16:07 +0000
+++ b/sql/backup/backup_test.cc	2008-10-17 11:28:25 +0000
@@ -44,7 +44,7 @@ int execute_backup_test_command(THD *thd
   field_list.push_back(new Item_empty_string("serialization", 13));
   protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
 
-  //obs::ObjIterator *it= obs::get_databases(thd);
+  //obs::Obj_iterator *it= obs::get_databases(thd);
   List_iterator<LEX_STRING> it(*db_list);
   
   //if (it)
@@ -68,7 +68,7 @@ int execute_backup_test_command(THD *thd
       // List tables..
       //
 
-      obs::ObjIterator *tit= obs::get_db_tables(thd, db->get_name());
+      obs::Obj_iterator *tit= obs::get_db_tables(thd, db->get_name());
 
       if (tit)
       {
@@ -250,7 +250,7 @@ int execute_backup_test_command(THD *thd
           String user;
           String host;
           String *user_host= (String *)grant->get_name();
-          user_exists(thd, user_host);
+          check_user_existence(thd, user_host);
           protocol->store(C_STRING_WITH_LEN("GRANT"),
                           system_charset_info);
           grant->serialize(thd, &serial);

=== modified file 'sql/backup/data_backup.cc'
--- a/sql/backup/data_backup.cc	2008-09-02 07:44:28 +0000
+++ b/sql/backup/data_backup.cc	2008-09-30 07:51:48 +0000
@@ -623,7 +623,7 @@ int write_table_data(THD* thd, Backup_in
     // Report and save information about VP
 
     info.save_vp_time(vp_time);
-    info.m_ctx.report_vp_time(vp_time);
+    info.m_ctx.report_vp_time(vp_time, TRUE); // TRUE = also write to progress log
 
     if (mysql_bin_log.is_open())
     {

=== modified file 'sql/backup/error.h'
--- a/sql/backup/error.h	2008-04-08 15:32:47 +0000
+++ b/sql/backup/error.h	2008-10-03 14:15:40 +0000
@@ -3,6 +3,14 @@
 
 namespace util {
 
+/// Used to save messages pushed into the stack
+struct SAVED_MYSQL_ERROR {
+  uint code;
+  MYSQL_ERROR::enum_warning_level level;
+  char *msg;
+};
+
+
 /**
   Report error stored in MYSQL_ERROR structure to a client.
 
@@ -11,7 +19,7 @@ namespace util {
   @returns 0 if error was reported, non-zero otherwise.
  */
 inline
-int report_mysql_error(THD* thd, MYSQL_ERROR *err, int code= 0)
+int report_mysql_error(THD* thd, SAVED_MYSQL_ERROR *err, int code= 0)
 {
   DBUG_ASSERT(err);
 

=== modified file 'sql/backup/image_info.h'
--- a/sql/backup/image_info.h	2008-09-15 12:27:32 +0000
+++ b/sql/backup/image_info.h	2008-10-01 15:19:53 +0000
@@ -120,6 +120,8 @@ public: // public interface
 
    void save_binlog_pos(const ::LOG_INFO&);
 
+   time_t get_vp_time() const;
+
  protected: // internal interface
   
   // Populate the catalogue
@@ -741,6 +743,32 @@ Image_info::Ts* Image_info::get_ts(uint 
   return m_ts_map[pos];
 }
 
+inline
+time_t Image_info::get_vp_time() const
+{
+  struct tm time;
+  time_t tz_offset;
+
+  bzero(&time,sizeof(time));
+
+  // Determine system timezone offset by calculating offset of the Epoch date.
+  time.tm_year=70;
+  time.tm_mday=1;
+  tz_offset= mktime(&time);
+
+  time.tm_year= vp_time.year;
+  time.tm_mon= vp_time.mon;
+  time.tm_mday= vp_time.mday;
+  time.tm_hour= vp_time.hour;
+  time.tm_min= vp_time.min;
+  time.tm_sec= vp_time.sec;  
+
+  /*
+    Note: mktime() assumes that time is expressed as local time and vp_time is
+    in UTC. Hence we must correct the result to get it right.
+   */ 
+  return mktime(&time) - tz_offset;
+}
 
 /**
   Save time inside a @c bstream_time_t structure (helper function).

=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc	2008-09-19 09:55:21 +0000
+++ b/sql/backup/kernel.cc	2008-10-18 07:57:38 +0000
@@ -95,6 +95,7 @@
 int backup_init()
 {
   pthread_mutex_init(&Backup_restore_ctx::run_lock, MY_MUTEX_INIT_FAST);
+  Backup_restore_ctx::run_lock_initialized= TRUE;
   return 0;
 }
 
@@ -103,10 +104,18 @@ int backup_init()
   
   @note This function is called in the server shut-down sequences, just before
   it shuts-down all its plugins.
+
+  @note Due to way in which server's code is organized this function might be
+  called and should work normally even in situation when backup_init() was not
+  called at all.
  */
 void backup_shutdown()
 {
-  pthread_mutex_destroy(&Backup_restore_ctx::run_lock);
+  if (Backup_restore_ctx::run_lock_initialized)
+  {
+    pthread_mutex_destroy(&Backup_restore_ctx::run_lock);
+    Backup_restore_ctx::run_lock_initialized= FALSE;
+  }
 }
 
 /*
@@ -126,6 +135,10 @@ static int send_reply(Backup_restore_ctx
 
   @note This function sends response to the client (ok, result set or error).
 
+  @note Both BACKUP and RESTORE should perform implicit commit at the beginning
+  and at the end of execution. This is done by the parser after marking these
+  commands with appropriate flags in @c sql_command_flags[] in sql_parse.cc.
+
   @returns 0 on success, error code otherwise.
  */
 
@@ -254,7 +267,7 @@ execute_backup_command(THD *thd, LEX *le
  */
 int send_error(Backup_restore_ctx &log, int error_code, ...)
 {
-  MYSQL_ERROR *error= log.last_saved_error();
+  util::SAVED_MYSQL_ERROR *error= log.last_saved_error();
 
   if (error && !util::report_mysql_error(log.thd(), error, error_code))
   {
@@ -362,6 +375,7 @@ class Mem_allocator
 // static members
 
 Backup_restore_ctx *Backup_restore_ctx::current_op= NULL;
+bool Backup_restore_ctx::run_lock_initialized= FALSE;
 pthread_mutex_t Backup_restore_ctx::run_lock;
 
 
@@ -573,6 +587,21 @@ Backup_restore_ctx::prepare_for_backup(S
   if (!info->is_valid())
     return NULL;
 
+  /*
+    If binlog is enabled, set BSTREAM_FLAG_BINLOG in the header to indicate
+    that validity point's binlog position will be stored in the image 
+    (in its summary section).
+    
+    This is not completely safe because theoretically even if now binlog is 
+    active, it can be disabled before we reach the validity point and then we 
+    will not store binlog position even though the flag is set. To fix this 
+    problem the format of backup image must be changed (some flags must be 
+    stored in the summary section which is written at the end of backup 
+    operation).
+  */
+  if (mysql_bin_log.is_open())
+    info->flags|= BSTREAM_FLAG_BINLOG; 
+
   info->save_start_time(when);
   m_catalog= info;
   m_state= PREPARED_FOR_BACKUP;
@@ -791,17 +820,6 @@ int Backup_restore_ctx::close()
 
   time_t when= my_time(0);
 
-  // If auto commit is turned off, be sure to commit the transaction
-  /* 
-    Note: this code needs to be refactored (see BUG#38261). When refactoring
-    make sure that errors are detected and reported.
-  */
-  if (m_thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
-  {
-    trans_commit_stmt(m_thd);
-    trans_commit_implicit(m_thd);
-  }
-
   // unlock tables if they are still locked
 
   // FIXME: detect errors if reported.
@@ -827,18 +845,6 @@ int Backup_restore_ctx::close()
   if (m_catalog)
     m_catalog->save_end_time(when); // Note: no errors.
 
-  // destroy backup stream's memory allocator (this frees memory)
-
-  delete mem_alloc;
-  mem_alloc= NULL;
-  
-  // deregister this operation if it was running
-  pthread_mutex_lock(&run_lock);
-  if (current_op == this) {
-    current_op= NULL;
-  }
-  pthread_mutex_unlock(&run_lock);
-
   /* 
     Remove the location, if asked for.
     
@@ -865,6 +871,24 @@ int Backup_restore_ctx::close()
   if (!m_error)
     report_stop(when, TRUE);
 
+  /* 
+    Destroy backup stream's memory allocator (this frees memory)
+  
+    Note that from now on data stored in this object might be corrupted. For 
+    example the binlog file name is a string stored in memory allocated by
+    the allocator which will be freed now.
+  */
+  
+  delete mem_alloc;
+  mem_alloc= NULL;
+  
+  // deregister this operation if it was running
+  pthread_mutex_lock(&run_lock);
+  if (current_op == this) {
+    current_op= NULL;
+  }
+  pthread_mutex_unlock(&run_lock);
+
   m_state= CLOSED;
   return m_error;
 }
@@ -1117,6 +1141,15 @@ int Backup_restore_ctx::do_restore()
   // FIXME: error logging.
   m_thd->main_da.reset_diagnostics_area();
 
+  /*
+    Report validity point time and binlog position stored in the backup image
+    (in the summary section).
+   */ 
+
+  report_vp_time(info.get_vp_time(), FALSE); // FALSE = do not write to progress log
+  if (info.flags & BSTREAM_FLAG_BINLOG)
+    report_binlog_pos(info.binlog_pos);
+
   // FIXME: detect errors if reported.
   // FIXME: error logging.
   report_stats_post(info);
@@ -1801,8 +1834,8 @@ int bcat_create_item(st_bstream_image_he
     {
       DBUG_PRINT("restore",(" tablespace has changed on the server - aborting"));
       info->m_ctx.fatal_error(ER_BACKUP_TS_CHANGE, desc,
-                              obs::describe_tablespace(sobj)->ptr(),
-                              obs::describe_tablespace(ts)->ptr());
+                              obs::get_tablespace_description(sobj)->ptr(),
+                              obs::get_tablespace_description(ts)->ptr());
       return BSTREAM_ERROR;
     }
   }
@@ -1822,7 +1855,7 @@ int bcat_create_item(st_bstream_image_he
             error handling work in WL#4384 with possible implementation
             via a related bug report.
     */
-    if (!obs::user_exists(thd, sobj->get_name()))
+    if (!obs::check_user_existence(thd, sobj->get_name()))
     {
       info->m_ctx.write_message(log_level::WARNING, 
                                 ER(ER_BACKUP_GRANT_SKIPPED),

=== modified file 'sql/backup/logger.cc'
--- a/sql/backup/logger.cc	2008-09-08 11:05:26 +0000
+++ b/sql/backup/logger.cc	2008-10-08 10:54:19 +0000
@@ -46,8 +46,12 @@ int Logger::write_message(log_level::val
    switch (level) {
    case log_level::ERROR:
      if (m_save_errors)
-       errors.push_front(new MYSQL_ERROR(::current_thd, error_code,
-                                         MYSQL_ERROR::WARN_LEVEL_ERROR, msg));
+     {
+       error.code= error_code;
+       error.level= MYSQL_ERROR::WARN_LEVEL_ERROR;
+       error.msg= sql_strdup(msg);
+     }
+
      sql_print_error(out);
      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                          error_code, msg);

=== modified file 'sql/backup/logger.h'
--- a/sql/backup/logger.h	2008-08-28 15:13:31 +0000
+++ b/sql/backup/logger.h	2008-10-18 07:57:38 +0000
@@ -54,7 +54,7 @@ class Logger
    void report_start(time_t);
    void report_stop(time_t, bool);
    void report_state(enum_backup_state);
-   void report_vp_time(time_t);
+   void report_vp_time(time_t, bool);
    void report_binlog_pos(const st_bstream_binlog_pos&);
    void report_driver(const char *driver);
    void report_stats_pre(const Image_info&);
@@ -69,7 +69,7 @@ class Logger
    void save_errors();
    void stop_save_errors();
    void clear_saved_errors();
-   MYSQL_ERROR *last_saved_error();
+   util::SAVED_MYSQL_ERROR *last_saved_error();
 
  protected:
 
@@ -81,8 +81,7 @@ class Logger
   int write_message(log_level::value level , int error_code, const char *msg);
 
  private:
-
-  List<MYSQL_ERROR> errors;  ///< Used to store saved errors.
+  util::SAVED_MYSQL_ERROR error;   ///< Used to store saved errors.
   bool m_save_errors;        ///< Flag telling if errors should be saved.
   Backup_log *backup_log;    ///< Backup log interface class.
 };
@@ -172,15 +171,15 @@ void Logger::stop_save_errors()
 /// Delete all saved errors to free resources.
 inline
 void Logger::clear_saved_errors()
-{ 
-  errors.delete_elements();
+{
+  memset(&error, 0, sizeof(error));
 }
 
 /// Return a pointer to most recent saved error.
 inline
-MYSQL_ERROR *Logger::last_saved_error()
+util::SAVED_MYSQL_ERROR *Logger::last_saved_error()
 { 
-  return errors.is_empty() ? NULL : errors.head();
+  return error.code ? &error : NULL;
 }
 
 /// Report start of an operation.
@@ -237,13 +236,19 @@ void Logger::report_state(enum_backup_st
   backup_log->state(state);
 }
 
-/// Report validity point creation time.
+/** 
+  Report validity point creation time.
+
+  @param[IN] when   the time of validity point
+  @param[IN] report determines if VP time should be also reported in the
+                    backup_progress log
+*/
 inline
-void Logger::report_vp_time(time_t when)
+void Logger::report_vp_time(time_t when, bool report)
 {
   DBUG_ASSERT(m_state == RUNNING);
   DBUG_ASSERT(backup_log);
-  backup_log->vp_time(when);
+  backup_log->vp_time(when, report);
 }
 
 /** 

=== modified file 'sql/backup/stream_v1.c'
--- a/sql/backup/stream_v1.c	2008-09-09 08:19:21 +0000
+++ b/sql/backup/stream_v1.c	2008-09-30 08:08:16 +0000
@@ -1813,7 +1813,7 @@ int bstream_rd_data_chunk(backup_stream 
         envelope= buf;
       }
 
-      // update chunk->data to point to the new buffer
+ /* update chunk->data to point to the new buffer */
       chunk->data= *buf;
 
       /* update to_read blob to indicate free space left */
@@ -1969,10 +1969,10 @@ int bstream_rd_int4(backup_stream *s, un
   if (ret == BSTREAM_ERROR)
     return BSTREAM_ERROR;
 
-  *x = buf[0];
-  *x += (buf[1] << 8);
-  *x += (buf[1] << 2*8);
-  *x += (buf[1] << 3*8);
+  *x = (unsigned long int)buf[0];
+  *x += ((unsigned long int)buf[1] << 8);
+  *x += ((unsigned long int)buf[2] << 2*8);
+  *x += ((unsigned long int)buf[3] << 3*8);
 
   return ret;
 }

=== modified file 'sql/backup/stream_v1_transport.c'
--- a/sql/backup/stream_v1_transport.c	2008-09-11 09:47:53 +0000
+++ b/sql/backup/stream_v1_transport.c	2008-09-16 16:09:18 +0000
@@ -289,12 +289,12 @@ int read_fragment_header(byte **header)
 int as_write_all(struct st_abstract_stream *s, bstream_blob b, bstream_blob env)
 {
   int ret= BSTREAM_OK;
-
   while ((ret == BSTREAM_OK) && (b.begin < b.end))
    ret= as_write(s,&b,env);
 
   return ret;
-};
+}
+
 
 /** Fill blob with bytes from stream */
 int as_read_all(struct st_abstract_stream *s, bstream_blob b, bstream_blob env)
@@ -305,7 +305,7 @@ int as_read_all(struct st_abstract_strea
    ret= as_read(s,&b,env);
 
   return ret;
-};
+}
 
 
 /*************************************************************************
@@ -775,7 +775,7 @@ int load_next_fragment(backup_stream *s)
 
   s->state= NORMAL; /* default, unless changed below */
 
-  ret= read_fragment_header(&s->buf.header);    // Never errors.
+  ret= read_fragment_header(&s->buf.header);    /* Never errors. */
 
   /*
     If buf.header was not moved, it means that the fragment extends to
@@ -1128,7 +1128,7 @@ int bstream_write_part(backup_stream *s,
     If nothing else worked, we just append the data to the output buffer
     and return.
    */
-  append_to_buffer(s,data);  // Never errors.
+  append_to_buffer(s,data);  /* Never errors. */
   return BSTREAM_OK;
 }
 
@@ -1638,7 +1638,7 @@ int bstream_next_chunk(backup_stream *s)
   ASSERT(s->buf.pos > s->buf.header);
 
   ret= load_next_fragment(s);
-  if (ret == BSTREAM_ERROR)     // To avoid invariant check below.
+  if (ret == BSTREAM_ERROR)     /* To avoid invariant check below. */
     return BSTREAM_ERROR;
   /* if we hit EOC marker here, we treat it as empty chunk */
   if (ret == BSTREAM_EOC)

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2008-07-23 09:43:50 +0000
+++ b/sql/filesort.cc	2008-10-10 16:23:30 +0000
@@ -121,7 +121,7 @@ ha_rows filesort(THD *thd, TABLE *table,
   TABLE_LIST *tab= table->pos_in_table_list;
   Item_subselect *subselect= tab ? tab->containing_subselect() : 0;
 
-  MYSQL_FILESORT_START();
+  MYSQL_FILESORT_START(table->s->db.str, table->s->table_name.str);
 
   /*
    Release InnoDB's adaptive hash index latch (if holding) before
@@ -333,8 +333,10 @@ ha_rows filesort(THD *thd, TABLE *table,
 #endif
   memcpy(&table->sort, &table_sort, sizeof(FILESORT_INFO));
   DBUG_PRINT("exit",("records: %ld", (long) records));
-  MYSQL_FILESORT_END();
-  DBUG_RETURN(error ? HA_POS_ERROR : records);
+  if (error)
+    records= HA_POS_ERROR;
+  MYSQL_FILESORT_DONE(error, records);
+  DBUG_RETURN(records);
 } /* filesort */
 
 

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2008-10-08 13:55:20 +0000
+++ b/sql/handler.cc	2008-10-17 17:47:16 +0000
@@ -5270,13 +5270,51 @@ int handler::ha_external_lock(THD *thd, 
   */
   DBUG_ASSERT(next_insert_id == 0);
 
+  if (MYSQL_HANDLER_RDLOCK_START_ENABLED() ||
+      MYSQL_HANDLER_WRLOCK_START_ENABLED() ||
+      MYSQL_HANDLER_UNLOCK_START_ENABLED())
+  {
+    if (lock_type == F_RDLCK)
+    {
+      MYSQL_HANDLER_RDLOCK_START(table_share->db.str,
+                                 table_share->table_name.str);
+    }
+    else if (lock_type == F_WRLCK)
+    {
+      MYSQL_HANDLER_WRLOCK_START(table_share->db.str,
+                                 table_share->table_name.str);
+    }
+    else if (lock_type == F_UNLCK)
+    {
+      MYSQL_HANDLER_UNLOCK_START(table_share->db.str,
+                                 table_share->table_name.str);
+    }
+  }
+
   /*
     We cache the table flags if the locking succeeded. Otherwise, we
     keep them as they were when they were fetched in ha_open().
   */
-  MYSQL_EXTERNAL_LOCK(lock_type);
-
   int error= external_lock(thd, lock_type);
+
+  if (MYSQL_HANDLER_RDLOCK_DONE_ENABLED() ||
+      MYSQL_HANDLER_WRLOCK_DONE_ENABLED() ||
+      MYSQL_HANDLER_UNLOCK_DONE_ENABLED())
+  {
+    if (lock_type == F_RDLCK)
+    {
+      MYSQL_HANDLER_RDLOCK_DONE(error);
+    }
+    else if (lock_type == F_WRLCK)
+    {
+      MYSQL_HANDLER_WRLOCK_DONE(error);
+    }
+    else if (lock_type == F_UNLCK)
+    {
+      MYSQL_HANDLER_UNLOCK_DONE(error);
+    }
+  }
+  
   if (error == 0)
     cached_table_flags= table_flags();
   DBUG_RETURN(error);
@@ -5310,15 +5348,16 @@ int handler::ha_write_row(uchar *buf)
   int error;
   Log_func *log_func= Write_rows_log_event::binlog_row_logging_function;
   DBUG_ENTER("handler::ha_write_row");
-  MYSQL_INSERT_ROW_START();
 
+  MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
-
-  if (unlikely(error= write_row(buf)))
+  error= write_row(buf);
+  MYSQL_INSERT_ROW_DONE(error);
+  
+  if (unlikely(error != 0))
     DBUG_RETURN(error);
   if (unlikely(error= binlog_log_row(table, 0, buf, log_func)))
     DBUG_RETURN(error); /* purecov: inspected */
-  MYSQL_INSERT_ROW_END();
   DBUG_RETURN(0);
 }
 
@@ -5334,9 +5373,12 @@ int handler::ha_update_row(const uchar *
    */
   DBUG_ASSERT(new_data == table->record[0]);
 
+  MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
+  error= update_row(old_data, new_data);
+  MYSQL_UPDATE_ROW_DONE(error);
 
-  if (unlikely(error= update_row(old_data, new_data)))
+  if (unlikely(error != 0))
     return error;
   if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func)))
     return error;
@@ -5348,9 +5390,12 @@ int handler::ha_delete_row(const uchar *
   int error;
   Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function;
 
+  MYSQL_DELETE_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
+  error= delete_row(buf);
+  MYSQL_DELETE_ROW_DONE(error);
 
-  if (unlikely(error= delete_row(buf)))
+  if (unlikely(error != 0))
     return error;
   if (unlikely(error= binlog_log_row(table, buf, 0, log_func)))
     return error;

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2008-10-08 11:46:49 +0000
+++ b/sql/log.cc	2008-10-21 12:38:13 +0000
@@ -3339,6 +3339,8 @@ bool MYSQL_BACKUP_LOG::write(THD *thd, s
       goto err;
     if (write_str(user))
       goto err;
+    if (write_str(history_data->backup_file))
+      goto err;
     if (write_str(history_data->user_comment))
       goto err;
     if (write_str(history_data->command))
@@ -3474,8 +3476,17 @@ my_bool MYSQL_BACKUP_LOG::check_backup_l
   alloc_mdl_locks(&tables, thd->mem_root);
   if (simple_open_n_lock_tables(thd, &tables))
   {
+    /*
+      Here we wish to change the error that is generated by the open method,
+      "table does not exist" to a specific error message for missing
+      backup logs. In this case, we reset the old error and issue the new one.
+    */
     ret= TRUE;
     sql_print_error(ER(ER_BACKUP_PROGRESS_TABLES));
+    thd->main_da.reset_diagnostics_area();
+    thd->main_da.set_error_status(thd, 
+                                  ER_BACKUP_PROGRESS_TABLES, 
+                                  ER(ER_BACKUP_PROGRESS_TABLES));
     DBUG_RETURN(ret);
   }
   close_thread_tables(thd);
@@ -3487,8 +3498,17 @@ my_bool MYSQL_BACKUP_LOG::check_backup_l
   alloc_mdl_locks(&tables, thd->mem_root);
   if (simple_open_n_lock_tables(thd, &tables))
   {
+    /*
+      Here we wish to change the error that is generated by the open method,
+      "table does not exist" to a specific error message for missing
+      backup logs. In this case, we reset the old error and issue the new one.
+    */
     ret= TRUE;
     sql_print_error(ER(ER_BACKUP_PROGRESS_TABLES));
+    thd->main_da.reset_diagnostics_area();
+    thd->main_da.set_error_status(thd, 
+                                  ER_BACKUP_PROGRESS_TABLES, 
+                                  ER(ER_BACKUP_PROGRESS_TABLES));
     DBUG_RETURN(ret);
   }
   close_thread_tables(thd);
@@ -5111,7 +5131,7 @@ THD::binlog_set_pending_rows_event(Rows_
 int
 MYSQL_BIN_LOG::remove_pending_rows_event(THD *thd)
 {
-  DBUG_ENTER(__FUNCTION__);
+  DBUG_ENTER("MYSQL_BIN_LOG::remove_pending_rows_event");
 
   binlog_trx_data *const trx_data=
     (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2008-10-13 14:10:00 +0000
+++ b/sql/mysql_priv.h	2008-10-20 12:25:30 +0000
@@ -46,6 +46,11 @@
 
 #ifdef HAVE_DTRACE
 #define _DTRACE_VERSION 1
+#else
+#undef _DTRACE_VERSION
+#endif
+#ifdef EMBEDDED_LIBRARY
+#undef _DTRACE_VERSION
 #endif
 #include "probes.h"
 
@@ -521,7 +526,7 @@ enum open_table_mode
   Dont report errors for individual rows,
   But just report error on commit (or read ofcourse)
 */
-#define OPTION_ALLOW_BATCH              (ULL(1) << 33) // THD, intern (slave)
+#define OPTION_ALLOW_BATCH              (ULL(1) << 34) // THD, intern (slave)
 
 /**
   Maximum length of time zone name that we support

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2008-10-13 14:10:00 +0000
+++ b/sql/mysqld.cc	2008-10-23 11:57:08 +0000
@@ -1918,6 +1918,7 @@ void close_connection(THD *thd, uint err
   }
   if (lock)
     (void) pthread_mutex_unlock(&LOCK_thread_count);
+  MYSQL_CONNECTION_DONE((int) errcode, thd->thread_id);
   DBUG_VOID_RETURN;
 }
 #endif /* EMBEDDED_LIBRARY */
@@ -4026,12 +4027,12 @@ with --log-bin instead.");
     }
     else
     {
-      global_system_variables.binlog_format= BINLOG_FORMAT_STMT;
+      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
     }
   }
   else
     if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
-      global_system_variables.binlog_format= BINLOG_FORMAT_STMT;
+      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
     else
     {
       DBUG_ASSERT(global_system_variables.binlog_format != BINLOG_FORMAT_UNSPEC);
@@ -5996,10 +5997,6 @@ struct my_option my_long_options[] =
    "Set the default storage engine (table type) for tables.",
    (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"default-table-type", OPT_STORAGE_ENGINE,
-   "(deprecated) Use --default-storage-engine.",
-   (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str,
-   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.",
    (uchar**) &default_tz_name, (uchar**) &default_tz_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },

=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc	2008-05-29 15:44:11 +0000
+++ b/sql/net_serv.cc	2008-10-02 12:08:09 +0000
@@ -58,6 +58,13 @@
 #define MYSQL_CLIENT
 #endif /*EMBEDDED_LIBRARY */
 
+#ifdef HAVE_DTRACE
+/* Limit DTrace probes to server code for now */
+#ifndef MYSQL_SERVER
+#undef _DTRACE_VERSION
+#endif
+#endif
+#include "probes.h"
 
 /*
   The following handles the differences when this is linked between the
@@ -364,8 +371,12 @@ my_bool
 my_net_write(NET *net,const uchar *packet,size_t len)
 {
   uchar buff[NET_HEADER_SIZE];
+  my_bool rc;
   if (unlikely(!net->vio)) /* nowhere to write */
     return 0;
+
+  MYSQL_NET_WRITE_START(len);
+
   /*
     Big packets are handled by splitting them in packets of MAX_PACKET_LENGTH
     length. The last packet is always a packet that is < MAX_PACKET_LENGTH.
@@ -378,7 +389,10 @@ my_net_write(NET *net,const uchar *packe
     buff[3]= (uchar) net->pkt_nr++;
     if (net_write_buff(net, buff, NET_HEADER_SIZE) ||
 	net_write_buff(net, packet, z_size))
+    {
+      MYSQL_NET_WRITE_DONE(1);
       return 1;
+    }
     packet += z_size;
     len-=     z_size;
   }
@@ -386,11 +400,16 @@ my_net_write(NET *net,const uchar *packe
   int3store(buff,len);
   buff[3]= (uchar) net->pkt_nr++;
   if (net_write_buff(net, buff, NET_HEADER_SIZE))
+  {
+    MYSQL_NET_WRITE_DONE(1);
     return 1;
+  }
 #ifndef DEBUG_DATA_PACKETS
   DBUG_DUMP("packet_header", buff, NET_HEADER_SIZE);
 #endif
-  return test(net_write_buff(net,packet,len));
+  rc= test(net_write_buff(net,packet,len));
+  MYSQL_NET_WRITE_DONE(rc);
+  return rc;
 }
 
 /**
@@ -428,9 +447,12 @@ net_write_command(NET *net,uchar command
   ulong length=len+1+head_len;			/* 1 extra byte for command */
   uchar buff[NET_HEADER_SIZE+1];
   uint header_size=NET_HEADER_SIZE+1;
+  my_bool rc;
   DBUG_ENTER("net_write_command");
   DBUG_PRINT("enter",("length: %lu", (ulong) len));
 
+  MYSQL_NET_WRITE_START(length);
+  
   buff[4]=command;				/* For first packet */
 
   if (length >= MAX_PACKET_LENGTH)
@@ -444,7 +466,10 @@ net_write_command(NET *net,uchar command
       if (net_write_buff(net, buff, header_size) ||
 	  net_write_buff(net, header, head_len) ||
 	  net_write_buff(net, packet, len))
-	DBUG_RETURN(1);
+      {
+        MYSQL_NET_WRITE_DONE(1);
+        DBUG_RETURN(1);
+      }
       packet+= len;
       length-= MAX_PACKET_LENGTH;
       len= MAX_PACKET_LENGTH;
@@ -455,9 +480,11 @@ net_write_command(NET *net,uchar command
   }
   int3store(buff,length);
   buff[3]= (uchar) net->pkt_nr++;
-  DBUG_RETURN(test(net_write_buff(net, buff, header_size) ||
-                   (head_len && net_write_buff(net, header, head_len)) ||
-                   net_write_buff(net, packet, len) || net_flush(net)));
+  rc= test(net_write_buff(net, buff, header_size) ||
+           (head_len && net_write_buff(net, header, head_len)) ||
+           net_write_buff(net, packet, len) || net_flush(net));
+  MYSQL_NET_WRITE_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 /**
@@ -985,6 +1012,8 @@ my_net_read(NET *net)
 {
   size_t len, complen;
 
+  MYSQL_NET_READ_START();
+  
 #ifdef HAVE_COMPRESS
   if (!net->compress)
   {
@@ -1008,6 +1037,7 @@ my_net_read(NET *net)
     net->read_pos = net->buff + net->where_b;
     if (len != packet_error)
       net->read_pos[len]=0;		/* Safeguard for mysql_use_result */
+    MYSQL_NET_READ_DONE(0, len);
     return len;
 #ifdef HAVE_COMPRESS
   }
@@ -1091,7 +1121,10 @@ my_net_read(NET *net)
 
       net->where_b=buf_length;
       if ((packet_len = my_real_read(net,&complen)) == packet_error)
+      {
+        MYSQL_NET_READ_DONE(1, 0);
 	return packet_error;
+      }
       if (my_uncompress(net->buff + net->where_b, packet_len,
 			&complen))
       {
@@ -1100,6 +1133,7 @@ my_net_read(NET *net)
 #ifdef MYSQL_SERVER
 	my_error(ER_NET_UNCOMPRESS_ERROR, MYF(0));
 #endif
+        MYSQL_NET_READ_DONE(1, 0);
 	return packet_error;
       }
       buf_length+= complen;
@@ -1114,6 +1148,7 @@ my_net_read(NET *net)
     net->read_pos[len]=0;		/* Safeguard for mysql_use_result */
   }
 #endif /* HAVE_COMPRESS */
+  MYSQL_NET_READ_DONE(0, len);
   return len;
 }
 

=== modified file 'sql/probes.d'
--- a/sql/probes.d	2007-09-21 07:09:31 +0000
+++ b/sql/probes.d	2008-10-02 12:08:09 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2005 MySQL AB
+/* Copyright (C) 2008 MySQL AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -13,18 +13,142 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
 
+/*
+  The actual probe names in DTrace scripts will replace '__' by '-'. Thus
+  insert__row__start will be insert-row-start.
+
+  Recommendations for adding new probes:
+
+  - each probe should have the minimal set of arguments required to
+  unambiguously identify the context in which the probe fires. Redundant
+  probes (i.e. the ones that can be obtained in user scripts from previous
+  probes' arguments or otherwise) may be added for convenience.
+
+  - try to avoid computationally expensive probe arguments. If impossible,
+  use *_ENABLED() macros to check if the probe is activated before
+  performing expensive calculations for a probe argument.
+
+  - all *-done probes should have a status argument wherever applicable to make
+  it possible for user scripts to figure out whether the completed operation
+  was successful or not.
+  
+  - for all status arguments, a non-zero value should be returned on error or
+  failure, 0 should be returned on success.
+*/
+
 provider mysql {
-probe external_lock(int);
-probe insert_row_start();
-probe insert_row_end();
-probe filesort_start();
-probe filesort_end();
-probe delete_start();
-probe delete_end();
-probe insert_start();
-probe insert_end();
-probe select_start();
-probe select_end();
-probe update_start();
-probe update_end();
+  
+  /* The following ones fire when creating or closing a client connection */
+  probe connection__start(unsigned long conn_id, char *user, char *host);
+  probe connection__done(int status, unsigned long conn_id);
+
+  /*
+    Fire at the start/end of any client command processing (including SQL
+    queries).
+  */
+  probe command__start(unsigned long conn_id, int command,
+                       char *user, char *host);
+  probe command__done(int status);
+  
+  /*
+    The following probes fire at the start/end of any SQL query processing,
+    respectively.
+
+    query_start() has a lot of parameters that can be used to pick up
+    parameters for a lot of other probes here.  For simplicity reasons we also
+    add the query string to most other DTrace probes as well. Hostname is
+    either the hostname or the IP address of the MySQL Client.
+  */
+  probe query__start(char *query,
+                     unsigned long conn_id,
+                     char *db_name,
+                     char *user,
+                     char *host);
+  probe query__done(int status); 
+
+  /* Fire at the start/end of SQL query parsing */
+  probe query__parse__start(char *query);
+  probe query__parse__done(int status);
+
+  /* Track whether the query hits the query cache or not */
+  probe query__cache__hit(char *query, unsigned long rows);
+  probe query__cache__miss(char *query);
+
+  /*
+    This probe fires when the actual query execution starts, i.e. after
+    parsing and checking the query cache, but before privilege checks,
+    optimizing, etc.
+
+    Query means also all independent queries of a stored procedure and prepared
+    statements. Also the stored procedure itself is a query.
+
+    exec_type is:
+    0:           Executed query from sql_parse, top-level query (sql_parse.cc)
+    1:           Executed prepared statement (sql_prepare.cc)
+    2:           Executed cursor statement (sql_cursor.cc)
+    3:           Executed query in stored procedure (sp_head.cc)
+  */
+  probe query__exec__start(char *query,
+                           unsigned long connid,
+                           char *db_name,
+                           char *user,
+                           char *host,
+                           int exec_type);
+  probe query__exec__done(int status);
+
+  /* These probes fire when performing write operations towards any handler */
+  probe insert__row__start(char *db, char *table);
+  probe insert__row__done(int status);
+  probe update__row__start(char *db, char *table);
+  probe update__row__done(int status);
+  probe delete__row__start(char *db, char *table);
+  probe delete__row__done(int status);
+
+  /*
+    These probes fire when calling external_lock for any handler
+    depending on the lock type being acquired or released.
+  */
+  probe handler__rdlock__start(char *db, char *table);
+  probe handler__wrlock__start(char *db, char *table);
+  probe handler__unlock__start(char *db, char *table);
+  probe handler__rdlock__done(int status);
+  probe handler__wrlock__done(int status);
+  probe handler__unlock__done(int status);
+  
+  /*
+    These probes fire when a filesort activity happens in a query.
+  */
+  probe filesort__start(char *db, char *table);
+  probe filesort__done(int status, unsigned long rows);
+  /*
+    The query types SELECT, INSERT, INSERT AS SELECT, UPDATE, UPDATE with
+    multiple tables, DELETE, DELETE with multiple tables are all probed.
+    The start probe always contains the query text.
+  */
+  probe select__start(char *query);
+  probe select__done(int status, unsigned long rows);
+  probe insert__start(char *query);
+  probe insert__done(int status, unsigned long rows);
+  probe insert__select__start(char *query);
+  probe insert__select__done(int status, unsigned long rows);
+  probe update__start(char *query);
+  probe update__done(int status,
+                     unsigned long rowsmatches, unsigned long rowschanged);
+  probe multi__update__start(char *query);
+  probe multi__update__done(int status,
+                            unsigned long rowsmatches, unsigned long rowschanged);
+  probe delete__start(char *query);
+  probe delete__done(int status, unsigned long rows);
+  probe multi__delete__start(char *query);
+  probe multi__delete__done(int status, unsigned long rows);
+
+  /*
+    These probes can be used to measure the time waiting for network traffic
+    or identify network-related problems.
+  */
+  probe net__read__start();
+  probe net__read__done(int status, unsigned long bytes);
+  probe net__write__start(unsigned long bytes);
+  probe net__write__done(int status);
+
 };

=== modified file 'sql/probes.h'
--- a/sql/probes.h	2008-07-08 13:49:57 +0000
+++ b/sql/probes.h	2008-10-10 16:23:30 +0000
@@ -13,114 +13,362 @@ extern "C" {
 
 #if _DTRACE_VERSION && defined(HAVE_DTRACE)
 
-#define	MYSQL_DELETE_END() \
-	__dtrace_mysql___delete_end()
-#define	MYSQL_DELETE_END_ENABLED() \
-	__dtraceenabled_mysql___delete_end()
-#define	MYSQL_DELETE_START() \
-	__dtrace_mysql___delete_start()
+#define	MYSQL_COMMAND_DONE(arg0) \
+	__dtrace_mysql___command__done(arg0)
+#define	MYSQL_COMMAND_DONE_ENABLED() \
+	__dtraceenabled_mysql___command__done()
+#define	MYSQL_COMMAND_START(arg0, arg1, arg2, arg3) \
+	__dtrace_mysql___command__start(arg0, arg1, arg2, arg3)
+#define	MYSQL_COMMAND_START_ENABLED() \
+	__dtraceenabled_mysql___command__start()
+#define	MYSQL_CONNECTION_DONE(arg0, arg1) \
+	__dtrace_mysql___connection__done(arg0, arg1)
+#define	MYSQL_CONNECTION_DONE_ENABLED() \
+	__dtraceenabled_mysql___connection__done()
+#define	MYSQL_CONNECTION_START(arg0, arg1, arg2) \
+	__dtrace_mysql___connection__start(arg0, arg1, arg2)
+#define	MYSQL_CONNECTION_START_ENABLED() \
+	__dtraceenabled_mysql___connection__start()
+#define	MYSQL_DELETE_DONE(arg0, arg1) \
+	__dtrace_mysql___delete__done(arg0, arg1)
+#define	MYSQL_DELETE_DONE_ENABLED() \
+	__dtraceenabled_mysql___delete__done()
+#define	MYSQL_DELETE_ROW_DONE(arg0) \
+	__dtrace_mysql___delete__row__done(arg0)
+#define	MYSQL_DELETE_ROW_DONE_ENABLED() \
+	__dtraceenabled_mysql___delete__row__done()
+#define	MYSQL_DELETE_ROW_START(arg0, arg1) \
+	__dtrace_mysql___delete__row__start(arg0, arg1)
+#define	MYSQL_DELETE_ROW_START_ENABLED() \
+	__dtraceenabled_mysql___delete__row__start()
+#define	MYSQL_DELETE_START(arg0) \
+	__dtrace_mysql___delete__start(arg0)
 #define	MYSQL_DELETE_START_ENABLED() \
-	__dtraceenabled_mysql___delete_start()
-#define	MYSQL_EXTERNAL_LOCK(arg0) \
-	__dtrace_mysql___external_lock(arg0)
-#define	MYSQL_EXTERNAL_LOCK_ENABLED() \
-	__dtraceenabled_mysql___external_lock()
-#define	MYSQL_FILESORT_END() \
-	__dtrace_mysql___filesort_end()
-#define	MYSQL_FILESORT_END_ENABLED() \
-	__dtraceenabled_mysql___filesort_end()
-#define	MYSQL_FILESORT_START() \
-	__dtrace_mysql___filesort_start()
+	__dtraceenabled_mysql___delete__start()
+#define	MYSQL_FILESORT_DONE(arg0, arg1) \
+	__dtrace_mysql___filesort__done(arg0, arg1)
+#define	MYSQL_FILESORT_DONE_ENABLED() \
+	__dtraceenabled_mysql___filesort__done()
+#define	MYSQL_FILESORT_START(arg0, arg1) \
+	__dtrace_mysql___filesort__start(arg0, arg1)
 #define	MYSQL_FILESORT_START_ENABLED() \
-	__dtraceenabled_mysql___filesort_start()
-#define	MYSQL_INSERT_END() \
-	__dtrace_mysql___insert_end()
-#define	MYSQL_INSERT_END_ENABLED() \
-	__dtraceenabled_mysql___insert_end()
-#define	MYSQL_INSERT_ROW_END() \
-	__dtrace_mysql___insert_row_end()
-#define	MYSQL_INSERT_ROW_END_ENABLED() \
-	__dtraceenabled_mysql___insert_row_end()
-#define	MYSQL_INSERT_ROW_START() \
-	__dtrace_mysql___insert_row_start()
+	__dtraceenabled_mysql___filesort__start()
+#define	MYSQL_HANDLER_RDLOCK_DONE(arg0) \
+	__dtrace_mysql___handler__rdlock__done(arg0)
+#define	MYSQL_HANDLER_RDLOCK_DONE_ENABLED() \
+	__dtraceenabled_mysql___handler__rdlock__done()
+#define	MYSQL_HANDLER_RDLOCK_START(arg0, arg1) \
+	__dtrace_mysql___handler__rdlock__start(arg0, arg1)
+#define	MYSQL_HANDLER_RDLOCK_START_ENABLED() \
+	__dtraceenabled_mysql___handler__rdlock__start()
+#define	MYSQL_HANDLER_UNLOCK_DONE(arg0) \
+	__dtrace_mysql___handler__unlock__done(arg0)
+#define	MYSQL_HANDLER_UNLOCK_DONE_ENABLED() \
+	__dtraceenabled_mysql___handler__unlock__done()
+#define	MYSQL_HANDLER_UNLOCK_START(arg0, arg1) \
+	__dtrace_mysql___handler__unlock__start(arg0, arg1)
+#define	MYSQL_HANDLER_UNLOCK_START_ENABLED() \
+	__dtraceenabled_mysql___handler__unlock__start()
+#define	MYSQL_HANDLER_WRLOCK_DONE(arg0) \
+	__dtrace_mysql___handler__wrlock__done(arg0)
+#define	MYSQL_HANDLER_WRLOCK_DONE_ENABLED() \
+	__dtraceenabled_mysql___handler__wrlock__done()
+#define	MYSQL_HANDLER_WRLOCK_START(arg0, arg1) \
+	__dtrace_mysql___handler__wrlock__start(arg0, arg1)
+#define	MYSQL_HANDLER_WRLOCK_START_ENABLED() \
+	__dtraceenabled_mysql___handler__wrlock__start()
+#define	MYSQL_INSERT_DONE(arg0, arg1) \
+	__dtrace_mysql___insert__done(arg0, arg1)
+#define	MYSQL_INSERT_DONE_ENABLED() \
+	__dtraceenabled_mysql___insert__done()
+#define	MYSQL_INSERT_ROW_DONE(arg0) \
+	__dtrace_mysql___insert__row__done(arg0)
+#define	MYSQL_INSERT_ROW_DONE_ENABLED() \
+	__dtraceenabled_mysql___insert__row__done()
+#define	MYSQL_INSERT_ROW_START(arg0, arg1) \
+	__dtrace_mysql___insert__row__start(arg0, arg1)
 #define	MYSQL_INSERT_ROW_START_ENABLED() \
-	__dtraceenabled_mysql___insert_row_start()
-#define	MYSQL_INSERT_START() \
-	__dtrace_mysql___insert_start()
+	__dtraceenabled_mysql___insert__row__start()
+#define	MYSQL_INSERT_SELECT_DONE(arg0, arg1) \
+	__dtrace_mysql___insert__select__done(arg0, arg1)
+#define	MYSQL_INSERT_SELECT_DONE_ENABLED() \
+	__dtraceenabled_mysql___insert__select__done()
+#define	MYSQL_INSERT_SELECT_START(arg0) \
+	__dtrace_mysql___insert__select__start(arg0)
+#define	MYSQL_INSERT_SELECT_START_ENABLED() \
+	__dtraceenabled_mysql___insert__select__start()
+#define	MYSQL_INSERT_START(arg0) \
+	__dtrace_mysql___insert__start(arg0)
 #define	MYSQL_INSERT_START_ENABLED() \
-	__dtraceenabled_mysql___insert_start()
-#define	MYSQL_SELECT_END() \
-	__dtrace_mysql___select_end()
-#define	MYSQL_SELECT_END_ENABLED() \
-	__dtraceenabled_mysql___select_end()
-#define	MYSQL_SELECT_START() \
-	__dtrace_mysql___select_start()
+	__dtraceenabled_mysql___insert__start()
+#define	MYSQL_MULTI_DELETE_DONE(arg0, arg1) \
+	__dtrace_mysql___multi__delete__done(arg0, arg1)
+#define	MYSQL_MULTI_DELETE_DONE_ENABLED() \
+	__dtraceenabled_mysql___multi__delete__done()
+#define	MYSQL_MULTI_DELETE_START(arg0) \
+	__dtrace_mysql___multi__delete__start(arg0)
+#define	MYSQL_MULTI_DELETE_START_ENABLED() \
+	__dtraceenabled_mysql___multi__delete__start()
+#define	MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___multi__update__done(arg0, arg1, arg2)
+#define	MYSQL_MULTI_UPDATE_DONE_ENABLED() \
+	__dtraceenabled_mysql___multi__update__done()
+#define	MYSQL_MULTI_UPDATE_START(arg0) \
+	__dtrace_mysql___multi__update__start(arg0)
+#define	MYSQL_MULTI_UPDATE_START_ENABLED() \
+	__dtraceenabled_mysql___multi__update__start()
+#define	MYSQL_NET_READ_DONE(arg0, arg1) \
+	__dtrace_mysql___net__read__done(arg0, arg1)
+#define	MYSQL_NET_READ_DONE_ENABLED() \
+	__dtraceenabled_mysql___net__read__done()
+#define	MYSQL_NET_READ_START() \
+	__dtrace_mysql___net__read__start()
+#define	MYSQL_NET_READ_START_ENABLED() \
+	__dtraceenabled_mysql___net__read__start()
+#define	MYSQL_NET_WRITE_DONE(arg0) \
+	__dtrace_mysql___net__write__done(arg0)
+#define	MYSQL_NET_WRITE_DONE_ENABLED() \
+	__dtraceenabled_mysql___net__write__done()
+#define	MYSQL_NET_WRITE_START(arg0) \
+	__dtrace_mysql___net__write__start(arg0)
+#define	MYSQL_NET_WRITE_START_ENABLED() \
+	__dtraceenabled_mysql___net__write__start()
+#define	MYSQL_QUERY_CACHE_HIT(arg0, arg1) \
+	__dtrace_mysql___query__cache__hit(arg0, arg1)
+#define	MYSQL_QUERY_CACHE_HIT_ENABLED() \
+	__dtraceenabled_mysql___query__cache__hit()
+#define	MYSQL_QUERY_CACHE_MISS(arg0) \
+	__dtrace_mysql___query__cache__miss(arg0)
+#define	MYSQL_QUERY_CACHE_MISS_ENABLED() \
+	__dtraceenabled_mysql___query__cache__miss()
+#define	MYSQL_QUERY_DONE(arg0) \
+	__dtrace_mysql___query__done(arg0)
+#define	MYSQL_QUERY_DONE_ENABLED() \
+	__dtraceenabled_mysql___query__done()
+#define	MYSQL_QUERY_EXEC_DONE(arg0) \
+	__dtrace_mysql___query__exec__done(arg0)
+#define	MYSQL_QUERY_EXEC_DONE_ENABLED() \
+	__dtraceenabled_mysql___query__exec__done()
+#define	MYSQL_QUERY_EXEC_START(arg0, arg1, arg2, arg3, arg4, arg5) \
+	__dtrace_mysql___query__exec__start(arg0, arg1, arg2, arg3, arg4, arg5)
+#define	MYSQL_QUERY_EXEC_START_ENABLED() \
+	__dtraceenabled_mysql___query__exec__start()
+#define	MYSQL_QUERY_PARSE_DONE(arg0) \
+	__dtrace_mysql___query__parse__done(arg0)
+#define	MYSQL_QUERY_PARSE_DONE_ENABLED() \
+	__dtraceenabled_mysql___query__parse__done()
+#define	MYSQL_QUERY_PARSE_START(arg0) \
+	__dtrace_mysql___query__parse__start(arg0)
+#define	MYSQL_QUERY_PARSE_START_ENABLED() \
+	__dtraceenabled_mysql___query__parse__start()
+#define	MYSQL_QUERY_START(arg0, arg1, arg2, arg3, arg4) \
+	__dtrace_mysql___query__start(arg0, arg1, arg2, arg3, arg4)
+#define	MYSQL_QUERY_START_ENABLED() \
+	__dtraceenabled_mysql___query__start()
+#define	MYSQL_SELECT_DONE(arg0, arg1) \
+	__dtrace_mysql___select__done(arg0, arg1)
+#define	MYSQL_SELECT_DONE_ENABLED() \
+	__dtraceenabled_mysql___select__done()
+#define	MYSQL_SELECT_START(arg0) \
+	__dtrace_mysql___select__start(arg0)
 #define	MYSQL_SELECT_START_ENABLED() \
-	__dtraceenabled_mysql___select_start()
-#define	MYSQL_UPDATE_END() \
-	__dtrace_mysql___update_end()
-#define	MYSQL_UPDATE_END_ENABLED() \
-	__dtraceenabled_mysql___update_end()
-#define	MYSQL_UPDATE_START() \
-	__dtrace_mysql___update_start()
+	__dtraceenabled_mysql___select__start()
+#define	MYSQL_UPDATE_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___update__done(arg0, arg1, arg2)
+#define	MYSQL_UPDATE_DONE_ENABLED() \
+	__dtraceenabled_mysql___update__done()
+#define	MYSQL_UPDATE_ROW_DONE(arg0) \
+	__dtrace_mysql___update__row__done(arg0)
+#define	MYSQL_UPDATE_ROW_DONE_ENABLED() \
+	__dtraceenabled_mysql___update__row__done()
+#define	MYSQL_UPDATE_ROW_START(arg0, arg1) \
+	__dtrace_mysql___update__row__start(arg0, arg1)
+#define	MYSQL_UPDATE_ROW_START_ENABLED() \
+	__dtraceenabled_mysql___update__row__start()
+#define	MYSQL_UPDATE_START(arg0) \
+	__dtrace_mysql___update__start(arg0)
 #define	MYSQL_UPDATE_START_ENABLED() \
-	__dtraceenabled_mysql___update_start()
+	__dtraceenabled_mysql___update__start()
 
 
-extern void __dtrace_mysql___delete_end(void);
-extern int __dtraceenabled_mysql___delete_end(void);
-extern void __dtrace_mysql___delete_start(void);
-extern int __dtraceenabled_mysql___delete_start(void);
-extern void __dtrace_mysql___external_lock(int);
-extern int __dtraceenabled_mysql___external_lock(void);
-extern void __dtrace_mysql___filesort_end(void);
-extern int __dtraceenabled_mysql___filesort_end(void);
-extern void __dtrace_mysql___filesort_start(void);
-extern int __dtraceenabled_mysql___filesort_start(void);
-extern void __dtrace_mysql___insert_end(void);
-extern int __dtraceenabled_mysql___insert_end(void);
-extern void __dtrace_mysql___insert_row_end(void);
-extern int __dtraceenabled_mysql___insert_row_end(void);
-extern void __dtrace_mysql___insert_row_start(void);
-extern int __dtraceenabled_mysql___insert_row_start(void);
-extern void __dtrace_mysql___insert_start(void);
-extern int __dtraceenabled_mysql___insert_start(void);
-extern void __dtrace_mysql___select_end(void);
-extern int __dtraceenabled_mysql___select_end(void);
-extern void __dtrace_mysql___select_start(void);
-extern int __dtraceenabled_mysql___select_start(void);
-extern void __dtrace_mysql___update_end(void);
-extern int __dtraceenabled_mysql___update_end(void);
-extern void __dtrace_mysql___update_start(void);
-extern int __dtraceenabled_mysql___update_start(void);
+extern void __dtrace_mysql___command__done(int);
+extern int __dtraceenabled_mysql___command__done(void);
+extern void __dtrace_mysql___command__start(unsigned long, int, char *, char *);
+extern int __dtraceenabled_mysql___command__start(void);
+extern void __dtrace_mysql___connection__done(int, unsigned long);
+extern int __dtraceenabled_mysql___connection__done(void);
+extern void __dtrace_mysql___connection__start(unsigned long, char *, char *);
+extern int __dtraceenabled_mysql___connection__start(void);
+extern void __dtrace_mysql___delete__done(int, unsigned long);
+extern int __dtraceenabled_mysql___delete__done(void);
+extern void __dtrace_mysql___delete__row__done(int);
+extern int __dtraceenabled_mysql___delete__row__done(void);
+extern void __dtrace_mysql___delete__row__start(char *, char *);
+extern int __dtraceenabled_mysql___delete__row__start(void);
+extern void __dtrace_mysql___delete__start(char *);
+extern int __dtraceenabled_mysql___delete__start(void);
+extern void __dtrace_mysql___filesort__done(int, unsigned long);
+extern int __dtraceenabled_mysql___filesort__done(void);
+extern void __dtrace_mysql___filesort__start(char *, char *);
+extern int __dtraceenabled_mysql___filesort__start(void);
+extern void __dtrace_mysql___handler__rdlock__done(int);
+extern int __dtraceenabled_mysql___handler__rdlock__done(void);
+extern void __dtrace_mysql___handler__rdlock__start(char *, char *);
+extern int __dtraceenabled_mysql___handler__rdlock__start(void);
+extern void __dtrace_mysql___handler__unlock__done(int);
+extern int __dtraceenabled_mysql___handler__unlock__done(void);
+extern void __dtrace_mysql___handler__unlock__start(char *, char *);
+extern int __dtraceenabled_mysql___handler__unlock__start(void);
+extern void __dtrace_mysql___handler__wrlock__done(int);
+extern int __dtraceenabled_mysql___handler__wrlock__done(void);
+extern void __dtrace_mysql___handler__wrlock__start(char *, char *);
+extern int __dtraceenabled_mysql___handler__wrlock__start(void);
+extern void __dtrace_mysql___insert__done(int, unsigned long);
+extern int __dtraceenabled_mysql___insert__done(void);
+extern void __dtrace_mysql___insert__row__done(int);
+extern int __dtraceenabled_mysql___insert__row__done(void);
+extern void __dtrace_mysql___insert__row__start(char *, char *);
+extern int __dtraceenabled_mysql___insert__row__start(void);
+extern void __dtrace_mysql___insert__select__done(int, unsigned long);
+extern int __dtraceenabled_mysql___insert__select__done(void);
+extern void __dtrace_mysql___insert__select__start(char *);
+extern int __dtraceenabled_mysql___insert__select__start(void);
+extern void __dtrace_mysql___insert__start(char *);
+extern int __dtraceenabled_mysql___insert__start(void);
+extern void __dtrace_mysql___multi__delete__done(int, unsigned long);
+extern int __dtraceenabled_mysql___multi__delete__done(void);
+extern void __dtrace_mysql___multi__delete__start(char *);
+extern int __dtraceenabled_mysql___multi__delete__start(void);
+extern void __dtrace_mysql___multi__update__done(int, unsigned long, unsigned long);
+extern int __dtraceenabled_mysql___multi__update__done(void);
+extern void __dtrace_mysql___multi__update__start(char *);
+extern int __dtraceenabled_mysql___multi__update__start(void);
+extern void __dtrace_mysql___net__read__done(int, unsigned long);
+extern int __dtraceenabled_mysql___net__read__done(void);
+extern void __dtrace_mysql___net__read__start(void);
+extern int __dtraceenabled_mysql___net__read__start(void);
+extern void __dtrace_mysql___net__write__done(int);
+extern int __dtraceenabled_mysql___net__write__done(void);
+extern void __dtrace_mysql___net__write__start(unsigned long);
+extern int __dtraceenabled_mysql___net__write__start(void);
+extern void __dtrace_mysql___query__cache__hit(char *, unsigned long);
+extern int __dtraceenabled_mysql___query__cache__hit(void);
+extern void __dtrace_mysql___query__cache__miss(char *);
+extern int __dtraceenabled_mysql___query__cache__miss(void);
+extern void __dtrace_mysql___query__done(int);
+extern int __dtraceenabled_mysql___query__done(void);
+extern void __dtrace_mysql___query__exec__done(int);
+extern int __dtraceenabled_mysql___query__exec__done(void);
+extern void __dtrace_mysql___query__exec__start(char *, unsigned long, char *, char *, char *, int);
+extern int __dtraceenabled_mysql___query__exec__start(void);
+extern void __dtrace_mysql___query__parse__done(int);
+extern int __dtraceenabled_mysql___query__parse__done(void);
+extern void __dtrace_mysql___query__parse__start(char *);
+extern int __dtraceenabled_mysql___query__parse__start(void);
+extern void __dtrace_mysql___query__start(char *, unsigned long, char *, char *, char *);
+extern int __dtraceenabled_mysql___query__start(void);
+extern void __dtrace_mysql___select__done(int, unsigned long);
+extern int __dtraceenabled_mysql___select__done(void);
+extern void __dtrace_mysql___select__start(char *);
+extern int __dtraceenabled_mysql___select__start(void);
+extern void __dtrace_mysql___update__done(int, unsigned long, unsigned long);
+extern int __dtraceenabled_mysql___update__done(void);
+extern void __dtrace_mysql___update__row__done(int);
+extern int __dtraceenabled_mysql___update__row__done(void);
+extern void __dtrace_mysql___update__row__start(char *, char *);
+extern int __dtraceenabled_mysql___update__row__start(void);
+extern void __dtrace_mysql___update__start(char *);
+extern int __dtraceenabled_mysql___update__start(void);
 
 #else
 
-#define	MYSQL_DELETE_END()
-#define	MYSQL_DELETE_END_ENABLED() (0)
-#define	MYSQL_DELETE_START()
+#define	MYSQL_COMMAND_DONE(arg0)
+#define	MYSQL_COMMAND_DONE_ENABLED() (0)
+#define	MYSQL_COMMAND_START(arg0, arg1, arg2, arg3)
+#define	MYSQL_COMMAND_START_ENABLED() (0)
+#define	MYSQL_CONNECTION_DONE(arg0, arg1)
+#define	MYSQL_CONNECTION_DONE_ENABLED() (0)
+#define	MYSQL_CONNECTION_START(arg0, arg1, arg2)
+#define	MYSQL_CONNECTION_START_ENABLED() (0)
+#define	MYSQL_DELETE_DONE(arg0, arg1)
+#define	MYSQL_DELETE_DONE_ENABLED() (0)
+#define	MYSQL_DELETE_ROW_DONE(arg0)
+#define	MYSQL_DELETE_ROW_DONE_ENABLED() (0)
+#define	MYSQL_DELETE_ROW_START(arg0, arg1)
+#define	MYSQL_DELETE_ROW_START_ENABLED() (0)
+#define	MYSQL_DELETE_START(arg0)
 #define	MYSQL_DELETE_START_ENABLED() (0)
-#define	MYSQL_EXTERNAL_LOCK(arg0)
-#define	MYSQL_EXTERNAL_LOCK_ENABLED() (0)
-#define	MYSQL_FILESORT_END()
-#define	MYSQL_FILESORT_END_ENABLED() (0)
-#define	MYSQL_FILESORT_START()
+#define	MYSQL_FILESORT_DONE(arg0, arg1)
+#define	MYSQL_FILESORT_DONE_ENABLED() (0)
+#define	MYSQL_FILESORT_START(arg0, arg1)
 #define	MYSQL_FILESORT_START_ENABLED() (0)
-#define	MYSQL_INSERT_END()
-#define	MYSQL_INSERT_END_ENABLED() (0)
-#define	MYSQL_INSERT_ROW_END()
-#define	MYSQL_INSERT_ROW_END_ENABLED() (0)
-#define	MYSQL_INSERT_ROW_START()
+#define	MYSQL_HANDLER_RDLOCK_DONE(arg0)
+#define	MYSQL_HANDLER_RDLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_RDLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_RDLOCK_START_ENABLED() (0)
+#define	MYSQL_HANDLER_UNLOCK_DONE(arg0)
+#define	MYSQL_HANDLER_UNLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_UNLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_UNLOCK_START_ENABLED() (0)
+#define	MYSQL_HANDLER_WRLOCK_DONE(arg0)
+#define	MYSQL_HANDLER_WRLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_WRLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_WRLOCK_START_ENABLED() (0)
+#define	MYSQL_INSERT_DONE(arg0, arg1)
+#define	MYSQL_INSERT_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_ROW_DONE(arg0)
+#define	MYSQL_INSERT_ROW_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_ROW_START(arg0, arg1)
 #define	MYSQL_INSERT_ROW_START_ENABLED() (0)
-#define	MYSQL_INSERT_START()
+#define	MYSQL_INSERT_SELECT_DONE(arg0, arg1)
+#define	MYSQL_INSERT_SELECT_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_SELECT_START(arg0)
+#define	MYSQL_INSERT_SELECT_START_ENABLED() (0)
+#define	MYSQL_INSERT_START(arg0)
 #define	MYSQL_INSERT_START_ENABLED() (0)
-#define	MYSQL_SELECT_END()
-#define	MYSQL_SELECT_END_ENABLED() (0)
-#define	MYSQL_SELECT_START()
+#define	MYSQL_MULTI_DELETE_DONE(arg0, arg1)
+#define	MYSQL_MULTI_DELETE_DONE_ENABLED() (0)
+#define	MYSQL_MULTI_DELETE_START(arg0)
+#define	MYSQL_MULTI_DELETE_START_ENABLED() (0)
+#define	MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2)
+#define	MYSQL_MULTI_UPDATE_DONE_ENABLED() (0)
+#define	MYSQL_MULTI_UPDATE_START(arg0)
+#define	MYSQL_MULTI_UPDATE_START_ENABLED() (0)
+#define	MYSQL_NET_READ_DONE(arg0, arg1)
+#define	MYSQL_NET_READ_DONE_ENABLED() (0)
+#define	MYSQL_NET_READ_START()
+#define	MYSQL_NET_READ_START_ENABLED() (0)
+#define	MYSQL_NET_WRITE_DONE(arg0)
+#define	MYSQL_NET_WRITE_DONE_ENABLED() (0)
+#define	MYSQL_NET_WRITE_START(arg0)
+#define	MYSQL_NET_WRITE_START_ENABLED() (0)
+#define	MYSQL_QUERY_CACHE_HIT(arg0, arg1)
+#define	MYSQL_QUERY_CACHE_HIT_ENABLED() (0)
+#define	MYSQL_QUERY_CACHE_MISS(arg0)
+#define	MYSQL_QUERY_CACHE_MISS_ENABLED() (0)
+#define	MYSQL_QUERY_DONE(arg0)
+#define	MYSQL_QUERY_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_EXEC_DONE(arg0)
+#define	MYSQL_QUERY_EXEC_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_EXEC_START(arg0, arg1, arg2, arg3, arg4, arg5)
+#define	MYSQL_QUERY_EXEC_START_ENABLED() (0)
+#define	MYSQL_QUERY_PARSE_DONE(arg0)
+#define	MYSQL_QUERY_PARSE_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_PARSE_START(arg0)
+#define	MYSQL_QUERY_PARSE_START_ENABLED() (0)
+#define	MYSQL_QUERY_START(arg0, arg1, arg2, arg3, arg4)
+#define	MYSQL_QUERY_START_ENABLED() (0)
+#define	MYSQL_SELECT_DONE(arg0, arg1)
+#define	MYSQL_SELECT_DONE_ENABLED() (0)
+#define	MYSQL_SELECT_START(arg0)
 #define	MYSQL_SELECT_START_ENABLED() (0)
-#define	MYSQL_UPDATE_END()
-#define	MYSQL_UPDATE_END_ENABLED() (0)
-#define	MYSQL_UPDATE_START()
+#define	MYSQL_UPDATE_DONE(arg0, arg1, arg2)
+#define	MYSQL_UPDATE_DONE_ENABLED() (0)
+#define	MYSQL_UPDATE_ROW_DONE(arg0)
+#define	MYSQL_UPDATE_ROW_DONE_ENABLED() (0)
+#define	MYSQL_UPDATE_ROW_START(arg0, arg1)
+#define	MYSQL_UPDATE_ROW_START_ENABLED() (0)
+#define	MYSQL_UPDATE_START(arg0)
 #define	MYSQL_UPDATE_START_ENABLED() (0)
 
 #endif

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc	2008-10-07 20:09:02 +0000
+++ b/sql/scheduler.cc	2008-10-17 17:47:16 +0000
@@ -602,6 +602,8 @@ pthread_handler_t libevent_thread_proc(v
       else
       {
         /* login successful */
+        MYSQL_CONNECTION_START(thd->thread_id, thd->security_ctx->priv_user,
+                               (char *) thd->security_ctx->host_or_ip);
         thd->scheduler.logged_in= TRUE;
         prepare_new_connection_state(thd);
         if (!libevent_needs_immediate_processing(thd))

=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt	2008-09-03 12:39:48 +0000
+++ b/sql/share/errmsg.txt	2008-10-18 07:57:38 +0000
@@ -5020,7 +5020,7 @@ ER_WARN_HOSTNAME_WONT_WORK  
         por "MySQL foi inicializado em modo --skip-name-resolve. Voc� necesita reincializ�-lo sem esta op��o para este grant funcionar"
         spa "MySQL esta inicializado en modo --skip-name-resolve. Usted necesita reinicializarlo sin esta opci�n para este derecho funcionar"
 ER_UNKNOWN_STORAGE_ENGINE 42000 
-        eng "Unknown table engine '%s'"
+        eng "Unknown storage engine '%s'"
         ger "Unbekannte Speicher-Engine '%s'"
         por "Motor de tabela desconhecido '%s'"
         spa "Desconocido motor de tabla '%s'"
@@ -6251,7 +6251,7 @@ ER_BACKUP_THREAD_INIT
         eng "Backup driver's table locking thread can not be initialized."
 
 ER_BACKUP_PROGRESS_TABLES
-        eng "Can't open the backup log tables. Check 'mysql.backup_history' and 'mysql.backup_progress'."
+        eng "Can't open the backup logs as tables. Check 'mysql.backup_history' and 'mysql.backup_progress' or run mysql_upgrade to repair."
 
 ER_TABLESPACE_EXIST
   eng "Tablespace '%-.192s' already exists"

=== modified file 'sql/si_logs.cc'
--- a/sql/si_logs.cc	2008-08-28 15:13:31 +0000
+++ b/sql/si_logs.cc	2008-09-30 07:51:48 +0000
@@ -138,16 +138,19 @@ void Backup_log::state(enum_backup_state
   a message to the progress log.
 
   @param[IN]  when  Time of validity point.
+  @param[IN]  report Determines if an entry should be written to the 
+                     backup_progress log.
 
   @note If the time is 0|NULL, nothing is saved in the history data.
 */
-void Backup_log::vp_time(time_t when)
+void Backup_log::vp_time(time_t when, bool report)
 {
   if (when)
   {
-    m_op_hist.vp_time= when; 
-    logger.backup_progress_log_write(m_thd, m_op_hist.backup_id, "backup kernel", 
-                                     when, 0, 0, 0, 0, "vp time");
+    m_op_hist.vp_time= when;
+    if (report)
+      logger.backup_progress_log_write(m_thd, m_op_hist.backup_id, "backup kernel", 
+                                       when, 0, 0, 0, 0, "vp time");
   }
 }
 

=== modified file 'sql/si_logs.h'
--- a/sql/si_logs.h	2008-08-27 17:30:49 +0000
+++ b/sql/si_logs.h	2008-09-30 07:51:48 +0000
@@ -130,7 +130,7 @@ public:
   void size(longlong s) { m_op_hist.size= s; }
   void start(time_t when);
   void stop(time_t when);
-  void vp_time(time_t when);
+  void vp_time(time_t when, bool report);
   void add_driver(const char* driver);
 
 private:

=== modified file 'sql/si_objects.cc'
--- a/sql/si_objects.cc	2008-10-10 10:11:22 +0000
+++ b/sql/si_objects.cc	2008-10-17 11:28:25 +0000
@@ -261,10 +261,10 @@ bool drop_object(THD *thd, const char *o
   cmd.append(" IF EXISTS ");
   if (name1 && (name1->length() > 0))
   {
-    append_identifier(thd, &cmd, name1->c_ptr(), name1->length());  
+    append_identifier(thd, &cmd, name1->c_ptr(), name1->length());
     cmd.append(".");
   }
-  append_identifier(thd, &cmd, name2->c_ptr(), name2->length());  
+  append_identifier(thd, &cmd, name2->c_ptr(), name2->length());
   DBUG_RETURN(silent_exec(thd, &cmd));
 }
 
@@ -279,7 +279,7 @@ bool drop_object(THD *thd, const char *o
 
   @note: The select condition is designed to form a WHERE clause based on
   the database/schema column of the information_schema views. Most views have
-  a database/schema column but for those that do not, you must ignore the 
+  a database/schema column but for those that do not, you must ignore the
   selection condition by passing db_list = NULL.
 
   @retval TABLE* The schema table
@@ -344,7 +344,7 @@ void prepend_db(THD *thd, String *serial
   */
   serialization->length(0);
   serialization->append("USE ");
-  append_identifier(thd, serialization, db_name->c_ptr(), db_name->length());  
+  append_identifier(thd, serialization, db_name->c_ptr(), db_name->length());
   serialization->append("; ");
   DBUG_VOID_RETURN;
 }
@@ -394,7 +394,7 @@ void delete_table_name_key(void *data)
 ///////////////////////////////////////////////////////////////////////////
 
 namespace obs {
-  
+
 /**
   Build a where clause for list of databases.
 
@@ -408,7 +408,7 @@ namespace obs {
 
   @returns NULL if no databases in list or pointer to COND tree.
 */
-COND *create_db_select_condition(THD *thd, 
+COND *create_db_select_condition(THD *thd,
                                  TABLE *t,
                                  List<LEX_STRING> *db_list)
 {
@@ -416,7 +416,7 @@ COND *create_db_select_condition(THD *th
   List_iterator< ::LEX_STRING> it(*db_list);
   ::LEX_STRING *db;
   DBUG_ENTER("Obj::create_select_condition()");
-  
+
   /*
     If no list of databases, just return NULL
   */
@@ -439,7 +439,7 @@ COND *create_db_select_condition(THD *th
   */
   Item *db_field= new Item_field(thd, thd->lex->current_context(), t->field[1]);
   in_db_list.push_front(db_field);
-  
+
   /*
     Build the in function item comparison and add list of databases.
   */
@@ -711,7 +711,7 @@ class TablespaceObj : public Obj
 {
 public:
   TablespaceObj(const String *ts_name);
-  
+
 public:
   virtual bool do_serialize(THD *thd, String *serialization);
 
@@ -891,7 +891,7 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////
 
-class InformationSchemaIterator : public ObjIterator
+class InformationSchemaIterator : public Obj_iterator
 {
 public:
   static bool prepare_is_table(
@@ -932,7 +932,7 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////
 
-class ObjIteratorDummyImpl : ObjIterator
+class ObjIteratorDummyImpl : Obj_iterator
 {
 public:
   ObjIteratorDummyImpl() { return; }
@@ -1081,7 +1081,7 @@ protected:
 private:
   String m_db_name;
 };
- 
+
 class TblGrantIterator : public InformationSchemaIterator
 {
 public:
@@ -1101,7 +1101,7 @@ protected:
 private:
   String m_db_name;
 };
- 
+
 class ColGrantIterator : public InformationSchemaIterator
 {
 public:
@@ -1121,7 +1121,7 @@ protected:
 private:
   String m_db_name;
 };
- 
+
 
 ///////////////////////////////////////////////////////////////////////////
 
@@ -1168,7 +1168,7 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////
 
-class ViewBaseObjectsIterator : public ObjIterator
+class ViewBaseObjectsIterator : public Obj_iterator
 {
 public:
   enum IteratorType
@@ -1197,13 +1197,13 @@ private:
   uint m_cur_idx;
 
 private:
-  friend ObjIterator *get_view_base_tables(THD *,
+  friend Obj_iterator *get_view_base_tables(THD *,
+                                            const String *,
+                                            const String *);
+
+  friend Obj_iterator *get_view_base_views(THD *,
                                            const String *,
                                            const String *);
-
-  friend ObjIterator *get_view_base_views(THD *,
-                                          const String *,
-                                          const String *);
 };
 
 ///////////////////////////////////////////////////////////////////////////
@@ -1509,13 +1509,13 @@ DbGrantObj* DbGrantIterator::create_obj(
   */
   if (db_name == m_db_name)
   {
-    DBUG_PRINT("DbGrantIterator::create", (" Found grant %s %s %s", 
+    DBUG_PRINT("DbGrantIterator::create", (" Found grant %s %s %s",
      db_name.ptr(), grantee.ptr(), priv_type.ptr()));
 
     /*
       Include grants for only users that exist at time of backup.
     */
-    if (user_exists(m_thd, &grantee))
+    if (check_user_existence(m_thd, &grantee))
       return new DbGrantObj(&grantee, &db_name, &priv_type);
     else
       return NULL;
@@ -1538,7 +1538,7 @@ TblGrantObj* TblGrantIterator::create_ob
   String db_name;   // corresponds with TABLE_SCHEMA
   String tbl_name;  // corresponds with TABLE_NAME
   String priv_type; // corresponds with PRIVILEGE_TYPE
- 
+
   t->field[0]->val_str(&grantee);
   t->field[2]->val_str(&db_name);
   t->field[3]->val_str(&tbl_name);
@@ -1553,13 +1553,13 @@ TblGrantObj* TblGrantIterator::create_ob
   */
   if (db_name == m_db_name)
   {
-    DBUG_PRINT("TblGrantIterator::create", (" Found grant %s %s %s %s", 
+    DBUG_PRINT("TblGrantIterator::create", (" Found grant %s %s %s %s",
      db_name.ptr(), grantee.ptr(), tbl_name.ptr(), priv_type.ptr()));
 
     /*
       Include grants for only users that exist at time of backup.
     */
-    if (user_exists(m_thd, &grantee))
+    if (check_user_existence(m_thd, &grantee))
       return new TblGrantObj(&grantee, &db_name, &tbl_name, &priv_type);
     else
       return NULL;
@@ -1583,7 +1583,7 @@ ColGrantObj* ColGrantIterator::create_ob
   String tbl_name;  // corresponds with TABLE_NAME
   String col_name;  // corresponds with COLUMN_NAME
   String priv_type; // corresponds with PRIVILEGE_TYPE
- 
+
   t->field[0]->val_str(&grantee);
   t->field[2]->val_str(&db_name);
   t->field[3]->val_str(&tbl_name);
@@ -1599,14 +1599,14 @@ ColGrantObj* ColGrantIterator::create_ob
   */
   if (db_name == m_db_name)
   {
-    DBUG_PRINT("ColGrantIterator::create", (" Found grant %s %s %s %s %s", 
+    DBUG_PRINT("ColGrantIterator::create", (" Found grant %s %s %s %s %s",
      db_name.ptr(), grantee.ptr(), tbl_name.ptr(), col_name.ptr(),
      priv_type.ptr()));
 
     /*
       Include grants for only users that exist at time of backup.
     */
-    if (user_exists(m_thd, &grantee))
+    if (check_user_existence(m_thd, &grantee))
       return new ColGrantObj(&grantee, &db_name, &tbl_name,
                              &col_name, &priv_type);
     else
@@ -1734,14 +1734,14 @@ TableObj *ViewBaseObjectsIterator::next(
 
 ///////////////////////////////////////////////////////////////////////////
 
-ObjIterator *get_databases(THD *thd)
+Obj_iterator *get_databases(THD *thd)
 {
   TABLE *is_table;
   handler *ha;
   my_bitmap_map *orig_columns;
 
   if (InformationSchemaIterator::prepare_is_table(
-      thd, &is_table, &ha, &orig_columns, SCH_SCHEMATA, 
+      thd, &is_table, &ha, &orig_columns, SCH_SCHEMATA,
       thd->lex->db_list))
     return NULL;
 
@@ -1810,37 +1810,37 @@ template
 ColGrantIterator *
 create_is_iterator<ColGrantIterator>(THD *, enum_schema_tables, const String *);
 
-ObjIterator *get_db_tables(THD *thd, const String *db_name)
+Obj_iterator *get_db_tables(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbTablesIterator>(thd, SCH_TABLES, db_name);
 }
 
-ObjIterator *get_db_views(THD *thd, const String *db_name)
+Obj_iterator *get_db_views(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbViewsIterator>(thd, SCH_TABLES, db_name);
 }
 
-ObjIterator *get_db_triggers(THD *thd, const String *db_name)
+Obj_iterator *get_db_triggers(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbTriggerIterator>(thd, SCH_TRIGGERS, db_name);
 }
 
-ObjIterator *get_db_stored_procedures(THD *thd, const String *db_name)
+Obj_iterator *get_db_stored_procedures(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbStoredProcIterator>(thd, SCH_PROCEDURES, db_name);
 }
 
-ObjIterator *get_db_stored_functions(THD *thd, const String *db_name)
+Obj_iterator *get_db_stored_functions(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbStoredFuncIterator>(thd, SCH_PROCEDURES, db_name);
 }
 
-ObjIterator *get_db_events(THD *thd, const String *db_name)
+Obj_iterator *get_db_events(THD *thd, const String *db_name)
 {
 #ifdef HAVE_EVENT_SCHEDULER
   return create_is_iterator<DbEventIterator>(thd, SCH_EVENTS, db_name);
 #else
-  return (ObjIterator *)new ObjIteratorDummyImpl;
+  return (Obj_iterator *)new ObjIteratorDummyImpl;
 #endif
 }
 
@@ -1852,16 +1852,16 @@ ObjIterator *get_db_events(THD *thd, con
   The iterators return all of the grants for the database specified.
 */
 GrantObjIterator::GrantObjIterator(THD *thd, const String *db_name)
-: ObjIterator()
+: Obj_iterator()
 {
-  db_grants= create_is_iterator<DbGrantIterator>(thd, 
-                                                 SCH_SCHEMA_PRIVILEGES, 
+  db_grants= create_is_iterator<DbGrantIterator>(thd,
+                                                 SCH_SCHEMA_PRIVILEGES,
                                                  db_name);
   tbl_grants= create_is_iterator<TblGrantIterator>(thd,
-                                                 SCH_TABLE_PRIVILEGES, 
+                                                 SCH_TABLE_PRIVILEGES,
                                                  db_name);
-  col_grants= create_is_iterator<ColGrantIterator>(thd, 
-                                                 SCH_COLUMN_PRIVILEGES, 
+  col_grants= create_is_iterator<ColGrantIterator>(thd,
+                                                 SCH_COLUMN_PRIVILEGES,
                                                  db_name);
 }
 
@@ -1879,7 +1879,7 @@ Obj *GrantObjIterator::next()
 /**
   Creates a high-level iterator that iterates over database-, table-,
   routine-, and column-level privileges which shall permit a single
-  iterator from the si_objects to retrieve all of the privileges for 
+  iterator from the si_objects to retrieve all of the privileges for
   a given database.
 
   @param[IN] thd      Current THD object
@@ -1890,7 +1890,7 @@ Obj *GrantObjIterator::next()
   @return a pointer to an iterator object.
     @retval NULL in case of error.
 */
-ObjIterator *get_all_db_grants(THD *thd, const String *db_name)
+Obj_iterator *get_all_db_grants(THD *thd, const String *db_name)
 {
   return new GrantObjIterator(thd, db_name);
 }
@@ -1903,17 +1903,17 @@ ObjIterator *get_all_db_grants(THD *thd,
 
 ///////////////////////////////////////////////////////////////////////////
 
-ObjIterator* get_view_base_tables(THD *thd,
-                                  const String *db_name,
-                                  const String *view_name)
+Obj_iterator* get_view_base_tables(THD *thd,
+                                   const String *db_name,
+                                   const String *view_name)
 {
   return ViewBaseObjectsIterator::create(
     thd, db_name, view_name, ViewBaseObjectsIterator::GET_BASE_TABLES);
 }
 
-ObjIterator* get_view_base_views(THD *thd,
-                                 const String *db_name,
-                                 const String *view_name)
+Obj_iterator* get_view_base_views(THD *thd,
+                                  const String *db_name,
+                                  const String *view_name)
 {
   return ViewBaseObjectsIterator::create(
     thd, db_name, view_name, ViewBaseObjectsIterator::GET_BASE_VIEWS);
@@ -2918,8 +2918,8 @@ const String *TablespaceObj::build_seria
   if (m_ts_name.length() > 0)
   {
     THD *thd= current_thd;
-    append_identifier(thd, &m_create_stmt, 
-      m_ts_name.c_ptr(), m_ts_name.length());  
+    append_identifier(thd, &m_create_stmt,
+      m_ts_name.c_ptr(), m_ts_name.length());
   }
   m_create_stmt.append(" ADD DATAFILE '");
   m_create_stmt.append(m_datafile);
@@ -3046,7 +3046,7 @@ bool DbGrantObj::do_execute(THD *thd)
 TblGrantObj::TblGrantObj(const String *grantee,
                          const String *db_name,
                          const String *table_name,
-                         const String *priv_type) 
+                         const String *priv_type)
 : DbGrantObj(grantee, db_name, priv_type)
 {
   // copy strings to newly allocated memory
@@ -3095,7 +3095,7 @@ ColGrantObj::ColGrantObj(const String *g
                          const String *db_name,
                          const String *table_name,
                          const String *col_name,
-                         const String *priv_type) 
+                         const String *priv_type)
 : TblGrantObj(grantee, db_name, table_name, priv_type)
 {
   // copy strings to newly allocated memory
@@ -3188,10 +3188,10 @@ Obj *get_event(const String *db_name,
 
 Obj *materialize_database(const String *db_name,
                           uint serialization_version,
-                          const String *serialialization)
+                          const String *serialization)
 {
   Obj *obj= new DatabaseObj(db_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3199,10 +3199,10 @@ Obj *materialize_database(const String *
 Obj *materialize_table(const String *db_name,
                        const String *table_name,
                        uint serialization_version,
-                       const String *serialialization)
+                       const String *serialization)
 {
   Obj *obj= new TableObj(db_name, table_name, false);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3210,10 +3210,10 @@ Obj *materialize_table(const String *db_
 Obj *materialize_view(const String *db_name,
                       const String *view_name,
                       uint serialization_version,
-                      const String *serialialization)
+                      const String *serialization)
 {
   Obj *obj= new TableObj(db_name, view_name, true);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3221,10 +3221,10 @@ Obj *materialize_view(const String *db_n
 Obj *materialize_trigger(const String *db_name,
                          const String *trigger_name,
                          uint serialization_version,
-                         const String *serialialization)
+                         const String *serialization)
 {
   Obj *obj= new TriggerObj(db_name, trigger_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3232,10 +3232,10 @@ Obj *materialize_trigger(const String *d
 Obj *materialize_stored_procedure(const String *db_name,
                                   const String *stored_proc_name,
                                   uint serialization_version,
-                                  const String *serialialization)
+                                  const String *serialization)
 {
   Obj *obj= new StoredProcObj(db_name, stored_proc_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3243,10 +3243,10 @@ Obj *materialize_stored_procedure(const 
 Obj *materialize_stored_function(const String *db_name,
                                  const String *stored_func_name,
                                  uint serialization_version,
-                                 const String *serialialization)
+                                 const String *serialization)
 {
   Obj *obj= new StoredFuncObj(db_name, stored_func_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3255,10 +3255,10 @@ Obj *materialize_stored_function(const S
 Obj *materialize_event(const String *db_name,
                        const String *event_name,
                        uint serialization_version,
-                       const String *serialialization)
+                       const String *serialization)
 {
   Obj *obj= new EventObj(db_name, event_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3266,10 +3266,10 @@ Obj *materialize_event(const String *db_
 
 Obj *materialize_tablespace(const String *ts_name,
                             uint serialization_version,
-                            const String *serialialization)
+                            const String *serialization)
 {
   Obj *obj= new TablespaceObj(ts_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3293,7 +3293,7 @@ Obj *materialize_db_grant(const String *
     grants. We use DbGrantObj for all types of grants because
     we only have the GRANT statement in the serialization
     string and therefore do not that the 'parts' to create
-    the specific types. 
+    the specific types.
   */
   Obj *obj= get_db_grant(grantee, db_name);
   obj->materialize(serialization_version, serialization);
@@ -3383,10 +3383,7 @@ int split_user_host(String *grantee, Str
   return 0;
 }
 
-/*
-  Returns TRUE if user is defined on the system.
-*/
-bool user_exists(THD *thd, const String *grantee)
+bool check_user_existence(THD *thd, const String *grantee)
 {
   String user;
   String host;
@@ -3412,7 +3409,7 @@ bool user_exists(THD *thd, const String 
   Locate the row in the information_schema view for this tablespace.
 
   This method returns a row from a tablespace information_schema view
-  that matches the tablespace name passed. 
+  that matches the tablespace name passed.
 
   @param[in]     thd           Thread context
   @param[in]     is_table_idx  The information schema to search
@@ -3420,7 +3417,7 @@ bool user_exists(THD *thd, const String 
   @param[in]     ts_engine     Engine of the tablespace to find
   @param[out]    datafile      The datafile for the tablespace
   @param[out]    comments      The comments for the tablespace
-  
+
   @retval FALSE if tablespace exists and no errors
   @retval TRUE if tablespace does not exist or errors
 */
@@ -3529,14 +3526,14 @@ static bool find_tablespace_schema_row(T
   @param[out]    TablespaceObj A pointer to a new tablespace object
   @param[in]     ts_name       The name of the tablespace to find
   @param[in]     ts_engine     Engine of the tablespace to find
-  
+
   @note Caller is responsible for destroying the tablespace object.
 
   @retval FALSE if tablespace exists and no errors
   @retval TRUE if tablespace does not exist or errors
 */
 static bool get_tablespace_from_schema(THD *thd,
-                                       TablespaceObj **ts, 
+                                       TablespaceObj **ts,
                                        const String *ts_name,
                                        const String *ts_engine)
 {
@@ -3547,14 +3544,14 @@ static bool get_tablespace_from_schema(T
   /*
     Locate the row in TABLESPACES and get the comments.
   */
-  if (find_tablespace_schema_row(thd, SCH_TABLESPACES, 
+  if (find_tablespace_schema_row(thd, SCH_TABLESPACES,
       ts_name, ts_engine, &datafile, &comments))
     DBUG_RETURN(TRUE);
 
   /*
     Locate the row in FILES and get the datafile.
   */
-  if (find_tablespace_schema_row(thd, SCH_FILES, 
+  if (find_tablespace_schema_row(thd, SCH_FILES,
       ts_name, ts_engine, &datafile, &comments))
     DBUG_RETURN(TRUE);
 
@@ -3564,7 +3561,7 @@ static bool get_tablespace_from_schema(T
   if (datafile.length() == 0)
     DBUG_RETURN(TRUE);
 
-  DBUG_PRINT("get_tablespace_from_schema", (" Found tablespace %s %s", 
+  DBUG_PRINT("get_tablespace_from_schema", (" Found tablespace %s %s",
     ts_name->ptr(), datafile.ptr()));
 
   TablespaceObj *ts_local= new TablespaceObj(ts_name);
@@ -3578,20 +3575,20 @@ static bool get_tablespace_from_schema(T
 
 /**
   Retrieve the tablespace for a table if it exists
-  
+
   This method returns a @c TablespaceObj object if the table has a tablespace.
 
   @param[in]  thd       Thread context.
   @param[in]  db_name   The database name for the table.
   @param[in]  tbl_name  The table name.
-  
+
   @note Caller is responsible for destroying the object.
 
-  @retval Tablespace object if table uses a tablespace 
+  @retval Tablespace object if table uses a tablespace
   @retval NULL if table does not use a tablespace
 */
-Obj *get_tablespace_for_table(THD *thd, 
-                              const String *db_name, 
+Obj *get_tablespace_for_table(THD *thd,
+                              const String *db_name,
                               const String *tbl_name)
 {
   TablespaceObj *ts= NULL;
@@ -3599,7 +3596,7 @@ Obj *get_tablespace_for_table(THD *thd, 
   String ts_name, ts_engine;
   const char *ts_name_str= NULL;
   DBUG_ENTER("obs::get_tablespace_for_table()");
-  DBUG_PRINT("obs::get_tablespace_for_table", ("name: %s.%s", 
+  DBUG_PRINT("obs::get_tablespace_for_table", ("name: %s.%s",
              db_name->ptr(), tbl_name->ptr()));
 
   const char *db= db_name->ptr();
@@ -3641,12 +3638,12 @@ end:
   Determine if tablespace exists.
 
   This method determines if a materialized tablespace exists on the
-  system. This compares the name and all saved attributes of the 
+  system. This compares the name and all saved attributes of the
   tablespace. A FALSE return would mean either the tablespace does
   not exist or the tablespace attributes are different.
 
   @param[in]  Obj  The TablspaceObj pointer to compare.
-  
+
   @retval TRUE if it exists
   @retval FALSE if it does not exist
 */
@@ -3660,8 +3657,8 @@ bool tablespace_exists(THD *thd,
                              this_ts->get_engine());
   if (!other_ts)
     DBUG_RETURN(retval);
-  retval= (my_strcasecmp(system_charset_info, 
-           other_ts->build_serialization()->ptr(), 
+  retval= (my_strcasecmp(system_charset_info,
+           other_ts->build_serialization()->ptr(),
            ((TablespaceObj *)ts)->build_serialization()->ptr()) == 0);
   delete other_ts;
   DBUG_RETURN(retval);
@@ -3669,12 +3666,12 @@ bool tablespace_exists(THD *thd,
 
 /**
   Is there a tablespace with the given name?
-  
+
   This method determines if the tablespace referenced by name exists on the
   system. Returns a TablespaceObj if it exists or NULL if it doesn't.
 
   @param[in]  Obj  The TablspaceObj pointer to compare.
-  
+
   @note Caller is responsible for destroying the tablespace object.
 
   @returns the tablespace if found or NULL if not found
@@ -3695,12 +3692,12 @@ Obj *is_tablespace(THD *thd, Obj *ts)
   with the user.
 
   @param[in]  ts  The Tablspace to describe.
-  
+
   @returns tablespace description
 */
-const String *describe_tablespace(Obj *ts)
+const String *get_tablespace_description(Obj *ts)
 {
-  DBUG_ENTER("obs::describe_tablespace()");
+  DBUG_ENTER("obs::get_tablespace_description()");
   DBUG_RETURN(((TablespaceObj *)ts)->describe());
 }
 
@@ -3794,7 +3791,7 @@ TABLE_LIST *Name_locker::build_table_lis
   TABLE_LIST *tl= NULL;
   Obj *tbl= NULL;
   DBUG_ENTER("Name_locker::build_table_list()");
-  
+
   List_iterator<Obj> it(*tables);
   while ((tbl= it++))
   {

=== modified file 'sql/si_objects.h'
--- a/sql/si_objects.h	2008-09-11 16:28:29 +0000
+++ b/sql/si_objects.h	2008-10-17 11:28:25 +0000
@@ -19,10 +19,11 @@ namespace obs {
   Obj defines the basic set of operations for each database object.
 */
 
-class Obj { 
+class Obj
+{
 public:
 
-  bool serialize(THD *thd, String *serialialization);
+  bool serialize(THD *thd, String *serialization);
 
   /**
     Return the name of the object.
@@ -50,18 +51,18 @@ private:
     Read the object state from a given buffer and restores object state to
     the point, where it can be executed.
 
-    @param[in] serialialization_version The version of the serialization format.
-    @param[in] serialialization         Buffer contained serialized object.
+    @param[in] serialization_version The version of the serialization format.
+    @param[in] serialization         Buffer contained serialized object.
 
     @return error status.
       @retval FALSE on success.
       @retval TRUE on error.
   */
   virtual bool materialize(uint serialization_version,
-                           const String *serialialization) = 0;
+                           const String *serialization) = 0;
 
   /// Primitive implementing @c serialize() method.
-  virtual bool do_serialize(THD *thd, String *serialialization) = 0;
+  virtual bool do_serialize(THD *thd, String *serialization) = 0;
 
   /// Primitive implementing @c execute() method.
   virtual bool do_execute(THD *thd) = 0;
@@ -174,8 +175,8 @@ bool Obj::execute(THD *thd)
   the server must be able to materialize objects coded in any previous
   formats.
 
-  @param[in] thd              Server thread context.
-  @param[in] serialialization Buffer to serialize the object
+  @param[in] thd           Server thread context.
+  @param[in] serialization Buffer to serialize the object
 
   @return error status.
     @retval FALSE on success.
@@ -190,7 +191,7 @@ bool Obj::serialize(THD *thd, String *se
 {
   ulong saved_sql_mode= thd->variables.sql_mode;
   thd->variables.sql_mode= 0;
-  
+
   bool ret= do_serialize(thd, serialization);
 
   thd->variables.sql_mode= saved_sql_mode;
@@ -201,14 +202,14 @@ bool Obj::serialize(THD *thd, String *se
 ///////////////////////////////////////////////////////////////////////////
 
 /**
-  ObjIterator is a basic interface to enumerate the objects.
+  Obj_iterator is a basic interface to enumerate the objects.
 */
 
-class ObjIterator
+class Obj_iterator
 {
 public:
 
-  ObjIterator()
+  Obj_iterator()
   { }
 
   /**
@@ -223,7 +224,7 @@ public:
   virtual Obj *next() = 0;
 
 public:
-  virtual ~ObjIterator()
+  virtual ~Obj_iterator()
   { }
 
 };
@@ -232,12 +233,12 @@ public:
   GrantObjIternator is an encapsulation of the three iterators for each level
   of grant supported: database-, table- and routine-, and column-level.
 */
-class GrantObjIterator : public ObjIterator
+class GrantObjIterator : public Obj_iterator
 {
 public:
   GrantObjIterator(THD *thd, const String *db_name);
 
-  ~GrantObjIterator() 
+  ~GrantObjIterator()
   {
     delete db_grants;
     delete tbl_grants;
@@ -256,9 +257,9 @@ public:
   Obj *next();
 
 private:
-  ObjIterator *db_grants;  ///< database-level grants
-  ObjIterator *tbl_grants; ///< table- and routine-level grants
-  ObjIterator *col_grants; ///< column-level grants
+  Obj_iterator *db_grants;  ///< database-level grants
+  Obj_iterator *tbl_grants; ///< table- and routine-level grants
+  Obj_iterator *col_grants; ///< column-level grants
 };
 
 ///////////////////////////////////////////////////////////////////////////
@@ -400,7 +401,7 @@ Obj *get_event(const String *db_name, co
   @return a pointer to an iterator object.
 */
 
-ObjIterator *get_databases(THD *thd);
+Obj_iterator *get_databases(THD *thd);
 
 /**
   Create an iterator over all tables in the particular database.
@@ -411,7 +412,7 @@ ObjIterator *get_databases(THD *thd);
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_tables(THD *thd, const String *db_name);
+Obj_iterator *get_db_tables(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all views in the particular database.
@@ -422,7 +423,7 @@ ObjIterator *get_db_tables(THD *thd, con
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_views(THD *thd, const String *db_name);
+Obj_iterator *get_db_views(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all triggers in the particular database.
@@ -433,7 +434,7 @@ ObjIterator *get_db_views(THD *thd, cons
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_triggers(THD *thd, const String *db_name);
+Obj_iterator *get_db_triggers(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all stored procedures in the particular database.
@@ -444,7 +445,7 @@ ObjIterator *get_db_triggers(THD *thd, c
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_stored_procedures(THD *thd, const String *db_name);
+Obj_iterator *get_db_stored_procedures(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all stored functions in the particular database.
@@ -455,7 +456,7 @@ ObjIterator *get_db_stored_procedures(TH
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_stored_functions(THD *thd, const String *db_name);
+Obj_iterator *get_db_stored_functions(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all events in the particular database.
@@ -466,15 +467,15 @@ ObjIterator *get_db_stored_functions(THD
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_events(THD *thd, const String *db_name);
+Obj_iterator *get_db_events(THD *thd, const String *db_name);
 
 /*
   Creates a high-level iterator that iterates over database-, table-,
   routine-, and column-level privileges which shall permit a single
-  iterator from the si_objects to retrieve all of the privileges for 
+  iterator from the si_objects to retrieve all of the privileges for
   a given database.
 */
-ObjIterator *get_all_db_grants(THD *thd, const String *db_name);
+Obj_iterator *get_all_db_grants(THD *thd, const String *db_name);
 
 ///////////////////////////////////////////////////////////////////////////
 
@@ -491,9 +492,9 @@ ObjIterator *get_all_db_grants(THD *thd,
     @retval NULL in case of error.
 */
 
-ObjIterator* get_view_base_tables(THD *thd,
-                                  const String *db_name,
-                                  const String *view_name);
+Obj_iterator* get_view_base_tables(THD *thd,
+                                   const String *db_name,
+                                   const String *view_name);
 
 /**
   Create an iterator overl all base tables in the particular view.
@@ -504,9 +505,9 @@ ObjIterator* get_view_base_tables(THD *t
     @retval NULL in case of error.
 */
 
-ObjIterator* get_view_base_views(THD *thd,
-                                 const String *db_name,
-                                 const String *view_name);
+Obj_iterator* get_view_base_views(THD *thd,
+                                  const String *db_name,
+                                  const String *view_name);
 
 ///////////////////////////////////////////////////////////////////////////
 
@@ -517,41 +518,41 @@ ObjIterator* get_view_base_views(THD *th
 
 Obj *materialize_database(const String *db_name,
                           uint serialization_version,
-                          const String *serialialization);
+                          const String *serialization);
 
 Obj *materialize_table(const String *db_name,
                        const String *table_name,
                        uint serialization_version,
-                       const String *serialialization);
+                       const String *serialization);
 
 Obj *materialize_view(const String *db_name,
                       const String *view_name,
                       uint serialization_version,
-                      const String *serialialization);
+                      const String *serialization);
 
 Obj *materialize_trigger(const String *db_name,
                          const String *trigger_name,
                          uint serialization_version,
-                         const String *serialialization);
+                         const String *serialization);
 
 Obj *materialize_stored_procedure(const String *db_name,
                                   const String *stored_proc_name,
                                   uint serialization_version,
-                                  const String *serialialization);
+                                  const String *serialization);
 
 Obj *materialize_stored_function(const String *db_name,
                                  const String *stored_func_name,
                                  uint serialization_version,
-                                 const String *serialialization);
+                                 const String *serialization);
 
 Obj *materialize_event(const String *db_name,
                        const String *event_name,
                        uint serialization_version,
-                       const String *serialialization);
+                       const String *serialization);
 
 Obj *materialize_tablespace(const String *ts_name,
                             uint serialization_version,
-                            const String *serialialization);
+                            const String *serialization);
 
 Obj *materialize_db_grant(const String *grantee,
                           const String *db_name,
@@ -560,6 +561,14 @@ Obj *materialize_db_grant(const String *
 
 ///////////////////////////////////////////////////////////////////////////
 
+/**
+  Check if the given database name is reserved for internal use.
+
+  @return
+    @retval TRUE if the given database name is reserved for internal use
+    @retval FALSE otherwise.
+*/
+
 bool is_internal_db_name(const String *db_name);
 
 ///////////////////////////////////////////////////////////////////////////
@@ -571,40 +580,49 @@ bool is_internal_db_name(const String *d
     @retval FALSE on success (the database exists and accessible).
     @retval TRUE on error (the database either not exists, or not accessible).
 */
+
 bool check_db_existence(const String *db_name);
 
 /*
-  Returns TRUE if user is defined on the system.
+  Check if the given user is actually defined on the system.
+
+  @return Existence status.
+    @retval TRUE if user is defined on the system.
+    @retval FALSE if user does not exist.
 */
-bool user_exists(THD *thd, const String *grantee);
+
+bool check_user_existence(THD *thd, const String *grantee);
 
 /*
   This method returns a @c TablespaceObj object if the table has a tablespace.
 */
-Obj *get_tablespace_for_table(THD *thd, 
-                              const String *db_name, 
+
+Obj *get_tablespace_for_table(THD *thd,
+                              const String *db_name,
                               const String *tbl_name);
 
 /*
   This method determines if a materialized tablespace exists on the
-  system. This compares the name and all saved attributes of the 
+  system. This compares the name and all saved attributes of the
   tablespace. A FALSE return would mean either the tablespace does
   not exist or the tablespace attributes are different.
 */
-bool tablespace_exists(THD *thd,
-                       Obj *ts);
+
+bool tablespace_exists(THD *thd, Obj *ts);
 
 /*
   This method determines if the tablespace referenced by name exists on the
   system. Returns a TablespaceObj if it exists or NULL if it doesn't.
 */
+
 Obj *is_tablespace(THD *thd, Obj *ts);
 
-/*
-  This method returns a description of the tablespace useful for communicating
-  with the user.
+/**
+  Return a description of the tablespace useful for communicating with the
+  user.
 */
-const String *describe_tablespace(Obj *ts);
+
+const String *get_tablespace_description(Obj *ts);
 
 ///////////////////////////////////////////////////////////////////////////
 
@@ -656,22 +674,22 @@ void ddl_blocker_exception_off(THD *thd)
   Creates a WHERE clause for information schema table lookups of the
   for FROM INFORMATION_SCHEMA.X WHERE <db_col> IN ('a','b','c').
 */
-COND *create_db_select_condition(THD *thd, 
+COND *create_db_select_condition(THD *thd,
                                  TABLE *t,
                                  List<LEX_STRING> *db_list);
 
 /*
   The following class is used to manage name locks on a list of tables.
 
-  This class uses a list of type List<Obj> to establish the table list 
+  This class uses a list of type List<Obj> to establish the table list
   that will be used to manage locks on the tables.
 */
 class Name_locker
 {
 public:
   Name_locker(THD *thd) { m_thd= thd; }
-  ~Name_locker() 
-  { 
+  ~Name_locker()
+  {
     free_table_list(m_table_list);
     m_table_list= NULL;
   }

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2008-10-08 09:27:11 +0000
+++ b/sql/sp_head.cc	2008-10-17 17:47:16 +0000
@@ -2901,7 +2901,14 @@ sp_instr_stmt::print(String *str)
 int
 sp_instr_stmt::exec_core(THD *thd, uint *nextp)
 {
+  MYSQL_QUERY_EXEC_START(thd->query,
+                         thd->thread_id,
+                         (char *) (thd->db ? thd->db: ""),
+                         thd->security_ctx->priv_user,
+                         (char *) thd->security_ctx->host_or_ip,
+                         3);
   int res= mysql_execute_command(thd);
+  MYSQL_QUERY_EXEC_DONE(res);
   *nextp= m_ip+1;
   return res;
 }

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2008-09-30 14:07:24 +0000
+++ b/sql/sql_cache.cc	2008-10-17 17:47:16 +0000
@@ -1482,12 +1482,14 @@ def_week_frmt: %lu",                    
   thd->status_var.last_query_cost= 0.0;
   thd->main_da.disable_status();
 
+  MYSQL_QUERY_CACHE_HIT(thd->query, (ulong) thd->limit_found_rows);
   BLOCK_UNLOCK_RD(query_block);
   DBUG_RETURN(1);				// Result sent to client
 
 err_unlock:
   STRUCT_UNLOCK(&structure_guard_mutex);
 err:
+  MYSQL_QUERY_CACHE_MISS(thd->query);
   DBUG_RETURN(0);				// Query was not cached
 }
 

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2008-10-08 15:29:55 +0000
+++ b/sql/sql_class.cc	2008-10-21 12:38:13 +0000
@@ -3517,7 +3517,7 @@ int THD::binlog_delete_row(TABLE* table,
 
 int THD::binlog_remove_pending_rows_event(bool clear_maps)
 {
-  DBUG_ENTER(__FUNCTION__);
+  DBUG_ENTER("THD::binlog_remove_pending_rows_event");
 
   if (!mysql_bin_log.is_open())
     DBUG_RETURN(0);

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2008-07-23 08:52:08 +0000
+++ b/sql/sql_connect.cc	2008-10-17 17:47:16 +0000
@@ -1144,6 +1144,9 @@ pthread_handler_t handle_one_connection(
     if (login_connection(thd))
       goto end_thread;
 
+    MYSQL_CONNECTION_START(thd->thread_id, thd->security_ctx->priv_user,
+                           (char *) thd->security_ctx->host_or_ip);
+  
     prepare_new_connection_state(thd);
 
     while (!net->error && net->vio != 0 &&

=== modified file 'sql/sql_cursor.cc'
--- a/sql/sql_cursor.cc	2008-09-04 18:30:34 +0000
+++ b/sql/sql_cursor.cc	2008-10-10 16:23:30 +0000
@@ -167,8 +167,14 @@ int mysql_open_cursor(THD *thd, uint fla
     thd->lock_id= sensitive_cursor->get_lock_id();
     thd->cursor= sensitive_cursor;
   }
-
+  MYSQL_QUERY_EXEC_START(thd->query,
+                         thd->thread_id,
+                         (char *) (thd->db ? thd->db : ""),
+                         thd->security_ctx->priv_user,
+                         (char *) thd->security_ctx->host_or_ip,
+                         2);
   rc= mysql_execute_command(thd);
+  MYSQL_QUERY_EXEC_DONE(rc);
 
   lex->result= save_result;
   thd->lock_id= &thd->main_lock_id;

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2008-07-26 16:38:20 +0000
+++ b/sql/sql_delete.cc	2008-10-10 16:23:30 +0000
@@ -37,7 +37,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
                   bool reset_auto_increment)
 {
   bool          will_batch;
-  int		error, loc_error;
+  int		error, loc_error, res;
   TABLE		*table;
   SQL_SELECT	*select=0;
   READ_RECORD	info;
@@ -52,11 +52,15 @@ bool mysql_delete(THD *thd, TABLE_LIST *
   DBUG_ENTER("mysql_delete");
 
   if (open_and_lock_tables(thd, table_list))
+  {
+    MYSQL_DELETE_DONE(1, 0);
     DBUG_RETURN(TRUE);
+  }
   if (!(table= table_list->table))
   {
     my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
 	     table_list->view_db.str, table_list->view_name.str);
+    MYSQL_DELETE_DONE(1, 0);
     DBUG_RETURN(TRUE);
   }
   thd_proc_info(thd, "init");
@@ -160,7 +164,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
   {
     free_underlaid_joins(thd, select_lex);
     thd->row_count_func= 0;
-    MYSQL_DELETE_END();
+    MYSQL_DELETE_DONE(0, 0);
     my_ok(thd, (ha_rows) thd->row_count_func);  // No matching records
     DBUG_RETURN(0);
   }
@@ -178,7 +182,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
     delete select;
     free_underlaid_joins(thd, select_lex);
     thd->row_count_func= 0;
-    MYSQL_DELETE_END();
+    MYSQL_DELETE_DONE(0, 0);
     my_ok(thd, (ha_rows) thd->row_count_func);
     /*
       We don't need to call reset_auto_increment in this case, because
@@ -401,17 +405,18 @@ cleanup:
 
   DEBUG_SYNC(thd, "at_delete_end");
 
-  MYSQL_DELETE_END();
   if (error < 0 || (thd->lex->ignore && !thd->is_fatal_error))
   {
     thd->row_count_func= deleted;
     my_ok(thd, (ha_rows) thd->row_count_func);
     DBUG_PRINT("info",("%ld records deleted",(long) deleted));
   }
-  DBUG_RETURN(error >= 0 || thd->is_error());
+  res= error >= 0 || thd->is_error();
+  MYSQL_DELETE_DONE(res, (ulong) deleted);
+  DBUG_RETURN(res);
 
 err:
-  MYSQL_DELETE_END();
+  MYSQL_DELETE_DONE(1, 0);
   DBUG_RETURN(TRUE);
 }
 
@@ -745,6 +750,7 @@ bool multi_delete::send_data(List<Item> 
       }
     }
   }
+  MYSQL_MULTI_DELETE_DONE(0, (ulong) deleted);
   DBUG_RETURN(0);
 }
 

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2008-10-08 11:46:49 +0000
+++ b/sql/sql_insert.cc	2008-10-17 17:47:16 +0000
@@ -605,18 +605,25 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
   {
     my_error(ER_DELAYED_INSERT_TABLE_LOCKED, MYF(0),
              table_list->table_name);
+    MYSQL_INSERT_DONE(1, 0);
     DBUG_RETURN(TRUE);
   }
 
   if (table_list->lock_type == TL_WRITE_DELAYED)
   {
     if (open_and_lock_for_insert_delayed(thd, table_list))
+    {
+      MYSQL_INSERT_DONE(1, 0);
       DBUG_RETURN(TRUE);
+    }
   }
   else
   {
     if (open_and_lock_tables(thd, table_list))
+    {
+      MYSQL_INSERT_DONE(1, 0);
       DBUG_RETURN(TRUE);
+    }
   }
   lock_type= table_list->lock_type;
 
@@ -987,7 +994,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
     ::my_ok(thd, (ulong) thd->row_count_func, id, buff);
   }
   thd->abort_on_warning= 0;
-  MYSQL_INSERT_END();
+  MYSQL_INSERT_DONE(0, (ulong) thd->row_count_func);
   DBUG_RETURN(FALSE);
 
 abort:
@@ -1000,7 +1007,7 @@ abort:
   if (!joins_freed)
     free_underlaid_joins(thd, &thd->lex->select_lex);
   thd->abort_on_warning= 0;
-  MYSQL_INSERT_END();
+  MYSQL_INSERT_DONE(1, 0);
   DBUG_RETURN(TRUE);
 }
 
@@ -3257,6 +3264,7 @@ bool select_insert::send_eof()
   if (error)
   {
     table->file->print_error(error,MYF(0));
+    MYSQL_INSERT_SELECT_DONE(error, 0);
     DBUG_RETURN(1);
   }
   char buff[160];
@@ -3276,6 +3284,7 @@ bool select_insert::send_eof()
      thd->first_successful_insert_id_in_prev_stmt :
      (info.copied ? autoinc_value_of_last_inserted_row : 0));
   ::my_ok(thd, (ulong) thd->row_count_func, id, buff);
+  MYSQL_INSERT_SELECT_DONE(0, (ulong) thd->row_count_func);
   DBUG_RETURN(0);
 }
 
@@ -3329,6 +3338,12 @@ void select_insert::abort() {
     table->file->ha_release_auto_increment();
   }
 
+  if (MYSQL_INSERT_SELECT_DONE_ENABLED())
+  {
+    MYSQL_INSERT_SELECT_DONE(0, (ulong) (info.copied + info.deleted +
+                                         info.updated));
+  }
+
   DBUG_VOID_RETURN;
 }
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-10-08 11:46:49 +0000
+++ b/sql/sql_parse.cc	2008-10-17 17:47:16 +0000
@@ -794,7 +794,10 @@ bool dispatch_command(enum enum_server_c
 #if defined(ENABLED_PROFILING)
   thd->profiling.start_new_query();
 #endif
-
+  MYSQL_COMMAND_START(thd->thread_id, command,
+                      thd->security_ctx->priv_user,
+                      (char *) thd->security_ctx->host_or_ip);
+  
   thd->command=command;
   /*
     Commands which always take a long time are logged into
@@ -986,6 +989,10 @@ bool dispatch_command(enum enum_server_c
   {
     if (alloc_query(thd, packet, packet_length))
       break;					// fatal error is set
+    MYSQL_QUERY_START(thd->query, thd->thread_id,
+                      (char *) (thd->db ? thd->db : ""),
+                      thd->security_ctx->priv_user,
+                      (char *) thd->security_ctx->host_or_ip);
     char *packet_end= thd->query + thd->query_length;
     /* 'b' stands for 'buffer' parameter', special for 'my_snprintf' */
     const char* end_of_stmt= NULL;
@@ -1026,12 +1033,22 @@ bool dispatch_command(enum enum_server_c
         length--;
       }
 
+      if (MYSQL_QUERY_DONE_ENABLED())
+      {
+        MYSQL_QUERY_DONE(thd->is_error());
+      }
+      
 #if defined(ENABLED_PROFILING)
       thd->profiling.finish_current_query();
       thd->profiling.start_new_query("continuing");
       thd->profiling.set_query_source(beginning_of_next_stmt, length);
 #endif
 
+      MYSQL_QUERY_START(thd->query, thd->thread_id,
+                        (char *) (thd->db ? thd->db : ""),
+                        thd->security_ctx->priv_user,
+                        (char *) thd->security_ctx->host_or_ip);
+      
       pthread_mutex_lock(&LOCK_thread_count);
       thd->query_length= length;
       thd->query= beginning_of_next_stmt;
@@ -1419,7 +1436,17 @@ bool dispatch_command(enum enum_server_c
 #if defined(ENABLED_PROFILING)
   thd->profiling.finish_current_query();
 #endif
-
+  if (MYSQL_QUERY_DONE_ENABLED() || MYSQL_COMMAND_DONE_ENABLED())
+  {
+    int res;
+    res= (int) thd->is_error();
+    if (command == COM_QUERY)
+    {
+      MYSQL_QUERY_DONE(res);
+    }
+    MYSQL_COMMAND_DONE(res);
+  }
+  
   DBUG_RETURN(error);
 }
 
@@ -2858,6 +2885,7 @@ ddl_blocker_err:
       break;
     DBUG_ASSERT(select_lex->offset_limit == 0);
     unit->set_limit(select_lex);
+    MYSQL_UPDATE_START(thd->query);
     res= (up_result= mysql_update(thd, all_tables,
                                   select_lex->item_list,
                                   lex->value_list,
@@ -2917,7 +2945,7 @@ ddl_blocker_err:
 #ifdef HAVE_REPLICATION
     }  /* unlikely */
 #endif
-
+    MYSQL_MULTI_UPDATE_START(thd->query);
     res= mysql_multi_update(thd, all_tables,
                             &select_lex->item_list,
                             &lex->value_list,
@@ -2970,6 +2998,7 @@ ddl_blocker_err:
       break;
     }
 
+    MYSQL_INSERT_START(thd->query);
     res= mysql_insert(thd, all_tables, lex->field_list, lex->many_values,
 		      lex->update_list, lex->value_list,
                       lex->duplicates, lex->ignore);
@@ -3013,6 +3042,8 @@ ddl_blocker_err:
 
     if (!(res= open_and_lock_tables(thd, all_tables)))
     {
+      MYSQL_INSERT_SELECT_START(thd->query);
+      
       /* Skip first table, which is the table we are inserting in */
       TABLE_LIST *second_table= first_table->next_local;
       select_lex->table_list.first= (uchar*) second_table;
@@ -3097,6 +3128,7 @@ ddl_blocker_err:
       break;
     }
 
+    MYSQL_DELETE_START(thd->query);
     res = mysql_delete(thd, all_tables, select_lex->where,
                        &select_lex->order_list,
                        unit->select_limit_cnt, select_lex->options,
@@ -3127,6 +3159,7 @@ ddl_blocker_err:
       goto error;
 
     thd_proc_info(thd, "init");
+    MYSQL_MULTI_DELETE_START(thd->query);
     if ((res= open_and_lock_tables(thd, all_tables)))
       break;
 
@@ -5516,6 +5549,7 @@ void mysql_init_multi_delete(LEX *lex)
 void mysql_parse(THD *thd, const char *inBuf, uint length,
                  const char ** found_semicolon)
 {
+  int error;
   DBUG_ENTER("mysql_parse");
 
   DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on(););
@@ -5584,7 +5618,15 @@ void mysql_parse(THD *thd, const char *i
             thd->server_status|= SERVER_MORE_RESULTS_EXISTS;
           }
           lex->set_trg_event_type_for_tables();
-          mysql_execute_command(thd);
+	  MYSQL_QUERY_EXEC_START(thd->query,
+                                 thd->thread_id,
+                                 (char *) (thd->db ? thd->db : ""),
+                                 thd->security_ctx->priv_user,
+                                 (char *) thd->security_ctx->host_or_ip,
+                                 0);
+
+          error= mysql_execute_command(thd);
+	  MYSQL_QUERY_EXEC_DONE(error);
 	}
       }
     }
@@ -7518,6 +7560,8 @@ bool parse_sql(THD *thd,
   bool mysql_parse_status;
   DBUG_ASSERT(thd->m_parser_state == NULL);
 
+  MYSQL_QUERY_PARSE_START(thd->query);
+  
   /* Backup creation context. */
 
   Object_creation_ctx *backup_ctx= NULL;
@@ -7549,6 +7593,8 @@ bool parse_sql(THD *thd,
 
   /* That's it. */
 
+  MYSQL_QUERY_PARSE_DONE(mysql_parse_status || thd->is_fatal_error);
+  
   return mysql_parse_status || thd->is_fatal_error;
 }
 

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2008-08-07 17:52:43 +0000
+++ b/sql/sql_prepare.cc	2008-10-10 16:23:30 +0000
@@ -3568,7 +3568,14 @@ bool Prepared_statement::execute(String 
     if (query_cache_send_result_to_client(thd, thd->query,
                                           thd->query_length) <= 0)
     {
+      MYSQL_QUERY_EXEC_START(thd->query,
+                             thd->thread_id,
+                             (char *) (thd->db ? thd->db : ""),
+                             thd->security_ctx->priv_user,
+                             (char *) thd->security_ctx->host_or_ip,
+                             1);
       error= mysql_execute_command(thd);
+      MYSQL_QUERY_EXEC_DONE(error);
     }
   }
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-10-03 09:55:06 +0000
+++ b/sql/sql_select.cc	2008-10-17 17:47:16 +0000
@@ -31,6 +31,7 @@
 #include "mysql_priv.h"
 #include "sql_select.h"
 #include "sql_cursor.h"
+
 #include <m_ctype.h>
 #include <my_bit.h>
 #include <hash.h>
@@ -271,7 +272,7 @@ bool handle_select(THD *thd, LEX *lex, s
   bool res;
   register SELECT_LEX *select_lex = &lex->select_lex;
   DBUG_ENTER("handle_select");
-  MYSQL_SELECT_START();
+  MYSQL_SELECT_START(thd->query);
 
   if (select_lex->master_unit()->is_union() || 
       select_lex->master_unit()->fake_select_lex)
@@ -305,7 +306,8 @@ bool handle_select(THD *thd, LEX *lex, s
   if (unlikely(res))
     result->abort();
 
-  MYSQL_SELECT_END();
+  MYSQL_SELECT_DONE((int) res, (ulong) thd->limit_found_rows);
+
   DBUG_RETURN(res);
 }
 

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2008-10-08 11:46:49 +0000
+++ b/sql/sql_table.cc	2008-10-16 12:18:07 +0000
@@ -7024,7 +7024,6 @@ view_err:
   /* Copy the data if necessary. */
   thd->count_cuted_fields= CHECK_FIELD_WARN;	// calc cuted fields
   thd->cuted_fields=0L;
-  thd_proc_info(thd, "copy to tmp table");
   copied=deleted=0;
   /*
     We do not copy data for MERGE tables. Only the children have data.
@@ -7035,6 +7034,7 @@ view_err:
     /* We don't want update TIMESTAMP fields during ALTER TABLE. */
     new_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
     new_table->next_number_field=new_table->found_next_number_field;
+    thd_proc_info(thd, "copy to tmp table");
     error= copy_data_between_tables(table, new_table,
                                     alter_info->create_list, ignore,
                                    order_num, order, &copied, &deleted,
@@ -7604,6 +7604,12 @@ bool mysql_checksum_table(THD *thd, TABL
 	{
 	  for (;;)
 	  {
+            if (thd->killed)
+            {
+              t->file->ha_rnd_end();
+              thd->protocol->remove_last_row();
+              goto err;
+            }
 	    ha_checksum row_crc= 0;
             int error= t->file->rnd_next(t->record[0]);
             if (unlikely(error))

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2008-10-09 16:13:03 +0000
+++ b/sql/sql_update.cc	2008-10-17 17:47:16 +0000
@@ -209,7 +209,10 @@ int mysql_update(THD *thd,
   for ( ; ; )
   {
     if (open_tables(thd, &table_list, &table_count, 0))
+    {
+      MYSQL_UPDATE_DONE(1, 0, 0);
       DBUG_RETURN(1);
+    }
 
     if (table_list->multitable_view)
     {
@@ -218,21 +221,27 @@ int mysql_update(THD *thd,
       /* pass counter value */
       thd->lex->table_count= table_count;
       /* convert to multiupdate */
+      MYSQL_UPDATE_DONE(2, 0, 0);
       DBUG_RETURN(2);
     }
     if (!lock_tables(thd, table_list, table_count, 0, &need_reopen))
       break;
     if (!need_reopen)
+    {
+      MYSQL_UPDATE_DONE(1, 0, 0);
       DBUG_RETURN(1);
+    }
     close_tables_for_reopen(thd, &table_list, FALSE);
   }
 
   if (mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
       (thd->fill_derived_tables() &&
        mysql_handle_derived(thd->lex, &mysql_derived_filling)))
+  {
+    MYSQL_UPDATE_DONE(1, 0, 0);
     DBUG_RETURN(1);
+  }
 
-  MYSQL_UPDATE_START();
   thd_proc_info(thd, "init");
   table= table_list->table;
 
@@ -292,7 +301,7 @@ int mysql_update(THD *thd,
   if (select_lex->inner_refs_list.elements &&
     fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array))
   {
-    MYSQL_UPDATE_END();
+    MYSQL_UPDATE_DONE(1, 0, 0);
     DBUG_RETURN(-1);
   }
 
@@ -321,8 +330,8 @@ int mysql_update(THD *thd,
   if (prune_partitions(thd, table, conds))
   {
     free_underlaid_joins(thd, select_lex);
-    MYSQL_UPDATE_END();
     my_ok(thd);				// No matching records
+    MYSQL_UPDATE_DONE(0, 0, 0);
     DBUG_RETURN(0);
   }
 #endif
@@ -337,8 +346,8 @@ int mysql_update(THD *thd,
     free_underlaid_joins(thd, select_lex);
     if (error)
       goto abort;				// Error in where
-    MYSQL_UPDATE_END();
     my_ok(thd);				// No matching records
+    MYSQL_UPDATE_DONE(0, 0, 0);
     DBUG_RETURN(0);
   }
   if (!select && limit != HA_POS_ERROR)
@@ -811,7 +820,6 @@ int mysql_update(THD *thd,
   id= thd->arg_of_last_insert_id_function ?
     thd->first_successful_insert_id_in_prev_stmt : 0;
 
-  MYSQL_UPDATE_END();
   if (error < 0)
   {
     char buff[STRING_BUFFER_USUAL_SIZE];
@@ -824,7 +832,10 @@ int mysql_update(THD *thd,
   }
   thd->count_cuted_fields= CHECK_FIELD_IGNORE;		/* calc cuted fields */
   thd->abort_on_warning= 0;
-  DBUG_RETURN((error >= 0 || thd->is_error()) ? 1 : 0);
+
+  res= (error >= 0 || thd->is_error()) ? 1 : 0;
+  MYSQL_UPDATE_DONE(res, (ulong) found, (ulong) updated);
+  DBUG_RETURN(res);
 
 err:
   delete select;
@@ -837,7 +848,7 @@ err:
   thd->abort_on_warning= 0;
 
 abort:
-  MYSQL_UPDATE_END();
+  MYSQL_UPDATE_DONE(1, 0, 0);
   DBUG_RETURN(1);
 }
 
@@ -1622,7 +1633,10 @@ bool multi_update::send_data(List<Item> 
                                                *values_for_table[offset], 0,
                                                table->triggers,
                                                TRG_EVENT_UPDATE))
+      {
+        MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
 	DBUG_RETURN(1);
+      }
 
       found++;
       if (!can_compare_record || compare_record(table))
@@ -1635,7 +1649,10 @@ bool multi_update::send_data(List<Item> 
           if (error == VIEW_CHECK_SKIP)
             continue;
           else if (error == VIEW_CHECK_ERROR)
+          {
+            MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
             DBUG_RETURN(1);
+          }
         }
         if (!updated++)
         {
@@ -1665,6 +1682,7 @@ bool multi_update::send_data(List<Item> 
 
             prepare_record_for_error_message(error, table);
             table->file->print_error(error,MYF(flags));
+            MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
             DBUG_RETURN(1);
           }
         }
@@ -1689,7 +1707,10 @@ bool multi_update::send_data(List<Item> 
       if (table->triggers &&
           table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
                                             TRG_ACTION_AFTER, TRUE))
+      {
+        MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
         DBUG_RETURN(1);
+      }
     }
     else
     {
@@ -1732,12 +1753,14 @@ bool multi_update::send_data(List<Item> 
                                          error, 1))
         {
           do_update=0;
+          MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
 	  DBUG_RETURN(1);			// Not a table_is_full error
 	}
         found++;
       }
     }
   }
+  MYSQL_UPDATE_DONE(0, (ulong) found, (ulong) updated);
   DBUG_RETURN(0);
 }
 

=== modified file 'storage/falcon/Bitmap.cpp'
--- a/storage/falcon/Bitmap.cpp	2008-10-18 03:46:34 +0000
+++ b/storage/falcon/Bitmap.cpp	2008-10-23 20:10:01 +0000
@@ -722,7 +722,7 @@ void Bitmap::unitTest(void)
 		tester->set(bitNumber);
 		}
 
-	for (int bitNumber = 0; (bitNumber = tester->nextSet(0)) >= 0;)
+	for (bitNumber = 0; (bitNumber = tester->nextSet(0)) >= 0;)
 		{
 		if (!tester->isSet(bitNumber))
 			Log::log("** Error - %d should be set\n", bitNumber);
@@ -750,7 +750,7 @@ void Bitmap::unitTest(void)
 		tester->set(bitNumber);
 		}
 
-	for (int bitNumber = 0; (bitNumber = tester->nextSet(bitNumber)) >= 0;)
+	for (bitNumber = 0; (bitNumber = tester->nextSet(bitNumber)) >= 0;)
 		{
 		Log::log("Clearing bit %d\n", bitNumber);
 		tester->clear(bitNumber);
@@ -773,13 +773,13 @@ void Bitmap::unitTest(void)
 		tester->set(bitNumber);
 		}
 
-	for (int bitNumber = 0; (bitNumber = tester->nextSet( pseudoRand(bitNumber, 1800000))) >= 0;)
+	for (bitNumber = 0; (bitNumber = tester->nextSet( pseudoRand(bitNumber, 1800000))) >= 0;)
 		{
 		Log::log("Clearing bit %d\n", bitNumber);
 		tester->clear(bitNumber);
 		}
 
-	for (int bitNumber = 0; (bitNumber = tester->nextSet(0)) >= 0;)
+	for (bitNumber = 0; (bitNumber = tester->nextSet(0)) >= 0;)
 		{
 		Log::log("Clearing bit %d\n", bitNumber);
 		tester->clear(bitNumber);

=== modified file 'storage/falcon/Cache.cpp'
--- a/storage/falcon/Cache.cpp	2008-10-02 23:06:04 +0000
+++ b/storage/falcon/Cache.cpp	2008-10-23 07:58:38 +0000
@@ -934,7 +934,15 @@ void Cache::ioThread(void)
 					Log::log(LogInfo, "%d: Cache flush: %d pages, %d writes in %d seconds (%d pps)\n",
 								database->deltaTime, pages, writes, delta, pages / MAX(delta, 1));
 
-				database->pageCacheFlushed(flushArg);
+				try
+					{
+					database->pageCacheFlushed(flushArg);
+					}
+				catch (...)
+					{
+					// Ignores any errors from writing the checkpoint
+					// log record (ie. if we have issues with the serial log)
+					}
 				}
 			else
 				flushLock.unlock();

=== modified file 'storage/falcon/Database.cpp'
--- a/storage/falcon/Database.cpp	2008-10-16 02:40:08 +0000
+++ b/storage/falcon/Database.cpp	2008-10-23 07:58:38 +0000
@@ -2434,7 +2434,16 @@ void Database::updateCardinalities(void)
 	syncTbl.unlock();
 	syncDDL.unlock();
 
-	commitSystemTransaction();
+	try
+		{
+		commitSystemTransaction();
+		}
+	catch (...)
+		{
+		// Ignores any errors from committing the updates of the cardinalities
+		// Situations where this might happen can be due to problems with
+		// writing to the serial log
+		}
 }
 
 void Database::sync()

=== modified file 'storage/falcon/NNode.h'
--- a/storage/falcon/NNode.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/NNode.h	2008-09-20 23:20:02 +0000
@@ -109,7 +109,7 @@ enum NType {
 	Cast,
 	BlobRef,
 	Upper,
-	Lower,
+	Lower
    };
 
 class NNode  

=== modified file 'storage/falcon/StorageConnection.cpp'
--- a/storage/falcon/StorageConnection.cpp	2008-03-11 16:15:47 +0000
+++ b/storage/falcon/StorageConnection.cpp	2008-10-23 07:58:38 +0000
@@ -133,6 +133,8 @@ void StorageConnection::close(void)
 
 int StorageConnection::commit(void)
 {
+	int errorCode = 0;
+
 	if (connection)
 		{
 		if (traceStream)
@@ -142,15 +144,22 @@ int StorageConnection::commit(void)
 			
 			traceStream->clear();
 			}
-		
-		connection->commit();
+
+		try
+			{
+			connection->commit();
+			}
+		catch (SQLException& exception)
+			{
+			errorCode = translateError(exception, StorageErrorIOErrorSerialLog);
+			}
 		}
 	
 	transactionActive = false;
 	implicitTransactionCount = 0;
 	verbMark = 0;
 	
-	return 0;
+	return errorCode;
 }
 
 int StorageConnection::prepare(int xidLength, const UCHAR *xid)
@@ -165,6 +174,8 @@ int StorageConnection::prepare(int xidLe
 
 int StorageConnection::rollback(void)
 {
+	int errorCode = 0;
+
 	if (connection)
 		{
 		if (traceStream)
@@ -174,14 +185,22 @@ int StorageConnection::rollback(void)
 			
 			traceStream->clear();
 			}
-		connection->rollback();
+
+		try
+			{
+			connection->rollback();
+			}
+		catch (SQLException& exception)
+			{
+			errorCode = translateError(exception, StorageErrorIOErrorSerialLog);
+			}
 		}
 	
 	transactionActive = false;
 	implicitTransactionCount = 0;
 	verbMark = 0;
 	
-	return 0;
+	return errorCode;
 }
 
 int StorageConnection::startTransaction(int isolationLevel)
@@ -321,10 +340,16 @@ int StorageConnection::startImplicitTran
 	return false;
 }
 
-void StorageConnection::endImplicitTransaction(void)
+int StorageConnection::endImplicitTransaction(void)
 {
+	int errorCode = 0;
+
 	if (implicitTransactionCount > 0 && --implicitTransactionCount == 0)
-		commit();		
+		{
+		errorCode = commit();
+		}
+
+	return errorCode;
 }
 
 int StorageConnection::markVerb(void)
@@ -339,13 +364,22 @@ int StorageConnection::markVerb(void)
 	return false;
 }
 
-void StorageConnection::rollbackVerb(void)
+int StorageConnection::rollbackVerb(void)
 {
 	if (verbMark)
 		{
-		savepointRollback(verbMark);
-		verbMark = 0;
+		try
+			{
+			savepointRollback(verbMark);
+			verbMark = 0;
+			}
+		catch (SQLException& exception)
+			{
+			return translateError(exception, StorageErrorIOErrorSerialLog);
+			}
 		}
+
+	return 0;
 }
 
 void StorageConnection::releaseVerb(void)
@@ -416,3 +450,26 @@ void StorageConnection::validate(int opt
 	
 	connection->validate(flags);
 }
+
+int StorageConnection::translateError(SQLException& exception, int defaultStorageError)
+{
+	// This method is inspired by the corresponding method in
+	// StorageTable::translateError.
+
+	int errorCode;
+	int sqlCode = exception.getSqlcode();
+
+	switch (sqlCode)
+		{
+		case IO_ERROR_SERIALLOG:
+			errorCode = StorageErrorIOErrorSerialLog;
+			break;
+
+		default:
+			errorCode = defaultStorageError;
+		}
+
+	setErrorText(&exception);
+
+	return errorCode;
+}

=== modified file 'storage/falcon/StorageConnection.h'
--- a/storage/falcon/StorageConnection.h	2008-03-11 16:15:47 +0000
+++ b/storage/falcon/StorageConnection.h	2008-10-23 07:58:38 +0000
@@ -54,12 +54,12 @@ public:
 	virtual int		rollback(void);
 	virtual int		startTransaction(int isolationLevel);
 	virtual int		startImplicitTransaction(int isolationLevel);
-	virtual void	endImplicitTransaction(void);
+	virtual int 	endImplicitTransaction(void);
 	virtual int		savepointSet();
 	virtual int		savepointRelease(int savePoint);
 	virtual int		savepointRollback(int savePoint);
 	virtual int		markVerb();
-	virtual void	rollbackVerb();
+	virtual int	    rollbackVerb();
 	virtual void	releaseVerb();
 	virtual void	addRef(void);
 	virtual void	release(void);
@@ -81,6 +81,7 @@ public:
 	void			setMySqlThread(THD* thd);
 	void			setCurrentStatement(const char* text);
 	Transaction*	getTransaction(void);
+	int				translateError(SQLException& exception, int defaultStorageError);
 	
 	Connection		*connection;
 	Database		*database;

=== modified file 'storage/falcon/StorageTable.cpp'
--- a/storage/falcon/StorageTable.cpp	2008-10-14 13:00:31 +0000
+++ b/storage/falcon/StorageTable.cpp	2008-10-22 20:44:09 +0000
@@ -146,9 +146,9 @@ int StorageTable::createIndex(StorageInd
 	return share->createIndex(storageConnection, indexDesc, sql);
 }
 
-int StorageTable::dropIndex(StorageIndexDesc *indexDesc, const char *sql)
+int StorageTable::dropIndex(StorageIndexDesc *indexDesc, const char *sql, bool online)
 {
-	return share->dropIndex(storageConnection, indexDesc, sql);
+	return share->dropIndex(storageConnection, indexDesc, sql, online);
 }
 
 int StorageTable::next(int recordNumber, bool lockForUpdate)

=== modified file 'storage/falcon/StorageTable.h'
--- a/storage/falcon/StorageTable.h	2008-08-22 06:47:40 +0000
+++ b/storage/falcon/StorageTable.h	2008-10-22 20:44:09 +0000
@@ -95,7 +95,7 @@ public:
 	
 	virtual int		updateRow(int recordNumber);
 	virtual int		createIndex(StorageIndexDesc *indexDesc, const char *sql);
-	virtual int		dropIndex(StorageIndexDesc *indexDesc, const char *sql);
+	virtual int		dropIndex(StorageIndexDesc *indexDesc, const char *sql, bool online);
 	virtual const unsigned char* getEncoding(int fieldIndex);
 	virtual const char*			 getName(void);
 	virtual const char*			 getSchemaName(void);

=== modified file 'storage/falcon/StorageTableShare.cpp'
--- a/storage/falcon/StorageTableShare.cpp	2008-09-10 04:02:07 +0000
+++ b/storage/falcon/StorageTableShare.cpp	2008-10-22 20:44:09 +0000
@@ -382,7 +382,7 @@ void StorageTableShare::deleteIndex(int 
 			}
 }
 
-int StorageTableShare::dropIndex(StorageConnection *storageConnection, StorageIndexDesc *indexDesc, const char *sql)
+int StorageTableShare::dropIndex(StorageConnection *storageConnection, StorageIndexDesc *indexDesc, const char *sql, bool online)
 {
 	if (!table)
 		open();
@@ -397,7 +397,15 @@ int StorageTableShare::dropIndex(Storage
 	
 	int ret = storageDatabase->dropIndex(storageConnection, table, sql);
 	
-	deleteIndex(indexDesc->id);
+	// If index not found during online drop index, do not return an error
+	
+	if (ret == StorageErrorNoIndex && online)
+		ret = 0;
+		
+	// Remove index description from index mapping
+	
+	if (!ret)
+		deleteIndex(indexDesc->id);
 				
 	return ret;
 }

=== modified file 'storage/falcon/StorageTableShare.h'
--- a/storage/falcon/StorageTableShare.h	2008-10-14 13:00:31 +0000
+++ b/storage/falcon/StorageTableShare.h	2008-10-22 20:44:09 +0000
@@ -115,7 +115,7 @@ public:
 	virtual void		lockIndexes(bool exclusiveLock=false);
 	virtual void		unlockIndexes(void);
 	virtual int			createIndex(StorageConnection *storageConnection, StorageIndexDesc *indexDesc, const char *sql);
-	virtual int			dropIndex(StorageConnection *storageConnection, StorageIndexDesc *indexDesc, const char *sql);
+	virtual int			dropIndex(StorageConnection *storageConnection, StorageIndexDesc *indexDesc, const char *sql, bool online);
 	virtual bool		validateIndex(int indexId, StorageIndexDesc *indexTarget);
 	virtual void		deleteIndexes();
 	virtual int			numberIndexes();

=== modified file 'storage/falcon/StorageVersion.h'
--- a/storage/falcon/StorageVersion.h	2008-10-16 11:24:33 +0000
+++ b/storage/falcon/StorageVersion.h	2008-10-24 15:22:59 +0000
@@ -14,5 +14,5 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 
-#define FALCON_VERSION	"T1.2-7"
-#define FALCON_DATE		"16 October, 2008"
+#define FALCON_VERSION	"T1.3-0"
+#define FALCON_DATE		"24 October, 2008"

=== modified file 'storage/falcon/SyncHandler.cpp'
--- a/storage/falcon/SyncHandler.cpp	2008-10-16 02:59:09 +0000
+++ b/storage/falcon/SyncHandler.cpp	2008-10-21 20:51:43 +0000
@@ -292,9 +292,8 @@ void SyncHandler::showSyncObjects(void)
 	Log::debug("\n\n== SyncHandler has found %d unique sync objects ==\n", syncObjCount);
 	Log::debug("  _____SyncObjectName_____\n", syncObjCount);
 
-	for (int slot = 0; slot < syncObjHashSize; slot++)
-		for (SyncObjectInfo *soi = syncObjects[slot]; soi; soi = soi->collision)
-			Log::debug("  %s\n", soi->name);
+	FOR_HASH_ITEMS(SyncObjectInfo *, soi, syncObjects, syncObjHashSize)
+		Log::debug("  %s\n", soi->name);
 }
 
 SyncLocationInfo *SyncHandler::findLocation(const char* locationName, LockType type, int slot)
@@ -339,9 +338,8 @@ void SyncHandler::showLocations(void)
 	Log::debug("\n\n== SyncHandler has found %d unique locations ==\n",locationCount);
 	Log::debug("  _____LocationName_____\t_____SyncObjectName_____\n");
 
-	for (int slot = 0; slot < locationHashSize; slot++)
-		for (SyncLocationInfo *loc = locations[slot]; loc; loc = loc->collision)
-			Log::debug("  %s\t%s\t%s\n", loc->name, loc->soi->name, (loc->type == Exclusive ? "Exclusive" : "Shared"));
+	FOR_HASH_ITEMS(SyncLocationInfo *, loc, locations, locationHashSize)
+		Log::debug("  %s\t%s\t%s\n", loc->name, loc->soi->name, (loc->type == Exclusive ? "Exclusive" : "Shared"));
 }
 
 void SyncHandler::addToThread(SyncThreadInfo* thd, SyncLocationInfo *loc)
@@ -464,9 +462,8 @@ void SyncHandler::countLocationStacks(vo
 {
 	int stackCount = 0;
 
-	for (int slot = 0; slot < stackHashSize; slot++)
-		for (LocationStackInfo *lsi = locationStacks[slot]; lsi; lsi = lsi->collision)
-			lsi->count = ++stackCount;
+	FOR_HASH_ITEMS(LocationStackInfo *, lsi, locationStacks, stackHashSize)
+		lsi->count = ++stackCount;
 }
 
 void SyncHandler::showLocationStacks(void)
@@ -475,20 +472,18 @@ void SyncHandler::showLocationStacks(voi
 	Log::debug("     Count; LocationStack\n");
 	int stackCount = 0;
 
-	for (int slot = 0; slot < stackHashSize; slot++)
-		for (LocationStackInfo *lsi = locationStacks[slot]; lsi; lsi = lsi->collision)
-			showLocationStack(lsi);
+	FOR_HASH_ITEMS(LocationStackInfo *, lsi, locationStacks, stackHashSize)
+		showLocationStack(lsi);
 }
 
 void SyncHandler::showLocationStack(int stackNum)
 {
-	for (int slot = 0; slot < stackHashSize; slot++)
-		for (LocationStackInfo *lsi = locationStacks[slot]; lsi; lsi = lsi->collision)
-			if (lsi->count == stackNum)
-				{
-				showLocationStack(lsi);
-				return;
-				}
+	FOR_HASH_ITEMS(LocationStackInfo *, lsi, locationStacks, stackHashSize)
+		if (lsi->count == stackNum)
+			{
+			showLocationStack(lsi);
+			return;
+			}
 }
 
 void SyncHandler::showLocationStack(LocationStackInfo *lsi)
@@ -530,150 +525,144 @@ DeadlockInfo* SyncHandler::findDeadlock(
 void SyncHandler::validate(void)
 {
 	possibleDeadlockCount = 0;
-	for (int n = 0; n < deadlockHashSize; ++n)
-		for (DeadlockInfo *dli; (dli = possibleDeadlocks[n]);)
-			{
-			possibleDeadlocks[n] = dli->collision;
-			delete dli;
-			}
+	FOR_HASH_ITEMS_TO_DELETE(DeadlockInfo *, dli, possibleDeadlocks, deadlockHashSize)
+		{
+		possibleDeadlocks[_slot] = dli->collision;
+		delete dli;
+		}
 
 	int a,b,c,d,e;
-	for (a = 0; a < syncObjHashSize; a++)
-		for (SyncObjectInfo *soi = syncObjects[a]; soi; soi = soi->collision)
-			{
-			// Make a list of all SyncObjects that must occur before and after and this.
+	FOR_HASH_ITEMS(SyncObjectInfo *, soi, syncObjects, syncObjHashSize)
+		{
+		// Make a list of all SyncObjects that must occur before and after and this.
 
-			memset(soi->beforeList, 0, sizeof(soi->beforeList));
-			int beforeCount = 0;
+		memset(soi->beforeList, 0, sizeof(soi->beforeList));
+		int beforeCount = 0;
 
-			memset(soi->afterList, 0, sizeof(soi->afterList));
-			int afterCount = 0;
+		memset(soi->afterList, 0, sizeof(soi->afterList));
+		int afterCount = 0;
 
-			// search each location stack for this soi, make a list of
-			// SyncObjects that occur before and after
+		// search each location stack for this soi, make a list of
+		// SyncObjects that occur before and after
 
-			for (b = 0; b < stackHashSize; b++)
-				for (LocationStackInfo *lsi = locationStacks[b]; lsi; lsi = lsi->collision)
+		FOR_HASH_ITEMS_2(LocationStackInfo *, lsi, locationStacks, stackHashSize)
+			{
+			for (c = 0; c < lsi->height; c++)
+				if (soi == lsi->loc[c]->soi)
 					{
-					for (c = 0; c < lsi->height; c++)
-						if (soi == lsi->loc[c]->soi)
-							{
 
-							// Record the SyncObjects that occur before this
+					// Record the SyncObjects that occur before this
 
-							for (d = 0; d < c; d++) 
-								{
-								for (e = 0; e < beforeCount; e++)
-									if (soi->beforeList[e] == lsi->loc[d]->soi)
-										break;
-
-								if (e == beforeCount)
-									soi->beforeList[beforeCount++] = lsi->loc[d]->soi;
-
-								ASSERT(lsi->loc[d]->soi);
-								ASSERT(beforeCount < beforeAfterSize);
-								}
-
-							// Record the SyncObjects that occur after this
-
-							for (d = c + 1; d < lsi->height; d++)
-								{
-								for (e = 0; e < afterCount; e++)
-									if (soi->afterList[e] == lsi->loc[d]->soi)
-										break;
-
-								if (e == afterCount)
-									soi->afterList[afterCount++] = lsi->loc[d]->soi;
-
-								ASSERT(lsi->loc[d]->soi);
-								ASSERT(afterCount < beforeAfterSize);
-								}
-							}
-					}
+					for (d = 0; d < c; d++) 
+						{
+						for (e = 0; e < beforeCount; e++)
+							if (soi->beforeList[e] == lsi->loc[d]->soi)
+								break;
+
+						if (e == beforeCount)
+							soi->beforeList[beforeCount++] = lsi->loc[d]->soi;
+
+						ASSERT(lsi->loc[d]->soi);
+						ASSERT(beforeCount < beforeAfterSize);
+						}
+
+					// Record the SyncObjects that occur after this
+
+					for (d = c + 1; d < lsi->height; d++)
+						{
+						for (e = 0; e < afterCount; e++)
+							if (soi->afterList[e] == lsi->loc[d]->soi)
+								break;
 
-			// Make sure none of the SyncObjects in before are also in after.
+						if (e == afterCount)
+							soi->afterList[afterCount++] = lsi->loc[d]->soi;
 
-			for (b = 0; b < beforeCount; b++)
-				if (soi != soi->beforeList[b])
-					for (c = 0; c < afterCount; c++)
-						if (soi->beforeList[b] == soi->afterList[c])
-							addPossibleDeadlock(soi, soi->afterList[c]);
+						ASSERT(lsi->loc[d]->soi);
+						ASSERT(afterCount < beforeAfterSize);
+						}
+					}
 			}
 
+		// Make sure none of the SyncObjects in before are also in after.
+
+		for (a = 0; a < beforeCount; a++)
+			if (soi != soi->beforeList[a])
+				for (b = 0; b < afterCount; b++)
+					if (soi->beforeList[a] == soi->afterList[b])
+						addPossibleDeadlock(soi, soi->afterList[b]);
+		}
+
 	// Refine the list of possible deadlocks
 	// The second SOI  was found before and after the first.
 	// But if that happened on the same stack,  it is OK as long as
 	// the two calls do not go from shared up to exclusive.
-	for (a = 0; a < deadlockHashSize; a++)
-		for (DeadlockInfo *dli = possibleDeadlocks[a]; dli; dli = dli->collision)
-			{
-			bool foundBothInOneStack = false;
-			bool foundOneBeforeTwo = false;
-			bool foundTwoBeforeOne = false;
-			bool foundRisingLock = false;
+	FOR_HASH_ITEMS(DeadlockInfo *, dli, possibleDeadlocks, deadlockHashSize)
+		{
+		bool foundBothInOneStack = false;
+		bool foundOneBeforeTwo = false;
+		bool foundTwoBeforeOne = false;
+		bool foundRisingLock = false;
 
-			for (b = 0; b < stackHashSize; b++)
-				for (LocationStackInfo *lsi = locationStacks[b]; lsi; lsi = lsi->collision)
-					{
-					int firstOneNum = 0;
-					int lastOneNum = 0;
-					int firstTwoNum = 0;
-					int lastTwoNum = 0;
-					
-					for (c = 0; c < lsi->height; c++)
+		FOR_HASH_ITEMS_2(LocationStackInfo *, lsi, locationStacks, stackHashSize)
+			{
+			int firstOneNum = 0;
+			int lastOneNum = 0;
+			int firstTwoNum = 0;
+			int lastTwoNum = 0;
+			
+			for (c = 0; c < lsi->height; c++)
+				{
+				if (dli->soi[0] == lsi->loc[c]->soi)
+					if (firstOneNum)
 						{
-						if (dli->soi[0] == lsi->loc[c]->soi)
-							if (firstOneNum)
-								{
-								lastOneNum = c + 1;
-								if (   (lsi->loc[firstOneNum - 1]->type == Shared) 
-									&& (lsi->loc[c]->type == Exclusive))
-									{
-									foundRisingLock = true;
-									lsi->hasRisingLockTypes = true;
-									}
-								}
-							else
-								firstOneNum = c + 1;
-
-						else if (dli->soi[1] == lsi->loc[c]->soi)
-							if (firstTwoNum)
-								{
-								lastTwoNum = c + 1;
-								if (   (lsi->loc[firstTwoNum - 1]->type == Shared) 
-									&& (lsi->loc[c]->type == Exclusive))
-									{
-									foundRisingLock = true;
-									lsi->hasRisingLockTypes = true;
-									}
-								}
-							else
-								firstTwoNum = c + 1;
+						lastOneNum = c + 1;
+						if (   (lsi->loc[firstOneNum - 1]->type == Shared) 
+							&& (lsi->loc[c]->type == Exclusive))
+							{
+							foundRisingLock = true;
+							lsi->hasRisingLockTypes = true;
+							}
 						}
+					else
+						firstOneNum = c + 1;
 
-					if (firstOneNum && firstTwoNum)
+				else if (dli->soi[1] == lsi->loc[c]->soi)
+					if (firstTwoNum)
 						{
-						if (firstOneNum < lastTwoNum && lastTwoNum < lastOneNum)
-							foundBothInOneStack = true;
-						else if (firstTwoNum < lastOneNum && lastOneNum < lastTwoNum)
-							foundBothInOneStack = true;
-						else if (firstOneNum < firstTwoNum)
-							foundOneBeforeTwo = true;
-						else if (firstTwoNum < firstOneNum)
-							foundTwoBeforeOne = true;
-
+						lastTwoNum = c + 1;
+						if (   (lsi->loc[firstTwoNum - 1]->type == Shared) 
+							&& (lsi->loc[c]->type == Exclusive))
+							{
+							foundRisingLock = true;
+							lsi->hasRisingLockTypes = true;
+							}
 						}
-					}
+					else
+						firstTwoNum = c + 1;
+				}
 
-			// Is this still a possible deadlock?
-			if (   foundBothInOneStack 
-				&& !(foundOneBeforeTwo && foundTwoBeforeOne) 
-				&& !foundRisingLock)
+			if (firstOneNum && firstTwoNum)
 				{
-				// Take this possible deadlock out of the list.
-				removePossibleDeadlock(dli);
+				if (firstOneNum < lastTwoNum && lastTwoNum < lastOneNum)
+					foundBothInOneStack = true;
+				else if (firstTwoNum < lastOneNum && lastOneNum < lastTwoNum)
+					foundBothInOneStack = true;
+				else if (firstOneNum < firstTwoNum)
+					foundOneBeforeTwo = true;
+				else if (firstTwoNum < firstOneNum)
+					foundTwoBeforeOne = true;
 				}
 			}
+
+		// Is this still a possible deadlock?
+		if (   foundBothInOneStack 
+			&& !(foundOneBeforeTwo && foundTwoBeforeOne) 
+			&& !foundRisingLock)
+			{
+			// Take this possible deadlock out of the list.
+			removePossibleDeadlock(dli);
+			}
+		}
 }
 
 void SyncHandler::addPossibleDeadlock(SyncObjectInfo *soi1, SyncObjectInfo *soi2)
@@ -728,23 +717,20 @@ void SyncHandler::removePossibleDeadlock
 #define TWO_ONE 2
 void SyncHandler::showPossibleDeadlockStacks(void)
 {
-	int a;
 	int possibleDeadlockCount = 0;
-	for (a = 0; a < deadlockHashSize; a++)
-		for (DeadlockInfo *dli = possibleDeadlocks[a]; dli; dli = dli->collision)
-			if (dli->isPossible)
-				possibleDeadlockCount++;
+	FOR_HASH_ITEMS(DeadlockInfo *, dli, possibleDeadlocks, deadlockHashSize)
+		if (dli->isPossible)
+			possibleDeadlockCount++;
 
 	Log::debug("\n== SyncHandler has found %d possible deadlocks ==\n", possibleDeadlockCount);
 
-	for (a = 0; a < deadlockHashSize; a++)
-		for (DeadlockInfo *dli = possibleDeadlocks[a]; dli; dli = dli->collision)
-			if (dli->isPossible)
-				{
-				Log::debug("\n=== Possible Deadlock===\n");
-				showPossibleDeadlockStack(dli, ONE_TWO);
-				showPossibleDeadlockStack(dli, TWO_ONE);
-				}
+	FOR_HASH_ITEMS(DeadlockInfo *, dli, possibleDeadlocks, deadlockHashSize)
+		if (dli->isPossible)
+			{
+			Log::debug("\n=== Possible Deadlock===\n");
+			showPossibleDeadlockStack(dli, ONE_TWO);
+			showPossibleDeadlockStack(dli, TWO_ONE);
+			}
 }
 
 void SyncHandler::showPossibleDeadlockStack(DeadlockInfo *dli, int showOrder)
@@ -759,44 +745,43 @@ void SyncHandler::showPossibleDeadlockSt
 
 	// Find call stacks containing these two SyncObjects.
 
-	for (int b = 0; b < stackHashSize; b++)
-		for (LocationStackInfo *lsi = locationStacks[b]; lsi; lsi = lsi->collision)
-			{
-			// Does this location stack have both SyncObjects?
+	FOR_HASH_ITEMS(LocationStackInfo *, lsi, locationStacks, stackHashSize)
+		{
+		// Does this location stack have both SyncObjects?
 
-			int numFound = 0;
-			int order = 0;
-			for (int c = 0; c < lsi->height; c++)
+		int numFound = 0;
+		int order = 0;
+		for (int c = 0; c < lsi->height; c++)
+			{
+			if (lsi->loc[c]->soi == dli->soi[0])
 				{
-				if (lsi->loc[c]->soi == dli->soi[0])
-					{
-					numFound |= FOUND_FIRST;
-					if (!order)
-						order = ONE_TWO;
-					}
-				else if (lsi->loc[c]->soi == dli->soi[1])
-					{
-					numFound |= FOUND_SECOND;
-					if (!order)
-						order = TWO_ONE;
-					}
+				numFound |= FOUND_FIRST;
+				if (!order)
+					order = ONE_TWO;
 				}
-
-			if ( (numFound == FOUND_BOTH) && (order == showOrder) )
+			else if (lsi->loc[c]->soi == dli->soi[1])
 				{
-				if (stackCount == 0)
-					{
-					sampleLsi1 = lsi;
-					Log::debug("  Stacks =", dli->soi[0]->name, dli->soi[1]->name);
-					}
-				else if ((stackCount % 10) == 0)
-					Log::debug("\n   ");
+				numFound |= FOUND_SECOND;
+				if (!order)
+					order = TWO_ONE;
+				}
+			}
 
-				stackCount++;
-				Log::debug(" %d", lsi->count);
-				sampleLsi2 = lsi;
+		if ( (numFound == FOUND_BOTH) && (order == showOrder) )
+			{
+			if (stackCount == 0)
+				{
+				sampleLsi1 = lsi;
+				Log::debug("  Stacks =", dli->soi[0]->name, dli->soi[1]->name);
 				}
+			else if ((stackCount % 10) == 0)
+				Log::debug("\n   ");
+
+			stackCount++;
+			Log::debug(" %d", lsi->count);
+			sampleLsi2 = lsi;
 			}
+		}
 
 	Log::debug("\n");
 	if (sampleLsi1)

=== modified file 'storage/falcon/SyncHandler.h'
--- a/storage/falcon/SyncHandler.h	2008-10-16 02:59:09 +0000
+++ b/storage/falcon/SyncHandler.h	2008-10-21 20:51:43 +0000
@@ -23,6 +23,19 @@
 // Uncomment this to use the SyncHandler
 //#define USE_FALCON_SYNC_HANDLER
 
+#define FOR_HASH_ITEMS(_itemType, _item, _hashBuckets, _hashSize) \
+	for (int _slot1 = 0; _slot1 < _hashSize; _slot1++) \
+		for (_itemType _item = _hashBuckets[_slot1]; _item; _item = _item->collision)
+
+#define FOR_HASH_ITEMS_2(_itemType2, _item2, _hashBuckets2, _hashSize2) \
+	for (int _slot2 = 0; _slot2 < _hashSize2; _slot2++) \
+		for (_itemType2 _item2 = _hashBuckets2[_slot2]; _item2; _item2 = _item2->collision)
+
+#define FOR_HASH_ITEMS_TO_DELETE(_itemType, _item, _hashBuckets, _hashSize) \
+	for (int _slot = 0; _slot < _hashSize; ++_slot) \
+		for (_itemType _item; (_item = _hashBuckets[_slot]);)
+
+
 static const int syncObjHashSize = 101;
 static const int locationHashSize = 503;
 static const int threadHashSize = 100;

=== modified file 'storage/falcon/Table.cpp'
--- a/storage/falcon/Table.cpp	2008-10-16 02:53:35 +0000
+++ b/storage/falcon/Table.cpp	2008-10-21 20:51:43 +0000
@@ -3310,7 +3310,7 @@ void Table::validateAndInsert(Transactio
 	Sync syncTable(&syncObject, "Table::validateAndInsert");
 
 	// Do not need syncPrior here since this is a new record.
-	// No other thread can see this records priorVersion pointer.
+	// No other thread can see this record's priorVersion pointer.
 
 	Record *prior = record->getPriorVersion();
 

=== modified file 'storage/falcon/TransactionManager.cpp'
--- a/storage/falcon/TransactionManager.cpp	2008-10-16 02:53:35 +0000
+++ b/storage/falcon/TransactionManager.cpp	2008-10-24 10:20:10 +0000
@@ -118,9 +118,23 @@ Transaction* TransactionManager::startTr
 		if (transaction->state == Available && transaction->dependencies == 0)
 			if (COMPARE_EXCHANGE(&transaction->state, Available, Initializing))
 				{
-				transaction->initialize(connection, INTERLOCKED_INCREMENT(transactionSequence));
+				// Check again that the dependencies are zero. The transaction
+				// object might have been re-use between the previous if-test
+				// and the actual change of state
+
+				if (transaction->dependencies != 0)
+					{
+					// Return the transaction object back to the list
+
+					transaction->state = Available;
+					}
+				else
+					{
+					ASSERT(transaction->dependencies == 0);
+					transaction->initialize(connection, INTERLOCKED_INCREMENT(transactionSequence));
 
-				return transaction;
+					return transaction;
+					}
 				}
 
 	sync.unlock();

=== modified file 'storage/falcon/Types.h'
--- a/storage/falcon/Types.h	2008-06-19 15:09:45 +0000
+++ b/storage/falcon/Types.h	2008-09-20 23:20:02 +0000
@@ -70,7 +70,7 @@ enum JdbcType {
 	jdbcBLOB	= 2004,
 	jdbcCLOB	= 2005,
 	CLOB		= 2005,
-	NUMERIC		= 2,
+	NUMERIC		= 2
 	};
 #endif
 
@@ -103,7 +103,7 @@ enum TerType {
 	terScaledLong,
 	terScaledQuad,
 	terRepositoryBlob,
-	terRepositoryClob,
+	terRepositoryClob
 	};
 
 

=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp	2008-10-21 08:57:35 +0000
+++ b/storage/falcon/ha_falcon.cpp	2008-10-26 08:45:22 +0000
@@ -902,7 +902,7 @@ int StorageInterface::createIndex(const 
 	return storageTable->createIndex(&indexDesc, sql);
 }
 
-int StorageInterface::dropIndex(const char *schemaName, const char *tableName, TABLE *table, int indexId)
+int StorageInterface::dropIndex(const char *schemaName, const char *tableName, TABLE *table, int indexId, bool online)
 {
 	StorageIndexDesc indexDesc;
 	getKeyDesc(table, indexId, &indexDesc);
@@ -911,7 +911,7 @@ int StorageInterface::dropIndex(const ch
 	gen.gen("drop index %s.\"%s\"", schemaName, indexDesc.name);
 	const char *sql = gen.getString();
 
-	return storageTable->dropIndex(&indexDesc, sql);
+	return storageTable->dropIndex(&indexDesc, sql, online);
 }
 
 #if 0
@@ -1094,14 +1094,19 @@ int StorageInterface::write_row(uchar *b
 
 	if (table->next_number_field && buff == table->record[0])
 		{
-		update_auto_increment();
+		int code = update_auto_increment();
+		/*
+		   May fail, e.g. due to an out of range value in STRICT mode.
+		*/
+		if (code)
+			DBUG_RETURN(code);
 
 		/*
 		   If the new value is less than the current highest value, it will be
 		   ignored by setSequenceValue().
 		*/
 
-		int code = storageShare->setSequenceValue(table->next_number_field->val_int());
+		code = storageShare->setSequenceValue(table->next_number_field->val_int());
 
 		if (code)
 			DBUG_RETURN(error(code));
@@ -1198,20 +1203,26 @@ int StorageInterface::commit(handlerton 
 {
 	DBUG_ENTER("StorageInterface::commit");
 	StorageConnection *storageConnection = getStorageConnection(thd);
+	int ret = 0;
 
 	if (all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
 		{
 		if (storageConnection)
-			storageConnection->commit();
+			ret = storageConnection->commit();
 		else
-			storageHandler->commit(thd);
+			ret = storageHandler->commit(thd);
 		}
 	else
 		{
 		if (storageConnection)
 			storageConnection->releaseVerb();
 		else
-			storageHandler->releaseVerb(thd);
+			ret = storageHandler->releaseVerb(thd);
+		}
+
+	if (ret != 0)
+		{
+		DBUG_RETURN(getMySqlError(ret));
 		}
 
 	DBUG_RETURN(0);
@@ -1240,20 +1251,26 @@ int StorageInterface::rollback(handlerto
 {
 	DBUG_ENTER("StorageInterface::rollback");
 	StorageConnection *storageConnection = getStorageConnection(thd);
+	int ret = 0;
 
 	if (all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
 		{
 		if (storageConnection)
-			storageConnection->rollback();
+			ret = storageConnection->rollback();
 		else
-			storageHandler->rollback(thd);
+			ret = storageHandler->rollback(thd);
 		}
 	else
 		{
 		if (storageConnection)
-			storageConnection->rollbackVerb();
+			ret = storageConnection->rollbackVerb();
 		else
-			storageHandler->rollbackVerb(thd);
+			ret = storageHandler->rollbackVerb(thd);
+		}
+
+	if (ret != 0)
+		{
+		DBUG_RETURN(getMySqlError(ret));
 		}
 
 	DBUG_RETURN(0);
@@ -1543,6 +1560,7 @@ int StorageInterface::rename_table(const
 
 	ret = storageShare->renameTable(storageConnection, to);
 	
+	if (!ret)
 	remapIndexes(table);
 	
 	storageShare->unlock();
@@ -1923,10 +1941,12 @@ int StorageInterface::external_lock(THD 
 
 	if (lock_type == F_UNLCK)
 		{
+		int ret = 0;
+
 		storageConnection->setCurrentStatement(NULL);
 
 		if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
-			storageConnection->endImplicitTransaction();
+			ret = storageConnection->endImplicitTransaction();
 		else
 			storageConnection->releaseVerb();
 
@@ -1935,6 +1955,9 @@ int StorageInterface::external_lock(THD 
 			storageTable->clearStatement();
 			storageTable->clearCurrentIndex();
 			}
+
+		if (ret)
+			DBUG_RETURN(error(ret));
 		}
 	else
 		{
@@ -2147,7 +2170,7 @@ int StorageInterface::check_if_supported
 	HA_ALTER_FLAGS supported;
 	supported = supported | HA_ADD_INDEX | HA_DROP_INDEX | HA_ADD_UNIQUE_INDEX | HA_DROP_UNIQUE_INDEX;
 						/**
-						| HA_ADD_COLUMN | HA_COLUMN_STORAGE | HA_COLUMN_FORMAT;
+						| HA_ADD_COLUMN | HA_COLUMN_STORAGE | HA_COLUMN_FORMAT | HA_ADD_PK_INDEX | HA_DROP_PK_INDEX;
 						**/
 	HA_ALTER_FLAGS notSupported = ~(supported);
 	
@@ -2187,9 +2210,21 @@ int StorageInterface::check_if_supported
 	DBUG_RETURN(HA_ALTER_SUPPORTED_NO_LOCK);
 }
 
+// Prepare for online ALTER
+
 int StorageInterface::alter_table_phase1(THD* thd, TABLE* altered_table, HA_CREATE_INFO* create_info, HA_ALTER_INFO* alter_info, HA_ALTER_FLAGS* alter_flags)
 {
 	DBUG_ENTER("StorageInterface::alter_table_phase1");
+
+	DBUG_RETURN(0);
+}
+
+// Perform the online ALTER
+
+int StorageInterface::alter_table_phase2(THD* thd, TABLE* altered_table, HA_CREATE_INFO* create_info, HA_ALTER_INFO* alter_info, HA_ALTER_FLAGS* alter_flags)
+{
+	DBUG_ENTER("StorageInterface::alter_table_phase2");
+
 	int ret = 0;
 	
 	if (alter_flags->is_set(HA_ADD_COLUMN))
@@ -2200,16 +2235,11 @@ int StorageInterface::alter_table_phase1
 		
 	if ((alter_flags->is_set(HA_DROP_INDEX) || alter_flags->is_set(HA_DROP_UNIQUE_INDEX)) && !ret)
 		ret = dropIndex(thd, altered_table, create_info, alter_info, alter_flags);
-		
+	
 	DBUG_RETURN(ret);
 }
 
-int StorageInterface::alter_table_phase2(THD* thd, TABLE* altered_table, HA_CREATE_INFO* create_info, HA_ALTER_INFO* alter_info, HA_ALTER_FLAGS* alter_flags)
-{
-	DBUG_ENTER("StorageInterface::alter_table_phase2");
-	
-	DBUG_RETURN(0);
-}
+// Notification that changes are written and table re-opened
 
 int StorageInterface::alter_table_phase3(THD* thd, TABLE* altered_table)
 {
@@ -2271,20 +2301,17 @@ int StorageInterface::addIndex(THD* thd,
 
 	for (unsigned int n = 0; n < alteredTable->s->keys; n++)
 		{
-		if (n != alteredTable->s->primary_key)
-			{
-			KEY *key = alteredTable->key_info + n;
-			KEY *tableEnd = table->key_info + table->s->keys;
-			KEY *tableKey;
+		KEY *key = alteredTable->key_info + n;
+		KEY *tableEnd = table->key_info + table->s->keys;
+		KEY *tableKey;
 			
-			for (tableKey = table->key_info; tableKey < tableEnd; tableKey++)
-				if (!strcmp(tableKey->name, key->name))
-					break;
+		for (tableKey = table->key_info; tableKey < tableEnd; tableKey++)
+			if (!strcmp(tableKey->name, key->name))
+				break;
 					
-			if (tableKey >= tableEnd)
-				if ((ret = createIndex(schemaName, tableName, alteredTable, n)))
-					break;
-			}
+		if (tableKey >= tableEnd)
+			if ((ret = createIndex(schemaName, tableName, alteredTable, n)))
+				break;
 		}
 		
 	// The server indexes may have been reordered, so remap to the Falcon indexes
@@ -2313,20 +2340,17 @@ int StorageInterface::dropIndex(THD* thd
 	
 	for (unsigned int n = 0; n < table->s->keys; n++)
 		{
-		if (n != table->s->primary_key)
-				{
-			KEY *key = table->key_info + n;
-			KEY *alterEnd = alteredTable->key_info + alteredTable->s->keys;
-			KEY *alterKey;
-			
-			for (alterKey = alteredTable->key_info; alterKey < alterEnd; alterKey++)
-				if (!strcmp(alterKey->name, key->name))
-					break;
+		KEY *key = table->key_info + n;
+		KEY *alterEnd = alteredTable->key_info + alteredTable->s->keys;
+		KEY *alterKey;
+		
+		for (alterKey = alteredTable->key_info; alterKey < alterEnd; alterKey++)
+			if (!strcmp(alterKey->name, key->name))
+				break;
 
-			if (alterKey >= alterEnd)
-				if ((ret = dropIndex(schemaName, tableName, table, n)))
-					break;
-				}
+		if (alterKey >= alterEnd)
+			if ((ret = dropIndex(schemaName, tableName, table, n, true)))
+				break;
 		}
 	
 	// The server indexes have been reordered, so remap to the Falcon indexes

=== modified file 'storage/falcon/ha_falcon.h'
--- a/storage/falcon/ha_falcon.h	2008-10-16 02:53:35 +0000
+++ b/storage/falcon/ha_falcon.h	2008-10-22 20:44:09 +0000
@@ -114,7 +114,7 @@ public:
 
 	void			getDemographics(void);
 	int				createIndex(const char *schemaName, const char *tableName, TABLE *table, int indexId);
-	int				dropIndex(const char *schemaName, const char *tableName, TABLE *table, int indexId);
+	int				dropIndex(const char *schemaName, const char *tableName, TABLE *table, int indexId, bool online);
 	void			getKeyDesc(TABLE *table, int indexId, StorageIndexDesc *indexInfo);
 	void			startTransaction(void);
 	bool			threadSwitch(THD *newThread);

=== modified file 'storage/falcon/plug.in'
--- a/storage/falcon/plug.in	2008-08-20 13:27:29 +0000
+++ b/storage/falcon/plug.in	2008-09-23 09:08:59 +0000
@@ -66,33 +66,40 @@ MYSQL_PLUGIN_ACTIONS(falcon,[
   AC_CACHE_CHECK([compiler flag to enable implicit templates],
                  falcon_cxx_enable_implicit_templates,[
     CXXFLAGS="$ac_save_CXXFLAGS -fimplicit-templates"
-    AC_TRY_LINK([],
-      [int i = 0;
-       i++;],
-      falcon_cxx_enable_implicit_templates="-fimplicit-templates",
-      falcon_cxx_enable_implicit_templates=""
+    AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+      falcon_cxx_enable_implicit_templates="-fimplicit-templates"
     )
   ])
 
+  # -lstdc++ really shouldn't be here, and is only required while we continue
+  # to use gcc to link C++ code for the static linking hack.  Once we stop
+  # doing that it should be removed from here, and the CXXLDFLAG setting below
+  # will do the right thing for g++.
   AC_CACHE_CHECK([compiler flag to enable exceptions],
                  falcon_cxx_enable_exceptions,[
-    CXXFLAGS="$ac_save_CXXFLAGS -fexceptions -lstdc++"
-    AC_TRY_LINK([],
-      [int i = 0;
-       i++;],
-      falcon_cxx_enable_exceptions="-fexceptions -lstdc++",
-      falcon_cxx_enable_exceptions=""
-    )
+    m4_foreach([cxxflag], [[-fexceptions -lstdc++], [-features=except]],[
+      CXXFLAGS="$ac_save_CXXFLAGS cxxflag"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+        falcon_cxx_enable_exceptions="cxxflag"
+      )
+    ])
+  ])
+
+  AC_CACHE_CHECK([linker flag to enable STL],
+                 falcon_cxx_enable_stl,[
+    m4_foreach([cxxflag], [-lstdc++],[
+      CXXFLAGS="$ac_save_CXXFLAGS cxxflag"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+        falcon_cxx_enable_stl="cxxflag"
+      )
+    ])
   ])
 
   AC_CACHE_CHECK([compiler flag to silence offsetof warnings],
                  falcon_cxx_no_invalid_offsetof,[
     CXXFLAGS="$ac_save_CXXFLAGS -Wno-invalid-offsetof"
-    AC_TRY_LINK([],
-      [int i = 0;
-       i++;],
-      falcon_cxx_no_invalid_offsetof="-Wno-invalid-offsetof",
-      falcon_cxx_no_invalid_offsetof=""
+    AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+      falcon_cxx_no_invalid_offsetof="-Wno-invalid-offsetof"
     )
   ])
 
@@ -100,7 +107,7 @@ MYSQL_PLUGIN_ACTIONS(falcon,[
   AC_LANG_POP([C++])
 
   # Falcon uses exceptions and STL.
-  CXXLDFLAGS="$CXXLDFLAGS $falcon_cxx_enable_exceptions"
+  CXXLDFLAGS="$CXXL