List:Commits« Previous MessageNext Message »
From:Kevin Lewis Date:November 20 2008 3:55pm
Subject:bzr commit into mysql-6.0-falcon-team branch (klewis:2913)
View as plain text  
#At file:///C:/Work/bzr/Merge/mysql-6.0-falcon-team/

 2913 Kevin Lewis	2008-11-20 [merge]
      merge
removed:
  mysql-test/suite/backup/r/backup_view_on_view.result
  mysql-test/suite/backup/t/backup_view_on_view.test
added:
  mysql-test/suite/backup/r/backup_logs_purge.result
  mysql-test/suite/backup/t/backup_logs_output-master.opt
  mysql-test/suite/backup/t/backup_logs_purge.test
  mysql-test/suite/backup_engines/r/backup_tmp_tables.result
  mysql-test/suite/backup_engines/t/backup_tmp_tables.test
  mysql-test/suite/rpl/r/rpl_backup.result
  mysql-test/suite/rpl/r/rpl_extraCol_falcon.result
  mysql-test/suite/rpl/r/rpl_extraColmaster_falcon.result
  mysql-test/suite/rpl/r/rpl_locktrans_falcon.result
  mysql-test/suite/rpl/r/rpl_relay_space_falcon.result
  mysql-test/suite/rpl/r/rpl_row_blob_falcon.result
  mysql-test/suite/rpl/r/rpl_truncate_falcon.result
  mysql-test/suite/rpl/t/rpl_backup.test
  mysql-test/suite/rpl/t/rpl_extraCol_falcon.test
  mysql-test/suite/rpl/t/rpl_extraColmaster_falcon.test
  mysql-test/suite/rpl/t/rpl_locktrans_falcon.test
  mysql-test/suite/rpl/t/rpl_relay_space_falcon.test
  mysql-test/suite/rpl/t/rpl_row_blob_falcon.test
  mysql-test/suite/rpl/t/rpl_truncate_falcon.test
modified:
  include/my_base.h
  mysql-test/mysql-test-run.pl
  mysql-test/suite/backup/r/backup_errors.result
  mysql-test/suite/backup/r/backup_logs.result
  mysql-test/suite/backup/r/backup_logs_output.result
  mysql-test/suite/backup/r/backup_no_be.result
  mysql-test/suite/backup/t/backup_errors.test
  mysql-test/suite/backup/t/backup_logs.test
  mysql-test/suite/backup/t/backup_logs_output.test
  mysql-test/suite/backup/t/backup_no_be.test
  mysql-test/suite/backup/t/disabled.def
  mysql-test/suite/backup_engines/include/backup_ptr_objects.inc
  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
  sql/backup/backup_info.cc
  sql/backup/backup_kernel.h
  sql/backup/be_snapshot.cc
  sql/backup/be_thread.cc
  sql/backup/data_backup.cc
  sql/backup/image_info.cc
  sql/backup/image_info.h
  sql/backup/kernel.cc
  sql/backup/logger.h
  sql/log.cc
  sql/log.h
  sql/log_event.cc
  sql/mysqld.cc
  sql/rpl_constants.h
  sql/set_var.cc
  sql/share/errmsg.txt
  sql/si_logs.cc
  sql/si_logs.h
  sql/si_objects.cc
  sql/si_objects.h
  sql/sql_lex.cc
  sql/sql_lex.h
  sql/sql_parse.cc
  sql/sql_repl.cc
  sql/sql_yacc.yy
  storage/csv/ha_tina.cc
  storage/csv/ha_tina.h
  storage/falcon/DeferredIndex.cpp
  storage/falcon/Log.h
  storage/falcon/PageInventoryPage.cpp
  storage/falcon/SRLBlobDelete.h
  storage/falcon/SRLBlobUpdate.h
  storage/falcon/SRLCreateIndex.h
  storage/falcon/SRLCreateSection.h
  storage/falcon/SRLCreateTableSpace.cpp
  storage/falcon/SRLCreateTableSpace.h
  storage/falcon/SRLData.h
  storage/falcon/SRLDelete.h
  storage/falcon/SRLDeleteIndex.cpp
  storage/falcon/SRLDeleteIndex.h
  storage/falcon/SRLDropTableSpace.cpp
  storage/falcon/SRLDropTableSpace.h
  storage/falcon/SRLFreePage.h
  storage/falcon/SRLIndexAdd.h
  storage/falcon/SRLIndexDelete.h
  storage/falcon/SRLIndexPage.h
  storage/falcon/SRLInversionPage.h
  storage/falcon/SRLOverflowPages.h
  storage/falcon/SRLRecordLocator.h
  storage/falcon/SRLRecordStub.h
  storage/falcon/SRLSectionLine.h
  storage/falcon/SRLSectionPage.h
  storage/falcon/SRLSectionPromotion.h
  storage/falcon/SRLSequencePage.h
  storage/falcon/SRLUpdateBlob.h
  storage/falcon/SRLUpdateIndex.cpp
  storage/falcon/SRLUpdateIndex.h
  storage/falcon/SRLUpdateRecords.cpp
  storage/falcon/SRLUpdateRecords.h
  storage/falcon/SerialLog.cpp
  storage/falcon/SerialLog.h
  storage/falcon/SerialLogRecord.cpp
  storage/falcon/SerialLogRecord.h
  storage/falcon/StorageHandler.cpp
  storage/falcon/StorageVersion.h
  storage/falcon/ha_falcon.cpp
  storage/falcon/ha_falcon.h

=== modified file 'include/my_base.h'
--- a/include/my_base.h	2008-10-20 09:16:47 +0000
+++ b/include/my_base.h	2008-10-28 14:17:05 +0000
@@ -208,7 +208,8 @@ enum ha_extra_function {
   HA_EXTRA_ORDERBY_LIMIT,
   HA_EXTRA_NO_ORDERBY_LIMIT,
   /* Inform handler we will force a close as part of flush */
-  HA_EXTRA_PREPARE_FOR_FORCED_CLOSE
+  HA_EXTRA_PREPARE_FOR_FORCED_CLOSE,
+  HA_EXTRA_ALLOW_LOG_DELETE
 };
 
 /* Compatible option, to be deleted in 6.0 */

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2008-10-23 16:29:52 +0000
+++ b/mysql-test/mysql-test-run.pl	2008-11-12 17:42:23 +0000
@@ -133,7 +133,7 @@ our $default_vardir;
 
 our $opt_usage;
 our $opt_suites;
-our $opt_suites_default= "main,backup,binlog,rpl,rpl_ndb,ndb"; # Default suites to run
+our $opt_suites_default= "main,backup,backup_engines,binlog,rpl,rpl_ndb,ndb"; # Default suites to run
 our $opt_script_debug= 0;  # Script debugging, enable with --script-debug
 our $opt_verbose= 0;  # Verbose output, enable with --verbose
 

=== modified file 'mysql-test/suite/backup/r/backup_errors.result'
--- a/mysql-test/suite/backup/r/backup_errors.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_errors.result	2008-11-05 09:41:15 +0000
@@ -20,6 +20,8 @@ BACKUP DATABASE foo TO 'test.bak';
 ERROR 42000: Unknown database 'foo'
 BACKUP DATABASE test,foo,bdb,bar TO 'test.bak';
 ERROR 42000: Unknown database 'foo,bar'
+BACKUP DATABASE foo,test,bar,foo TO 'test.bak';
+ERROR 42000: Not unique database: 'foo'
 use adb;
 create table t1 (a int);
 create procedure p1() backup database test to 'test.bak';

=== modified file 'mysql-test/suite/backup/r/backup_logs.result'
--- a/mysql-test/suite/backup/r/backup_logs.result	2008-10-15 20:00:48 +0000
+++ b/mysql-test/suite/backup/r/backup_logs.result	2008-11-07 10:40:48 +0000
@@ -31,12 +31,12 @@ object	utf8
 Now starting real tests
 
 DROP DATABASE IF EXISTS backup_logs;
+PURGE BACKUP LOGS;
 CREATE DATABASE backup_logs;
 con1: Create table and new users.
 CREATE TABLE backup_logs.t1 (a char(30)) ENGINE=MYISAM;
 CREATE TABLE backup_logs.t2 (a char(30)) ENGINE=INNODB;
 CREATE TABLE backup_logs.t3 (a char(30)) ENGINE=MEMORY;
-CREATE TABLE backup_logs.t1_res (id BIGINT UNSIGNED NOT NULL) ENGINE=MEMORY;
 INSERT INTO backup_logs.t1 VALUES ("01 Test #1 - progress");
 INSERT INTO backup_logs.t1 VALUES ("02 Test #1 - progress");
 INSERT INTO backup_logs.t1 VALUES ("03 Test #1 - progress");
@@ -60,27 +60,28 @@ SET DEBUG_SYNC= 'after_backup_log_init  
 SET DEBUG_SYNC= 'after_backup_start_backup SIGNAL phase1    WAIT_FOR backup';
 SET DEBUG_SYNC= 'after_backup_validated    SIGNAL validated WAIT_FOR do_phase2';
 SET DEBUG_SYNC= 'after_backup_binlog       SIGNAL phase2    WAIT_FOR finish';
-con2: Send backup command.
+Start using a known backup id for a more definitive test.
+SET SESSION debug="+d,set_backup_id";
+con2: Send backup command. 
+con2: Backup id = 500.
 BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
 con1: Wait for the backup to be started.
 SET DEBUG_SYNC= 'now WAIT_FOR started';
 con1: Display progress
-SELECT MAX(backup_id) INTO @bup_id FROM mysql.backup_progress;
-INSERT INTO backup_logs.t1_res (id) VALUES (@bup_id);
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 500;
 notes
 starting
 con1: Let backup step to running state.
 SET DEBUG_SYNC= 'now SIGNAL do_run WAIT_FOR phase1';
 con1: Display progress
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 500;
 notes
 starting
 running
 con1: Let backup do the backup phase1.
 SET DEBUG_SYNC= 'now SIGNAL backup WAIT_FOR validated';
 con1: Display progress
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 500;
 notes
 starting
 running
@@ -88,7 +89,7 @@ validity point
 con1: Let backup do the backup phase2.
 SET DEBUG_SYNC= 'now SIGNAL do_phase2 WAIT_FOR phase2';
 con1: Display progress
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 500;
 notes
 starting
 running
@@ -99,8 +100,11 @@ con1: Let backup finish.
 SET DEBUG_SYNC= 'now SIGNAL finish';
 con2: Finish backup command
 backup_id
-#
-SELECT ob.* FROM mysql.backup_history AS ob JOIN backup_logs.t1_res AS t1 ON ob.backup_id = t1.id;;
+500
+FLUSH BACKUP LOGS;
+Turn off debugging session.
+SET SESSION debug="-d";
+SELECT * FROM mysql.backup_history WHERE backup_id = 500;;
 backup_id	#
 process_id	#
 binlog_pos	#
@@ -108,8 +112,8 @@ binlog_file	#
 backup_state	complete
 operation	backup
 error_num	0
-num_objects	4
-total_bytes	3981
+num_objects	3
+total_bytes	3971
 validity_point_time	#
 start_time	#
 stop_time	#
@@ -119,8 +123,8 @@ backup_file	#
 backup_file_path	#
 user_comment	
 command	BACKUP DATABASE backup_logs to 'backup_logs_orig.bak'
-drivers	MyISAM, Default, Snapshot
-SELECT obp.* FROM mysql.backup_progress AS obp JOIN backup_logs.t1_res AS t1 ON obp.backup_id = t1.id;
+drivers	MyISAM, Snapshot, Default
+SELECT * FROM mysql.backup_progress WHERE backup_id = 500;
 backup_id	object	start_time	stop_time	total_bytes	progress	error_num	notes
 #	backup kernel	#	#	0	0	0	starting
 #	backup kernel	#	#	0	0	0	running
@@ -128,26 +132,22 @@ backup_id	object	start_time	stop_time	to
 #	backup kernel	#	#	0	0	0	vp time
 #	backup kernel	#	#	0	0	0	running
 #	backup kernel	#	#	0	0	0	complete
-DELETE FROM backup_logs.t1_res;
 con2: Activate sync points for the backup statement.
 SET DEBUG_SYNC= 'after_backup_log_init      SIGNAL started WAIT_FOR do_run';
 SET DEBUG_SYNC= 'after_backup_start_restore SIGNAL running WAIT_FOR finish';
 con2: Send restore command.
+con2: Backup id = 501.
 RESTORE FROM 'backup_logs_orig.bak';
 con1: Wait for the restore to be started.
 SET DEBUG_SYNC= 'now WAIT_FOR started';
 con1: Display progress
-select * from backup_logs.t1_res;
-id
-SELECT MAX(backup_id) INTO @bup_id FROM mysql.backup_progress;
-INSERT INTO backup_logs.t1_res (id) VALUES (@bup_id);
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 501;
 notes
 starting
 con1: Let restore step to running state.
 SET DEBUG_SYNC= 'now SIGNAL do_run WAIT_FOR running';
 con1: Display progress
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 501;
 notes
 starting
 running
@@ -155,13 +155,11 @@ con1: Let restore do its job and finish.
 SET DEBUG_SYNC= 'now SIGNAL finish';
 con2: Finish restore command
 backup_id
-#
+501
+FLUSH BACKUP LOGS;
 SET DEBUG_SYNC= 'now SIGNAL complete';
 SET DEBUG_SYNC= 'now WAIT_FOR complete';
-DELETE FROM backup_logs.t1_res;
-SELECT MAX(backup_id) INTO @bup_id FROM mysql.backup_history WHERE command LIKE "RESTORE FROM%";
-INSERT INTO backup_logs.t1_res (id) VALUES (@bup_id);
-SELECT ob.* FROM mysql.backup_history AS ob JOIN backup_logs.t1_res AS t1 ON ob.backup_id = t1.id;;
+SELECT * FROM mysql.backup_history WHERE backup_id = 501;;
 backup_id	#
 process_id	#
 binlog_pos	#
@@ -169,8 +167,8 @@ binlog_file	#
 backup_state	complete
 operation	restore
 error_num	0
-num_objects	4
-total_bytes	1493
+num_objects	3
+total_bytes	1483
 validity_point_time	#
 start_time	#
 stop_time	#
@@ -180,22 +178,13 @@ backup_file	#
 backup_file_path	#
 user_comment	
 command	RESTORE FROM 'backup_logs_orig.bak'
-drivers	MyISAM, Default, Snapshot
-SELECT obp.* FROM mysql.backup_progress AS obp JOIN backup_logs.t1_res AS t1 ON obp.backup_id = t1.id;
+drivers	MyISAM, Snapshot, Default
+SELECT * FROM mysql.backup_progress WHERE backup_id = 501;
 backup_id	object	start_time	stop_time	total_bytes	progress	error_num	notes
 #	backup kernel	#	#	0	0	0	starting
 #	backup kernel	#	#	0	0	0	running
 #	backup kernel	#	#	0	0	0	complete
 SET DEBUG_SYNC= 'RESET';
-SET SESSION debug="d,set_backup_id";
-BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
-backup_id
-500
-SET SESSION debug="d";
-The backup id for this command should be 501.
-BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
-backup_id
-501
 The backup id for this command should be 502.
 BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
 backup_id
@@ -204,4 +193,12 @@ The backup id for this command should be
 BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
 backup_id
 503
+The backup id for this command should be 504.
+BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
+backup_id
+504
+The backup id for this command should be 505.
+BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
+backup_id
+505
 DROP DATABASE backup_logs;

=== modified file 'mysql-test/suite/backup/r/backup_logs_output.result'
--- a/mysql-test/suite/backup/r/backup_logs_output.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_logs_output.result	2008-11-10 16:49:10 +0000
@@ -1,5 +1,34 @@
 con1
-Display backup variables
+Clear the logs.
+SET @@global.backup_history_log = 'ON';
+SET @@global.backup_progress_log = 'ON';
+Display backup variable values from startup options file.
+SHOW VARIABLES LIKE 'backup_history%';
+Variable_name	Value
+backup_history_log	ON
+backup_history_log_file	MYSQLTEST_VARDIR/master-data/history.txt
+SHOW VARIABLES LIKE 'backup_progress%';
+Variable_name	Value
+backup_progress_log	ON
+backup_progress_log_file	MYSQLTEST_VARDIR/master-data/progress.txt
+SHOW VARIABLES LIKE 'log_backup_output';
+Variable_name	Value
+log_backup_output	FILE
+Set the backup log file names to default values.
+SET @@global.backup_history_log_file = DEFAULT;
+SET @@global.backup_progress_log_file = DEFAULT;
+SET @@global.log_backup_output = 'TABLE';
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+See that the log names have been reset.
+SHOW VARIABLES LIKE 'backup_history%';
+Variable_name	Value
+backup_history_log	ON
+backup_history_log_file	MYSQLTEST_VARDIR/master-data/backup_history.log
+SHOW VARIABLES LIKE 'backup_progress%';
+Variable_name	Value
+backup_progress_log	ON
+backup_progress_log_file	MYSQLTEST_VARDIR/master-data/backup_progress.log
 SHOW VARIABLES LIKE 'backup_history_log';
 Variable_name	Value
 backup_history_log	ON
@@ -24,8 +53,6 @@ backup_progress_log	OFF
 SHOW VARIABLES LIKE 'log_backup_output';
 Variable_name	Value
 log_backup_output	NONE
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
 Show the size of the logs
 SELECT count(*) FROM mysql.backup_history;
 count(*)
@@ -64,8 +91,8 @@ backup_progress_log	ON
 SHOW VARIABLES LIKE 'log_backup_output';
 Variable_name	Value
 log_backup_output	TABLE
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
 BACKUP DATABASE bup_log TO 'bup_log.bak';
 backup_id
 #
@@ -79,6 +106,11 @@ count(*)
 FLUSH BACKUP LOGS;
 '---Checking backup logs when log_backup_output is TABLE---'
 '---and the progress log is turned off                   ---'
+Clear the logs.
+SET @@global.backup_history_log = 'ON';
+SET @@global.backup_progress_log = 'ON';
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
 SET @@global.backup_history_log = 'ON';
 SET @@global.backup_progress_log = 'OFF';
 Display backup variables
@@ -91,8 +123,6 @@ backup_progress_log	OFF
 SHOW VARIABLES LIKE 'log_backup_output';
 Variable_name	Value
 log_backup_output	TABLE
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
 Show the size of the logs
 SELECT count(*) FROM mysql.backup_history;
 count(*)
@@ -113,6 +143,11 @@ count(*)
 FLUSH BACKUP LOGS;
 '---Checking backup logs when log_backup_output is TABLE---'
 '---and the history log is turned off                 ---'
+Clear the logs.
+SET @@global.backup_history_log = 'ON';
+SET @@global.backup_progress_log = 'ON';
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
 SET @@global.backup_history_log = 'OFF';
 SET @@global.backup_progress_log = 'ON';
 Display backup variables
@@ -125,8 +160,6 @@ backup_progress_log	ON
 SHOW VARIABLES LIKE 'log_backup_output';
 Variable_name	Value
 log_backup_output	TABLE
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
 Show the size of the logs
 SELECT count(*) FROM mysql.backup_history;
 count(*)
@@ -145,6 +178,14 @@ SELECT count(*) FROM mysql.backup_progre
 count(*)
 6
 FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+Show the size of the logs
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+0
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+0
 '---Checking backup logs when log_backup_output is FILE---'
 SET @@global.log_backup_output = 'FILE';
 turning backup logs back on
@@ -160,8 +201,6 @@ backup_progress_log	ON
 SHOW VARIABLES LIKE 'log_backup_output';
 Variable_name	Value
 log_backup_output	FILE
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
 BACKUP DATABASE bup_log TO 'bup_log.bak';
 backup_id
 #
@@ -173,6 +212,7 @@ SELECT count(*) FROM mysql.backup_progre
 count(*)
 0
 FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
 '---Checking backup logs when log_backup_output is TABLE, FILE---'
 SET @@global.log_backup_output = 'TABLE,FILE';
 Display backup variables
@@ -185,8 +225,6 @@ backup_progress_log	ON
 SHOW VARIABLES LIKE 'log_backup_output';
 Variable_name	Value
 log_backup_output	FILE,TABLE
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
 BACKUP DATABASE bup_log TO 'bup_log.bak';
 backup_id
 #
@@ -198,6 +236,34 @@ SELECT count(*) FROM mysql.backup_progre
 count(*)
 6
 FLUSH BACKUP LOGS;
+SET GLOBAL backup_history_log=0;
+SET GLOBAL backup_progress_log=0;
+Should show 'OFF'
+SHOW VARIABLES LIKE 'backup%log';
+Variable_name	Value
+backup_history_log	OFF
+backup_progress_log	OFF
+SET GLOBAL backup_history_log=1;
+SET GLOBAL backup_progress_log=1;
+Should show 'ON'
+SHOW VARIABLES LIKE 'backup%log';
+Variable_name	Value
+backup_history_log	ON
+backup_progress_log	ON
+SET GLOBAL backup_history_log=OFF;
+SET GLOBAL backup_progress_log=OFF;
+Should show 'OFF'
+SHOW VARIABLES LIKE 'backup%log';
+Variable_name	Value
+backup_history_log	OFF
+backup_progress_log	OFF
+SET GLOBAL backup_history_log=DEFAULT;
+SET GLOBAL backup_progress_log=DEFAULT;
+After set default still should show 'ON'
+SHOW VARIABLES LIKE 'backup%log';
+Variable_name	Value
+backup_history_log	ON
+backup_progress_log	ON
 Cleanup
 DROP DATABASE bup_log;
 SET @@global.log_backup_output = 'TABLE';

=== added file 'mysql-test/suite/backup/r/backup_logs_purge.result'
--- a/mysql-test/suite/backup/r/backup_logs_purge.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_logs_purge.result	2008-10-28 14:17:05 +0000
@@ -0,0 +1,425 @@
+SET @@global.log_backup_output = 'FILE,TABLE';
+PURGE BACKUP LOGS;
+
+Now starting real tests
+
+DROP DATABASE IF EXISTS backup_logs;
+CREATE DATABASE backup_logs;
+Create table and populate with data.
+CREATE TABLE backup_logs.t1 (a char(30)) ENGINE=MYISAM;
+CREATE TABLE backup_logs.t2 (a char(30)) ENGINE=INNODB;
+CREATE TABLE backup_logs.t3 (a char(30)) ENGINE=MEMORY;
+INSERT INTO backup_logs.t1 VALUES ("01 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("02 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("03 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("04 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("05 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("06 Test #1 - progress");
+INSERT INTO backup_logs.t1 VALUES ("07 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("01 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("02 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("03 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("04 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("05 Test #1 - progress");
+INSERT INTO backup_logs.t2 VALUES ("06 Test #1 - progress");
+INSERT INTO backup_logs.t3 VALUES ("01 Test #1 - progress");
+INSERT INTO backup_logs.t3 VALUES ("02 Test #1 - progress");
+INSERT INTO backup_logs.t3 VALUES ("03 Test #1 - progress");
+INSERT INTO backup_logs.t3 VALUES ("04 Test #1 - progress");
+SET SESSION debug="+d,set_backup_id";
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup1.bak';
+backup_id
+500
+SET SESSION debug="-d";
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup2.bak';
+backup_id
+501
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup3.bak';
+backup_id
+502
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup4.bak';
+backup_id
+503
+Do restore of database
+RESTORE from 'backup1.bak';
+backup_id
+504
+Do restore of database
+RESTORE from 'backup2.bak';
+backup_id
+505
+Do restore of database
+RESTORE from 'backup3.bak';
+backup_id
+506
+Do restore of database
+RESTORE from 'backup4.bak';
+backup_id
+507
+Display results from backup logs
+SELECT backup_id FROM mysql.backup_history;
+backup_id
+500
+501
+502
+503
+504
+505
+506
+507
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+backup_id
+500
+501
+502
+503
+504
+505
+506
+507
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+8
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+36
+Purge all backup log data prior to id = 502.
+PURGE BACKUP LOGS TO 502;
+Display results from backup logs
+SELECT backup_id FROM mysql.backup_history;
+backup_id
+502
+503
+504
+505
+506
+507
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+backup_id
+502
+503
+504
+505
+506
+507
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+6
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+24
+Purge all backup log data.
+PURGE BACKUP LOGS;
+Display results from backup logs
+SELECT backup_id FROM mysql.backup_history;
+backup_id
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+backup_id
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+0
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+0
+Cleanup the logs and images for later testing.
+PURGE BACKUP LOGS;
+SET @@time_zone = '+00:00';
+SET SESSION debug="+d,set_backup_id";
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup1.bak';
+backup_id
+500
+SET SESSION debug="-d";
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup2.bak';
+backup_id
+501
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup3.bak';
+backup_id
+502
+SET SESSION debug="+d,set_log_time";
+Do backup of database
+BACKUP DATABASE backup_logs to 'backup4.bak';
+backup_id
+503
+SET SESSION debug="-d";
+Do restore of database
+RESTORE from 'backup1.bak';
+backup_id
+504
+Do restore of database
+RESTORE from 'backup2.bak';
+backup_id
+505
+Do restore of database
+RESTORE from 'backup3.bak';
+backup_id
+506
+SET SESSION debug="+d,set_log_time";
+Do restore of database
+RESTORE from 'backup4.bak';
+backup_id
+507
+SET SESSION debug="-d";
+Display the results.
+SELECT backup_id FROM mysql.backup_history;
+backup_id
+500
+501
+502
+503
+504
+505
+506
+507
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+backup_id
+500
+501
+502
+503
+504
+505
+506
+507
+SET @now_time= now();
+PURGE BACKUP LOGS BEFORE @now_time;
+SELECT backup_id FROM mysql.backup_history;
+backup_id
+503
+507
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+backup_id
+503
+507
+SET @@time_zone = @@global.time_zone;
+PURGE BACKUP LOGS;
+Perform backup
+SET SESSION debug="+d,set_backup_id";
+BACKUP DATABASE backup_logs TO '../bup_logs_dir.bak';
+backup_id
+500
+SET SESSION debug="-d";
+Ensure backup image file went to the correct location
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+1
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+6
+PURGE BACKUP LOGS TO 501;
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+0
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+0
+PURGE BACKUP LOGS BEFORE 123123;
+ERROR HY000: The datetime specified is invalid for the 'PURGE BACKUP LOGS BEFORE' command.
+SET @@global.log_backup_output = 'FILE';
+PURGE BACKUP LOGS TO 99999999;
+ERROR HY000: Removing backup log entries by date or backup_id requires logging to tables.
+PURGE BACKUP LOGS BEFORE @now_time;
+ERROR HY000: Removing backup log entries by date or backup_id requires logging to tables.
+SET @@global.log_backup_output = 'TABLE';
+Test backup and purge concurrent execution.
+PURGE BACKUP LOGS;
+Get rid of any lingering image files.
+SET DEBUG_SYNC= 'RESET';
+con2: Do some backups to add entries in logs.
+BACKUP DATABASE backup_logs to 'backup1.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs to 'backup2.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs to 'backup3.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs to 'backup4.bak';
+backup_id
+#
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+4
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+24
+SET SESSION debug="+d,set_backup_id";
+con2: Activate sync points for the backup statement.
+SET DEBUG_SYNC= 'before_backup_done SIGNAL ready WAIT_FOR proceed';
+BACKUP DATABASE backup_logs to 'backup5.bak';
+con1: Wait for the backup to be ready.
+SET DEBUG_SYNC= 'now WAIT_FOR ready';
+PURGE BACKUP LOGS;
+SET DEBUG_SYNC= 'now SIGNAL proceed';
+backup_id
+#
+SET SESSION debug="-d";
+There should be one row in this table: the backup id from last
+backup (500).
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+1
+SELECT backup_id, command FROM mysql.backup_history;
+backup_id	command
+500	BACKUP DATABASE backup_logs to 'backup5.bak'
+There should be one row in this table: the backup id from last
+backup (500). We should only see the complete progress 
+statement because all others were deleted while backup was
+in progress.
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+1
+SELECT * FROM mysql.backup_progress;
+backup_id	500
+object	backup kernel
+start_time	#
+stop_time	#
+total_bytes	0
+progress	0
+error_num	0
+notes	complete
+Now do the same test for restore.
+RESTORE FROM 'backup1.bak';
+backup_id
+#
+RESTORE FROM 'backup2.bak';
+backup_id
+#
+RESTORE FROM 'backup3.bak';
+backup_id
+#
+RESTORE FROM 'backup4.bak';
+backup_id
+#
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+5
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+13
+con2: Activate sync points for the backup statement.
+SET DEBUG_SYNC= 'before_restore_done SIGNAL ready WAIT_FOR proceed';
+RESTORE FROM 'backup5.bak';
+con1: Wait for the backup to be ready.
+SET DEBUG_SYNC= 'now WAIT_FOR ready';
+PURGE BACKUP LOGS;
+SET DEBUG_SYNC= 'now SIGNAL proceed';
+backup_id
+#
+There should be one row in this table: the backup id from last
+restore (505).
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+1
+SELECT backup_id, command FROM mysql.backup_history;
+backup_id	command
+505	RESTORE FROM 'backup5.bak'
+There should be one row in this table: the backup id from last
+restore (505). We should only see the complete progress 
+statement because all others were deleted while restore was
+in progress.
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+1
+SELECT * FROM mysql.backup_progress;
+backup_id	505
+object	backup kernel
+start_time	#
+stop_time	#
+total_bytes	0
+progress	0
+error_num	0
+notes	complete
+First, run some backups.
+BACKUP DATABASE backup_logs TO 'backup1.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs TO 'backup2.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs TO 'backup3.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs TO 'backup4.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs TO 'backup5.bak';
+backup_id
+#
+Test purges that do not meet criteria.
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+6
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+31
+PURGE BACKUP LOGS BEFORE '1988-10-12 12:00:00';
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+6
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+31
+PURGE BACKUP LOGS TO 0;
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+6
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+31
+Test empty logs (delete all entries).
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+6
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+31
+PURGE BACKUP LOGS TO 999999999;
+Check to be sure backup logs are empty (count(*) = 0).
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+0
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+0
+Run some more backups to generate more rows.
+BACKUP DATABASE backup_logs TO 'backup1.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs TO 'backup2.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs TO 'backup3.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs TO 'backup4.bak';
+backup_id
+#
+BACKUP DATABASE backup_logs TO 'backup5.bak';
+backup_id
+#
+Test purges that do not meet criteria.
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+5
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+30
+PURGE BACKUP LOGS BEFORE '2024-10-12 12:00:00';
+Test empty logs (delete all entries).
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+0
+SELECT count(*) FROM mysql.backup_progress;
+count(*)
+0
+SET DEBUG_SYNC= 'RESET';
+DROP DATABASE backup_logs;
+PURGE BACKUP LOGS;

=== modified file 'mysql-test/suite/backup/r/backup_no_be.result'
--- a/mysql-test/suite/backup/r/backup_no_be.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_no_be.result	2008-10-30 10:41:48 +0000
@@ -3,10 +3,10 @@ CREATE DATABASE db1;
 USE db1;
 CREATE TABLE t1 (a int) ENGINE=Myisam;
 INSERT INTO t1 VALUES (1),(2),(3);
-SET SESSION debug="d,";
+SET SESSION debug="-d,";
 SELECT @@debug;
 @@debug
-d
+
 BACKUP DATABASE db1 TO 'db1.bak';
 backup_id
 #
@@ -17,7 +17,7 @@ WHERE command LIKE 'BACKUP DATABASE db1 
 SELECT drivers FROM mysql.backup_history WHERE backup_id=@id;
 drivers
 MyISAM
-SET SESSION debug="d,backup_test_dummy_be_factory";
+SET SESSION debug="+d,backup_test_dummy_be_factory";
 SELECT @@debug;
 @@debug
 d,backup_test_dummy_be_factory
@@ -39,4 +39,4 @@ SHOW TABLES IN db1;
 Tables_in_db1
 t1
 DROP DATABASE db1;
-SET GLOBAL debug="d,";
+SET GLOBAL debug="-d,";

=== removed file 'mysql-test/suite/backup/r/backup_view_on_view.result'
--- a/mysql-test/suite/backup/r/backup_view_on_view.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_view_on_view.result	1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
-SET GLOBAL debug="d,backup:d,backup_data";
-DROP DATABASE IF EXISTS db1;
-CREATE DATABASE db1;
-CREATE TABLE db1.t1(a int) ENGINE=INNODB;
-CREATE VIEW db1.v1 AS SELECT * FROM db1.t1;
-CREATE VIEW db1.v2 AS SELECT * FROM db1.v1;
-INSERT INTO db1.t1 VALUES (1),(2),(3),(5),(7),(11);
-BACKUP DATABASE db1 TO 'test.bak';
-backup_id
-#
-RESTORE FROM 'test.bak';
-backup_id
-#
-SELECT * FROM db1.v2;
-a
-1
-2
-3
-5
-7
-11
-SELECT * FROM db1.v1;
-a
-1
-2
-3
-5
-7
-11
-SELECT * FROM db1.t1;
-a
-1
-2
-3
-5
-7
-11
-DROP DATABASE db1;

=== modified file 'mysql-test/suite/backup/t/backup_errors.test'
--- a/mysql-test/suite/backup/t/backup_errors.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_errors.test	2008-11-05 09:41:15 +0000
@@ -50,6 +50,10 @@ BACKUP DATABASE foo TO 'test.bak';
 -- error ER_BAD_DB_ERROR
 BACKUP DATABASE test,foo,bdb,bar TO 'test.bak';
 
+# repeated database
+-- error ER_NONUNIQ_DB
+BACKUP DATABASE foo,test,bar,foo TO 'test.bak';
+
 # Test that BACKUP/RESTORE statements are disable inside stored routines,
 # triggers and events.
 

=== modified file 'mysql-test/suite/backup/t/backup_logs.test'
--- a/mysql-test/suite/backup/t/backup_logs.test	2008-10-15 20:00:48 +0000
+++ b/mysql-test/suite/backup/t/backup_logs.test	2008-11-07 10:40:48 +0000
@@ -44,6 +44,8 @@ DROP DATABASE IF EXISTS backup_logs;
 --remove_file $MYSQLTEST_VARDIR/master-data/backup_logs_orig.bak;
 --enable_warnings
 
+PURGE BACKUP LOGS;
+
 connect (con1,localhost,root,,);
 connect (con2,localhost,root,,);
 
@@ -60,7 +62,6 @@ CREATE DATABASE backup_logs;
 CREATE TABLE backup_logs.t1 (a char(30)) ENGINE=MYISAM;
 CREATE TABLE backup_logs.t2 (a char(30)) ENGINE=INNODB;
 CREATE TABLE backup_logs.t3 (a char(30)) ENGINE=MEMORY;
-CREATE TABLE backup_logs.t1_res (id BIGINT UNSIGNED NOT NULL) ENGINE=MEMORY;
 
 INSERT INTO backup_logs.t1 VALUES ("01 Test #1 - progress"); 
 INSERT INTO backup_logs.t1 VALUES ("02 Test #1 - progress"); 
@@ -92,7 +93,11 @@ SET DEBUG_SYNC= 'after_backup_start_back
 SET DEBUG_SYNC= 'after_backup_validated    SIGNAL validated WAIT_FOR do_phase2';
 SET DEBUG_SYNC= 'after_backup_binlog       SIGNAL phase2    WAIT_FOR finish';
 
---echo con2: Send backup command.
+--echo Start using a known backup id for a more definitive test.
+SET SESSION debug="+d,set_backup_id";
+
+--echo con2: Send backup command. 
+--echo con2: Backup id = 500.
 send BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
 
 connection con1;
@@ -101,46 +106,46 @@ connection con1;
 SET DEBUG_SYNC= 'now WAIT_FOR started';
 
 --echo con1: Display progress
-SELECT MAX(backup_id) INTO @bup_id FROM mysql.backup_progress;
-INSERT INTO backup_logs.t1_res (id) VALUES (@bup_id);
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 500;
 
 --echo con1: Let backup step to running state.
 SET DEBUG_SYNC= 'now SIGNAL do_run WAIT_FOR phase1';
 
 --echo con1: Display progress
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 500;
 
 --echo con1: Let backup do the backup phase1.
 SET DEBUG_SYNC= 'now SIGNAL backup WAIT_FOR validated';
 
 --echo con1: Display progress
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 500;
 
 --echo con1: Let backup do the backup phase2.
 SET DEBUG_SYNC= 'now SIGNAL do_phase2 WAIT_FOR phase2';
 
 --echo con1: Display progress
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 500;
 
 --echo con1: Let backup finish.
 SET DEBUG_SYNC= 'now SIGNAL finish';
 
 connection con2;
 --echo con2: Finish backup command
---replace_column 1 #
 reap;
 
+FLUSH BACKUP LOGS;
+
+--echo Turn off debugging session.
+SET SESSION debug="-d";
+
 connection con1;
 
 #Show results
 --replace_column 1 # 2 # 3 # 4 # 10 # 11 # 12 # 15 # 16 #
---query_vertical SELECT ob.* FROM mysql.backup_history AS ob JOIN backup_logs.t1_res AS t1 ON ob.backup_id = t1.id;
+--query_vertical SELECT * FROM mysql.backup_history WHERE backup_id = 500;
 --replace_column 1 # 3 # 4 #
-SELECT obp.* FROM mysql.backup_progress AS obp JOIN backup_logs.t1_res AS t1 ON obp.backup_id = t1.id;
+SELECT * FROM mysql.backup_progress WHERE backup_id = 500;
 
-DELETE FROM backup_logs.t1_res;
- 
 connection con2;
 
 --echo con2: Activate sync points for the backup statement.
@@ -148,6 +153,7 @@ SET DEBUG_SYNC= 'after_backup_log_init  
 SET DEBUG_SYNC= 'after_backup_start_restore SIGNAL running WAIT_FOR finish';
 
 --echo con2: Send restore command.
+--echo con2: Backup id = 501.
 send RESTORE FROM 'backup_logs_orig.bak';
 
 connection con1;
@@ -156,25 +162,23 @@ connection con1;
 SET DEBUG_SYNC= 'now WAIT_FOR started';
 
 --echo con1: Display progress
-select * from backup_logs.t1_res;
-SELECT MAX(backup_id) INTO @bup_id FROM mysql.backup_progress;
-INSERT INTO backup_logs.t1_res (id) VALUES (@bup_id);
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 501;
 
 --echo con1: Let restore step to running state.
 SET DEBUG_SYNC= 'now SIGNAL do_run WAIT_FOR running';
 
 --echo con1: Display progress
-SELECT notes FROM mysql.backup_progress AS ob JOIN backup_logs.t1_res as t1 ON ob.backup_id = t1.id;
+SELECT notes FROM mysql.backup_progress WHERE backup_id = 501;
 
 --echo con1: Let restore do its job and finish.
 SET DEBUG_SYNC= 'now SIGNAL finish';
 
 connection con2;
 --echo con2: Finish restore command
---replace_column 1 #
 reap;
 
+FLUSH BACKUP LOGS;
+
 SET DEBUG_SYNC= 'now SIGNAL complete';
 
 connection con1;
@@ -182,41 +186,27 @@ connection con1;
 SET DEBUG_SYNC= 'now WAIT_FOR complete';
 
 #Show results
-DELETE FROM backup_logs.t1_res;
-SELECT MAX(backup_id) INTO @bup_id FROM mysql.backup_history WHERE command LIKE "RESTORE FROM%";
-INSERT INTO backup_logs.t1_res (id) VALUES (@bup_id);
 --replace_column 1 # 2 # 3 # 4 # 10 # 11 # 12 # 15 # 16 #
---query_vertical SELECT ob.* FROM mysql.backup_history AS ob JOIN backup_logs.t1_res AS t1 ON ob.backup_id = t1.id;
+--query_vertical SELECT * FROM mysql.backup_history WHERE backup_id = 501;
 --replace_column 1 # 3 # 4 #
-SELECT obp.* FROM mysql.backup_progress AS obp JOIN backup_logs.t1_res AS t1 ON obp.backup_id = t1.id;
+SELECT * FROM mysql.backup_progress WHERE backup_id = 501;
 
 SET DEBUG_SYNC= 'RESET';
 
-#
-# Now test read of backupid with known id using debug insertion
-#
-SET SESSION debug="d,set_backup_id";
-
 --remove_file $MYSQLTEST_VARDIR/master-data/backup_logs_orig.bak
-
-#
-# The first backup will cause the value to be set to 500 and written to file.
-# The second backup will read the value (500) and increment it.
-#--replace_column 1 #
+--echo The backup id for this command should be 502.
 BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
 
-SET SESSION debug="d";
-
 --remove_file $MYSQLTEST_VARDIR/master-data/backup_logs_orig.bak
---echo The backup id for this command should be 501.
+--echo The backup id for this command should be 503.
 BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
 
 --remove_file $MYSQLTEST_VARDIR/master-data/backup_logs_orig.bak
---echo The backup id for this command should be 502.
+--echo The backup id for this command should be 504.
 BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
 
 --remove_file $MYSQLTEST_VARDIR/master-data/backup_logs_orig.bak
---echo The backup id for this command should be 503.
+--echo The backup id for this command should be 505.
 BACKUP DATABASE backup_logs to 'backup_logs_orig.bak';
 
 #

=== added file 'mysql-test/suite/backup/t/backup_logs_output-master.opt'
--- a/mysql-test/suite/backup/t/backup_logs_output-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_logs_output-master.opt	2008-11-11 08:37:27 +0000
@@ -0,0 +1 @@
+--backup_history_log_file=$MYSQLTEST_VARDIR/master-data/history.txt --backup_progress_log_file=$MYSQLTEST_VARDIR/master-data/progress.txt --log-backup-output=FILE

=== modified file 'mysql-test/suite/backup/t/backup_logs_output.test'
--- a/mysql-test/suite/backup/t/backup_logs_output.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_logs_output.test	2008-11-10 16:49:10 +0000
@@ -11,7 +11,34 @@ connect (con1,localhost,root,,,,);
 --echo con1
 connection con1;
 
---echo Display backup variables
+--echo Clear the logs.
+SET @@global.backup_history_log = 'ON';
+SET @@global.backup_progress_log = 'ON';
+
+#
+# BUG#40219 No startup options for backup_*_logname.
+#
+--echo Display backup variable values from startup options file.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+SHOW VARIABLES LIKE 'backup_history%';
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+SHOW VARIABLES LIKE 'backup_progress%';
+SHOW VARIABLES LIKE 'log_backup_output';
+
+--echo Set the backup log file names to default values.
+SET @@global.backup_history_log_file = DEFAULT;
+SET @@global.backup_progress_log_file = DEFAULT;
+SET @@global.log_backup_output = 'TABLE';
+
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+
+--echo See that the log names have been reset.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+SHOW VARIABLES LIKE 'backup_history%';
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+SHOW VARIABLES LIKE 'backup_progress%';
+
 SHOW VARIABLES LIKE 'backup_history_log';
 SHOW VARIABLES LIKE 'backup_progress_log';
 SHOW VARIABLES LIKE 'log_backup_output';
@@ -28,9 +55,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
 SHOW VARIABLES LIKE 'backup_progress_log';
 SHOW VARIABLES LIKE 'log_backup_output';
 
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
-
 --echo Show the size of the logs
 SELECT count(*) FROM mysql.backup_history;
 SELECT count(*) FROM mysql.backup_progress;
@@ -71,8 +95,8 @@ SHOW VARIABLES LIKE 'backup_history_log'
 SHOW VARIABLES LIKE 'backup_progress_log';
 SHOW VARIABLES LIKE 'log_backup_output';
 
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
 
 --replace_column 1 #
 BACKUP DATABASE bup_log TO 'bup_log.bak';
@@ -91,6 +115,12 @@ FLUSH BACKUP LOGS;
 --echo '---Checking backup logs when log_backup_output is TABLE---'
 --echo '---and the progress log is turned off                   ---'
 
+--echo Clear the logs.
+SET @@global.backup_history_log = 'ON';
+SET @@global.backup_progress_log = 'ON';
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+
 SET @@global.backup_history_log = 'ON';
 SET @@global.backup_progress_log = 'OFF';
 
@@ -99,9 +129,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
 SHOW VARIABLES LIKE 'backup_progress_log';
 SHOW VARIABLES LIKE 'log_backup_output';
 
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
-
 --echo Show the size of the logs
 SELECT count(*) FROM mysql.backup_history;
 SELECT count(*) FROM mysql.backup_progress;
@@ -123,6 +150,12 @@ FLUSH BACKUP LOGS;
 --echo '---Checking backup logs when log_backup_output is TABLE---'
 --echo '---and the history log is turned off                 ---'
 
+--echo Clear the logs.
+SET @@global.backup_history_log = 'ON';
+SET @@global.backup_progress_log = 'ON';
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+
 SET @@global.backup_history_log = 'OFF';
 SET @@global.backup_progress_log = 'ON';
 
@@ -131,9 +164,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
 SHOW VARIABLES LIKE 'backup_progress_log';
 SHOW VARIABLES LIKE 'log_backup_output';
 
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
-
 --echo Show the size of the logs
 SELECT count(*) FROM mysql.backup_history;
 SELECT count(*) FROM mysql.backup_progress;
@@ -146,6 +176,12 @@ SELECT count(*) FROM mysql.backup_histor
 SELECT count(*) FROM mysql.backup_progress;
 
 FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+
+--echo Show the size of the logs
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
 --file_exists $MYSQLTEST_VARDIR/master-data/backup_history.log
 --file_exists $MYSQLTEST_VARDIR/master-data/backup_progress.log
 
@@ -165,15 +201,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
 SHOW VARIABLES LIKE 'backup_progress_log';
 SHOW VARIABLES LIKE 'log_backup_output';
 
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
-
-#
-# BUG#33364 - uncomment when purge command is implemented
-#
-# Purge the backup logs
-#PURGE BACKUP LOGS;
-
 --replace_column 1 #
 BACKUP DATABASE bup_log TO 'bup_log.bak';
 
@@ -182,12 +209,11 @@ SELECT count(*) FROM mysql.backup_histor
 SELECT count(*) FROM mysql.backup_progress;
 
 FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+
 --file_exists $MYSQLTEST_VARDIR/master-data/backup_history.log
 --file_exists $MYSQLTEST_VARDIR/master-data/backup_progress.log
 
-#
-# BUG#33364 - uncomment when purge command is implemented
-#
 # Check contents of logs for data. 
 #--error 0
 #--exec grep -q "BACKUP DATABASE bup_log TO 'bup_log.bak'" $MYSQLTEST_VARDIR/master-data/backup_history.log
@@ -206,15 +232,6 @@ SHOW VARIABLES LIKE 'backup_history_log'
 SHOW VARIABLES LIKE 'backup_progress_log';
 SHOW VARIABLES LIKE 'log_backup_output';
 
-TRUNCATE TABLE mysql.backup_history;
-TRUNCATE TABLE mysql.backup_progress;
-
-#
-# BUG#33364 - uncomment when purge command is implemented
-#
-# Purge the backup logs
-#PURGE BACKUP LOGS;
-
 --replace_column 1 #
 BACKUP DATABASE bup_log TO 'bup_log.bak';
 
@@ -238,6 +255,34 @@ FLUSH BACKUP LOGS;
 --error 0,1
 --remove_file $MYSQLTEST_VARDIR/master-data/bup_log.bak
 
+#
+# BUG#40218 Default setting incorrect
+#
+
+SET GLOBAL backup_history_log=0;
+SET GLOBAL backup_progress_log=0;
+
+--echo Should show 'OFF'
+SHOW VARIABLES LIKE 'backup%log';
+
+SET GLOBAL backup_history_log=1;
+SET GLOBAL backup_progress_log=1;
+
+--echo Should show 'ON'
+SHOW VARIABLES LIKE 'backup%log';
+
+SET GLOBAL backup_history_log=OFF;
+SET GLOBAL backup_progress_log=OFF;
+
+--echo Should show 'OFF'
+SHOW VARIABLES LIKE 'backup%log';
+
+SET GLOBAL backup_history_log=DEFAULT;
+SET GLOBAL backup_progress_log=DEFAULT;
+
+--echo After set default still should show 'ON'
+SHOW VARIABLES LIKE 'backup%log';
+
 --echo Cleanup
 DROP DATABASE bup_log;
 

=== added file 'mysql-test/suite/backup/t/backup_logs_purge.test'
--- a/mysql-test/suite/backup/t/backup_logs_purge.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_logs_purge.test	2008-10-28 14:17:05 +0000
@@ -0,0 +1,462 @@
+#
+# This test includes tests for ensuring the backup logs can be purged
+# of data.
+#
+
+--source include/not_embedded.inc
+--source include/have_debug_sync.inc
+--source include/have_debug.inc
+--source include/have_innodb.inc
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+
+SET @@global.log_backup_output = 'FILE,TABLE';
+
+PURGE BACKUP LOGS;
+
+--echo 
+--echo Now starting real tests
+--echo 
+
+# Create a database and some data to work with.
+
+--disable_warnings
+DROP DATABASE IF EXISTS backup_logs;
+--enable warnings
+CREATE DATABASE backup_logs;
+
+--echo Create table and populate with data.
+
+CREATE TABLE backup_logs.t1 (a char(30)) ENGINE=MYISAM;
+CREATE TABLE backup_logs.t2 (a char(30)) ENGINE=INNODB;
+CREATE TABLE backup_logs.t3 (a char(30)) ENGINE=MEMORY;
+
+INSERT INTO backup_logs.t1 VALUES ("01 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("02 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("03 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("04 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("05 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("06 Test #1 - progress"); 
+INSERT INTO backup_logs.t1 VALUES ("07 Test #1 - progress"); 
+
+INSERT INTO backup_logs.t2 VALUES ("01 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("02 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("03 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("04 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("05 Test #1 - progress"); 
+INSERT INTO backup_logs.t2 VALUES ("06 Test #1 - progress"); 
+
+INSERT INTO backup_logs.t3 VALUES ("01 Test #1 - progress"); 
+INSERT INTO backup_logs.t3 VALUES ("02 Test #1 - progress"); 
+INSERT INTO backup_logs.t3 VALUES ("03 Test #1 - progress"); 
+INSERT INTO backup_logs.t3 VALUES ("04 Test #1 - progress"); 
+
+#
+# Now test read of backupid with known id using debug insertion
+#
+SET SESSION debug="+d,set_backup_id";
+
+--echo Do backup of database
+BACKUP DATABASE backup_logs to 'backup1.bak';
+
+SET SESSION debug="-d";
+
+--echo Do backup of database
+BACKUP DATABASE backup_logs to 'backup2.bak';
+
+--echo Do backup of database
+BACKUP DATABASE backup_logs to 'backup3.bak';
+
+--echo Do backup of database
+BACKUP DATABASE backup_logs to 'backup4.bak';
+
+--echo Do restore of database
+RESTORE from 'backup1.bak';
+
+--echo Do restore of database
+RESTORE from 'backup2.bak';
+
+--echo Do restore of database
+RESTORE from 'backup3.bak';
+
+--echo Do restore of database
+RESTORE from 'backup4.bak';
+
+--file_exists $MYSQLTEST_VARDIR/master-data/backup1.bak
+--file_exists $MYSQLTEST_VARDIR/master-data/backup2.bak
+--file_exists $MYSQLTEST_VARDIR/master-data/backup3.bak
+--file_exists $MYSQLTEST_VARDIR/master-data/backup4.bak
+
+--echo Display results from backup logs
+SELECT backup_id FROM mysql.backup_history;
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+--echo Purge all backup log data prior to id = 502.
+PURGE BACKUP LOGS TO 502;
+
+--echo Display results from backup logs
+SELECT backup_id FROM mysql.backup_history;
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+--echo Purge all backup log data.
+PURGE BACKUP LOGS;
+
+--echo Display results from backup logs
+SELECT backup_id FROM mysql.backup_history;
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+--echo Cleanup the logs and images for later testing.
+PURGE BACKUP LOGS;
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup1.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup2.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup3.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup4.bak
+
+SET @@time_zone = '+00:00';
+
+SET SESSION debug="+d,set_backup_id";
+
+--echo Do backup of database
+BACKUP DATABASE backup_logs to 'backup1.bak';
+
+SET SESSION debug="-d";
+
+--echo Do backup of database
+BACKUP DATABASE backup_logs to 'backup2.bak';
+
+--echo Do backup of database
+BACKUP DATABASE backup_logs to 'backup3.bak';
+
+SET SESSION debug="+d,set_log_time";
+
+--echo Do backup of database
+BACKUP DATABASE backup_logs to 'backup4.bak';
+
+SET SESSION debug="-d";
+
+--echo Do restore of database
+RESTORE from 'backup1.bak';
+
+--echo Do restore of database
+RESTORE from 'backup2.bak';
+
+--echo Do restore of database
+RESTORE from 'backup3.bak';
+
+SET SESSION debug="+d,set_log_time";
+
+--echo Do restore of database
+RESTORE from 'backup4.bak';
+
+SET SESSION debug="-d";
+
+--file_exists $MYSQLTEST_VARDIR/master-data/backup1.bak
+--file_exists $MYSQLTEST_VARDIR/master-data/backup2.bak
+--file_exists $MYSQLTEST_VARDIR/master-data/backup3.bak
+--file_exists $MYSQLTEST_VARDIR/master-data/backup4.bak
+
+--echo Display the results.
+SELECT backup_id FROM mysql.backup_history;
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+
+#
+# We need to sleep to allow time to pass in order to ensure the time
+# compare method in log.cc has two different times to compare.
+#
+real_sleep 3;
+
+SET @now_time= now();
+
+PURGE BACKUP LOGS BEFORE @now_time; 
+
+SELECT backup_id FROM mysql.backup_history;
+SELECT DISTINCT backup_id FROM mysql.backup_progress;
+
+SET @@time_zone = @@global.time_zone;
+
+PURGE BACKUP LOGS;
+
+#
+# Test purge of logs for locations other than backupdir.
+#
+--echo Perform backup
+SET SESSION debug="+d,set_backup_id";
+
+BACKUP DATABASE backup_logs TO '../bup_logs_dir.bak';
+
+SET SESSION debug="-d";
+
+--echo Ensure backup image file went to the correct location
+--file_exists $MYSQLTEST_VARDIR/bup_logs_dir.bak
+
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+PURGE BACKUP LOGS TO 501;
+
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+#
+# Test error conditions.
+#
+
+--error ER_BACKUP_PURGE_DATETIME
+PURGE BACKUP LOGS BEFORE 123123;
+
+SET @@global.log_backup_output = 'FILE';
+
+--error ER_BACKUP_LOG_OUTPUT
+PURGE BACKUP LOGS TO 99999999;
+
+--error ER_BACKUP_LOG_OUTPUT
+PURGE BACKUP LOGS BEFORE @now_time;
+
+SET @@global.log_backup_output = 'TABLE';
+
+#
+# Now test what happens when PURGE is run at the same
+# time as a backup or restore is run.
+#
+
+--echo Test backup and purge concurrent execution.
+
+PURGE BACKUP LOGS;
+
+--echo Get rid of any lingering image files.
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup1.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup2.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup3.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup4.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/bup_logs_dir.bak
+
+SET DEBUG_SYNC= 'RESET';
+
+connection con1;
+
+--echo con2: Do some backups to add entries in logs.
+--replace_column 1 #
+BACKUP DATABASE backup_logs to 'backup1.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs to 'backup2.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs to 'backup3.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs to 'backup4.bak';
+
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+connection con2;
+
+SET SESSION debug="+d,set_backup_id";
+
+#
+# Stop backup after it has written rows to the logs but before
+# it writes the history log and last complete log entry.
+#
+--echo con2: Activate sync points for the backup statement.
+SET DEBUG_SYNC= 'before_backup_done SIGNAL ready WAIT_FOR proceed';
+SEND BACKUP DATABASE backup_logs to 'backup5.bak';
+
+connection con1;
+
+--echo con1: Wait for the backup to be ready.
+SET DEBUG_SYNC= 'now WAIT_FOR ready';
+
+PURGE BACKUP LOGS;
+
+SET DEBUG_SYNC= 'now SIGNAL proceed';
+
+connection con2;
+--replace_column 1 #
+reap;
+
+SET SESSION debug="-d";
+
+connection con1;
+
+--echo There should be one row in this table: the backup id from last
+--echo backup (500).
+SELECT count(*) FROM mysql.backup_history;
+SELECT backup_id, command FROM mysql.backup_history;
+
+--echo There should be one row in this table: the backup id from last
+--echo backup (500). We should only see the complete progress 
+--echo statement because all others were deleted while backup was
+--echo in progress.
+SELECT count(*) FROM mysql.backup_progress;
+--replace_column 3 # 4 #
+--query_vertical SELECT * FROM mysql.backup_progress
+
+--echo Now do the same test for restore.
+
+--replace_column 1 #
+RESTORE FROM 'backup1.bak';
+--replace_column 1 #
+RESTORE FROM 'backup2.bak';
+--replace_column 1 #
+RESTORE FROM 'backup3.bak';
+--replace_column 1 #
+RESTORE FROM 'backup4.bak';
+
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+connection con2;
+
+#
+# Stop restore after it has written rows to the logs but before
+# it writes the history log and last complete log entry.
+#
+--echo con2: Activate sync points for the backup statement.
+SET DEBUG_SYNC= 'before_restore_done SIGNAL ready WAIT_FOR proceed';
+SEND RESTORE FROM 'backup5.bak';
+
+connection con1;
+
+--echo con1: Wait for the backup to be ready.
+SET DEBUG_SYNC= 'now WAIT_FOR ready';
+
+PURGE BACKUP LOGS;
+
+SET DEBUG_SYNC= 'now SIGNAL proceed';
+
+connection con2;
+--replace_column 1 #
+reap;
+
+connection con1;
+
+--echo There should be one row in this table: the backup id from last
+--echo restore (505).
+SELECT count(*) FROM mysql.backup_history;
+SELECT backup_id, command FROM mysql.backup_history;
+
+--echo There should be one row in this table: the backup id from last
+--echo restore (505). We should only see the complete progress 
+--echo statement because all others were deleted while restore was
+--echo in progress.
+SELECT count(*) FROM mysql.backup_progress;
+--replace_column 3 # 4 #
+--query_vertical SELECT * FROM mysql.backup_progress
+
+#
+# Test removal of entries that do not meet criteria and
+# removal of all entries.
+#
+
+--remove_file $MYSQLTEST_VARDIR/master-data/backup1.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/backup2.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/backup3.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/backup4.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/backup5.bak
+
+--echo First, run some backups.
+
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup1.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup2.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup3.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup4.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup5.bak';
+
+--echo Test purges that do not meet criteria.
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+PURGE BACKUP LOGS BEFORE '1988-10-12 12:00:00';
+
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+PURGE BACKUP LOGS TO 0;
+
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+--echo Test empty logs (delete all entries).
+
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+PURGE BACKUP LOGS TO 999999999;
+
+--echo Check to be sure backup logs are empty (count(*) = 0).
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+--remove_file $MYSQLTEST_VARDIR/master-data/backup1.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/backup2.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/backup3.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/backup4.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/backup5.bak
+
+--echo Run some more backups to generate more rows.
+
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup1.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup2.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup3.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup4.bak';
+--replace_column 1 #
+BACKUP DATABASE backup_logs TO 'backup5.bak';
+
+--echo Test purges that do not meet criteria.
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+PURGE BACKUP LOGS BEFORE '2024-10-12 12:00:00';
+
+--echo Test empty logs (delete all entries).
+
+SELECT count(*) FROM mysql.backup_history;
+SELECT count(*) FROM mysql.backup_progress;
+
+
+#
+# Cleanup.
+#
+
+SET DEBUG_SYNC= 'RESET';
+
+DROP DATABASE backup_logs;
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup1.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup2.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup3.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup4.bak
+--error 0,1
+--remove_file $MYSQLTEST_VARDIR/master-data/backup5.bak
+
+PURGE BACKUP LOGS;
+
+

=== modified file 'mysql-test/suite/backup/t/backup_no_be.test'
--- a/mysql-test/suite/backup/t/backup_no_be.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_no_be.test	2008-10-30 10:41:48 +0000
@@ -33,7 +33,7 @@ INSERT INTO t1 VALUES (1),(2),(3);
 # First check the normal behaviour when server is not modified.
 
 # make sure that injected code is disabled
-SET SESSION debug="d,";
+SET SESSION debug="-d,";
 SELECT @@debug;
 
 # BACKUP should succeed without a warning.
@@ -56,7 +56,7 @@ SELECT drivers FROM mysql.backup_history
 # Now see what happens when injected code is activated and MyISAM uses the dummy
 # factory function.
 
-SET SESSION debug="d,backup_test_dummy_be_factory";
+SET SESSION debug="+d,backup_test_dummy_be_factory";
 SELECT @@debug;
 
 # The following BACKUP command should generate a warning but otherwise
@@ -91,5 +91,5 @@ SHOW TABLES IN db1;
 # Clean up.
 
 DROP DATABASE db1;
-SET GLOBAL debug="d,";
+SET GLOBAL debug="-d,";
 --remove_file $MYSQLTEST_VARDIR/master-data/db1.bak

=== removed file 'mysql-test/suite/backup/t/backup_view_on_view.test'
--- a/mysql-test/suite/backup/t/backup_view_on_view.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_view_on_view.test	1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
-# Test case for bug#34758
-
---source include/not_embedded.inc
---source include/have_debug.inc
---source include/have_innodb.inc
-
-# Setup the server to use the backup breakpoints
-SET GLOBAL debug="d,backup:d,backup_data";
-
---disable_warnings
-DROP DATABASE IF EXISTS db1;
---enable_warnings
-
-CREATE DATABASE db1;
-
-CREATE TABLE db1.t1(a int) ENGINE=INNODB;
-CREATE VIEW db1.v1 AS SELECT * FROM db1.t1;
-CREATE VIEW db1.v2 AS SELECT * FROM db1.v1;
-
-INSERT INTO db1.t1 VALUES (1),(2),(3),(5),(7),(11);
-
-replace_column 1 #;
-BACKUP DATABASE db1 TO 'test.bak';
-replace_column 1 #;
-RESTORE FROM 'test.bak';
-
-SELECT * FROM db1.v2;
-SELECT * FROM db1.v1;
-SELECT * FROM db1.t1;
-
-DROP DATABASE db1;
-

=== modified file 'mysql-test/suite/backup/t/disabled.def'
--- a/mysql-test/suite/backup/t/disabled.def	2008-10-09 11:45:40 +0000
+++ b/mysql-test/suite/backup/t/disabled.def	2008-10-30 10:41:48 +0000
@@ -11,6 +11,6 @@
 ##############################################################################
 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_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

=== modified file 'mysql-test/suite/backup_engines/include/backup_ptr_objects.inc'
--- a/mysql-test/suite/backup_engines/include/backup_ptr_objects.inc	2008-10-08 04:26:25 +0000
+++ b/mysql-test/suite/backup_engines/include/backup_ptr_objects.inc	2008-11-12 17:42:23 +0000
@@ -38,9 +38,15 @@ SET timestamp=@a;
 # procedure p1, p2 and p3 are created in ptr_ob1 and p4 in ptr_ob2.
 #
 
+# Get rid of old objects in the databases.
+--disable_warnings
+DROP DATABASE IF EXISTS ptr_ob1;
+DROP DATABASE IF EXISTS ptr_ob2;
+--enable_warnings
+
 # Create database
-CREATE DATABASE IF NOT EXISTS ptr_ob1;
-CREATE DATABASE IF NOT EXISTS ptr_ob2;
+CREATE DATABASE ptr_ob1;
+CREATE DATABASE ptr_ob2;
 USE ptr_ob1;
 
 --echo **** Creating tables ****
@@ -109,9 +115,10 @@ BEGIN
 END;||
 delimiter ;||
 
-INSERT INTO ptr_ob1.t2 VALUES
-(NULL, 'Normal Insert1'),(NULL, 'Normal Insert2'),
-(NULL, 'Normal Insert3'),(NULL, 'Normal Insert4');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert1');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert2');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert3');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert4');
 SELECT * FROM ptr_ob1.t2;
 SELECT * FROM ptr_ob1.t3;
 

=== modified file 'mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result	2008-10-08 04:26:25 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_objects_mixed.result	2008-11-12 17:42:23 +0000
@@ -14,8 +14,10 @@ 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;
+DROP DATABASE IF EXISTS ptr_ob1;
+DROP DATABASE IF EXISTS ptr_ob2;
+CREATE DATABASE ptr_ob1;
+CREATE DATABASE ptr_ob2;
 USE ptr_ob1;
 **** Creating tables ****
 CREATE TABLE ptr_ob1.t1(
@@ -102,9 +104,10 @@ CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT
 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');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert1');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert2');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert3');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert4');
 SELECT * FROM ptr_ob1.t2;
 id	data
 1	Normal Insert1

=== modified file 'mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result	2008-10-08 04:26:25 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_objects_row.result	2008-11-12 17:42:23 +0000
@@ -14,8 +14,10 @@ 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;
+DROP DATABASE IF EXISTS ptr_ob1;
+DROP DATABASE IF EXISTS ptr_ob2;
+CREATE DATABASE ptr_ob1;
+CREATE DATABASE ptr_ob2;
 USE ptr_ob1;
 **** Creating tables ****
 CREATE TABLE ptr_ob1.t1(
@@ -102,9 +104,10 @@ CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT
 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');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert1');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert2');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert3');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert4');
 SELECT * FROM ptr_ob1.t2;
 id	data
 1	Normal Insert1

=== modified file 'mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result	2008-10-08 04:26:25 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_objects_stmt.result	2008-11-12 17:42:23 +0000
@@ -14,8 +14,10 @@ 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;
+DROP DATABASE IF EXISTS ptr_ob1;
+DROP DATABASE IF EXISTS ptr_ob2;
+CREATE DATABASE ptr_ob1;
+CREATE DATABASE ptr_ob2;
 USE ptr_ob1;
 **** Creating tables ****
 CREATE TABLE ptr_ob1.t1(
@@ -102,9 +104,10 @@ CREATE TRIGGER ptr_ob1.trg2 AFTER INSERT
 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');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert1');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert2');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert3');
+INSERT INTO ptr_ob1.t2 VALUES (NULL, 'Normal Insert4');
 SELECT * FROM ptr_ob1.t2;
 id	data
 1	Normal Insert1

=== added file 'mysql-test/suite/backup_engines/r/backup_tmp_tables.result'
--- a/mysql-test/suite/backup_engines/r/backup_tmp_tables.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_tmp_tables.result	2008-10-30 12:29:54 +0000
@@ -0,0 +1,58 @@
+SHOW VARIABLES LIKE 'storage_engine';
+Variable_name	Value
+storage_engine	#
+** Pre-cleanup
+DROP DATABASE IF EXISTS db;
+** Create a database
+CREATE DATABASE db;
+USE db;
+** Create regular tables
+CREATE TABLE t1 (a int);
+CREATE TABLE t2 (a char(1));
+** Create a view
+CREATE VIEW v1 AS SELECT * FROM t1;
+** Store table's definition for later check
+** Insert some data into the tables
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES ('x');
+** Create temporary tables with the same name, but different layout
+** and using different storage engines
+CREATE TEMPORARY TABLE t1 (b text, c int) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE t2 (b int, c blob) ENGINE=InnoDB;
+** Insert data into the temporary tables
+INSERT INTO t1 VALUES ('foo', 2);
+INSERT INTO t2 VALUES (3, 'bar');
+** Backup database
+BACKUP DATABASE db TO 'db.bkp';
+backup_id
+#
+** Drop and restore the database
+DROP TABLE t1;
+DROP TABLE t2;
+RESTORE FROM 'db.bkp';
+backup_id
+#
+** Check definitions of the tables after restore
+table_t1
+0
+table_t2
+0
+** Checking data after restore
+SELECT * FROM t1;
+a
+1
+SELECT * FROM t2;
+a
+x
+SELECT * FROM v1;
+a
+1
+** Checking if restored table is seen from other connection
+SELECT * FROM db.t1;
+a
+1
+SELECT * FROM db.t2;
+a
+x
+** Cleanup
+DROP DATABASE db;

=== added file 'mysql-test/suite/backup_engines/t/backup_tmp_tables.test'
--- a/mysql-test/suite/backup_engines/t/backup_tmp_tables.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_tmp_tables.test	2008-11-12 17:42:23 +0000
@@ -0,0 +1,92 @@
+#
+# Test that BACKUP works correctly in the presence of temporary tables
+# with the same names as tables being backed-up (BUG#33574, BUG#34903).
+#
+
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source suite/backup_engines/include/backup_engine.inc
+
+let $bdir= `SELECT @@backupdir`;
+
+--echo ** Pre-cleanup
+--disable_warnings
+DROP DATABASE IF EXISTS db;
+--error 0,1
+--remove_file $bdir/db.bkp
+--enable_warnings
+
+--echo ** Create a database
+CREATE DATABASE db;
+USE db;
+
+--echo ** Create regular tables
+CREATE TABLE t1 (a int);
+CREATE TABLE t2 (a char(1));
+
+--echo ** Create a view
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+--echo ** Store table's definition for later check
+let $stmt1= query_get_value(SHOW CREATE TABLE t1, Create Table, 1);
+let $stmt2= query_get_value(SHOW CREATE TABLE t2, Create Table, 1);
+
+--echo ** Insert some data into the tables
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES ('x');
+
+--echo ** Create temporary tables with the same name, but different layout
+--echo ** and using different storage engines
+CREATE TEMPORARY TABLE t1 (b text, c int) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE t2 (b int, c blob) ENGINE=InnoDB;
+
+--echo ** Insert data into the temporary tables
+INSERT INTO t1 VALUES ('foo', 2);
+INSERT INTO t2 VALUES (3, 'bar');
+
+--echo ** Backup database
+--replace_column 1 #
+BACKUP DATABASE db TO 'db.bkp';
+
+--echo ** Drop and restore the database
+DROP TABLE t1;
+DROP TABLE t2;
+--replace_column 1 #
+RESTORE FROM 'db.bkp';
+
+#
+# Note: Above DROP TABLE statements should be removed once BUG#30099 is fixed.
+#
+
+--echo ** Check definitions of the tables after restore
+let $stmt1a= query_get_value(SHOW CREATE TABLE t1, Create Table, 1);
+let $stmt2a= query_get_value(SHOW CREATE TABLE t2, Create Table, 1);
+--disable_query_log
+--eval SELECT strcmp("$stmt1","$stmt1a") AS table_t1
+--eval SELECT strcmp("$stmt2","$stmt2a") AS table_t2
+--enable_query_log
+
+#
+# Note: The above tests using strcmp() might be too sensitive, although they 
+# work now. Theoreticaly the details of the CREATE TABLE statement produced by 
+# SHOW CREATE TABLE could be different even if RESTORE works ok. If you see 
+# result missmatch here, analyse carefully what are the differences before 
+# reporting a bug. The main purpose of above checks is to  ensure that RESTORE 
+# haven't wrongly captured definitions of the temporary tables instead of the 
+# regular ones.
+#
+
+--echo ** Checking data after restore
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM v1;
+
+--echo ** Checking if restored table is seen from other connection
+connect (A, localhost, root,,);
+--connection A
+SELECT * FROM db.t1;
+SELECT * FROM db.t2;
+
+--echo ** Cleanup
+DROP DATABASE db;
+--remove_file $bdir/db.bkp

=== added file 'mysql-test/suite/rpl/r/rpl_backup.result'
--- a/mysql-test/suite/rpl/r/rpl_backup.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_backup.result	2008-10-31 15:31:52 +0000
@@ -0,0 +1,335 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+Create some data...
+CREATE DATABASE rpl_backup;
+CREATE TABLE rpl_backup.t1 (a int);
+INSERT INTO rpl_backup.t1 VALUES (1), (2), (3), (4), (5);
+Remove all entries in the backup logs.
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+Remove all entries in the backup logs.
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+Get master's binlog position from the slave before backup.
+Get master's binlog position before backup.
+SET SESSION debug="+d,set_backup_id";
+Backup_id = 500.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_m1.bak';
+backup_id
+500
+SET SESSION debug="-d";
+Show any events issued as a result of backup.
+Note: There should be none!
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+Verify backup run on master does not advance binlog pos.
+Get master's binlog position after backup.
+Compare the before position of the master's binlog to
+the after position of the master's binlog. The result
+should be 0.
+Delta
+0
+Should have count(*) = 0.
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+0
+Verify backup run on master does not advance binlog pos.
+Get master's binlog position on the slave after backup.
+Compare the before position of the master's binlog to
+the after position of the slave's binlog as shown on
+on the slave. The result should be 0.
+Delta
+0
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	#
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	Yes
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	0
+Last_Error	
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	0
+Last_IO_Error	
+Last_SQL_Errno	0
+Last_SQL_Error	
+Ensure replication is still working...
+Cleanup from last error on master and slave.
+DELETE FROM rpl_backup.t1;
+INSERT INTO rpl_backup.t1 VALUES (11), (22), (33);
+SELECT count(*) FROM rpl_backup.t1;
+count(*)
+3
+SELECT count(*) FROM rpl_backup.t1;
+count(*)
+3
+Cleanup backup logs.
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+First, get master's binlog position and filename.
+SET SESSION debug="+d,set_backup_id";
+Backup_id = 600.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_s1.bak';
+backup_id
+600
+SET SESSION debug="-d";
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	#
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	Yes
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	0
+Last_Error	
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	0
+Last_IO_Error	
+Last_SQL_Errno	0
+Last_SQL_Error	
+Check saving of master's binlog information.
+Should have count(*) = 1.
+count(*)
+1
+Should have count(*) = 1.
+SELECT count(*) FROM mysql.backup_history;
+count(*)
+1
+INSERT INTO rpl_backup.t1 VALUES (10), (20), (30);
+Backup_id = 501.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_m2.bak';
+backup_id
+501
+SELECT count(*) FROM rpl_backup.t1;
+count(*)
+6
+SELECT count(*) FROM rpl_backup.t1;
+count(*)
+6
+Make a backup for later use.
+Backup_id = 601.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_s2.bak';
+backup_id
+601
+CREATE TABLE rpl_backup.t2 (b int);
+INSERT INTO rpl_backup.t2 VALUES (888), (999);
+Get master's binlog position before restore.
+Backup_id = 502.
+RESTORE FROM 'rpl_bup_m2.bak';
+backup_id
+502
+Show the incident event issued as a result of restore.
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Incident	1	#	#2 (RESTORE_ON_MASTER)
+master-bin.000001	#	Rotate	1	#	master-bin.000002;pos=4
+Showing tables on master.
+SHOW FULL TABLES FROM rpl_backup;
+Tables_in_rpl_backup	Table_type
+t1	BASE TABLE
+SELECT count(*) FROM rpl_backup.t1;
+count(*)
+6
+Check slave got everything up to incident event.
+Should be two rows: 888, 999.
+SELECT * FROM rpl_backup.t2 WHERE b > 800;
+b
+888
+999
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	#
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1590
+Last_Error	The incident RESTORE_ON_MASTER occured on the master. Message: A restore operation was initiated on the master.
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	0
+Last_IO_Error	
+Last_SQL_Errno	1590
+Last_SQL_Error	The incident RESTORE_ON_MASTER occured on the master. Message: A restore operation was initiated on the master.
+Show the slave stopped with an error.
+Last_SQL_Error
+The incident RESTORE_ON_MASTER occured on the master. Message: A restore operation was initiated on the master.
+SET global sql_slave_skip_counter=1;
+STOP SLAVE;
+START SLAVE;
+Showing tables on slave.
+SHOW FULL TABLES FROM rpl_backup;
+Tables_in_rpl_backup	Table_type
+t1	BASE TABLE
+t2	BASE TABLE
+STOP SLAVE;
+Backup_id = 602.
+RESTORE FROM '../master-data/rpl_bup_m2.bak';
+backup_id
+602
+Showing databases on slave.
+SHOW DATABASES LIKE 'rpl_backup%';
+Database (rpl_backup%)
+rpl_backup
+SELECT count(*) FROM rpl_backup.t1;
+count(*)
+6
+START SLAVE;
+Make a backup for later use.
+Backup_id = 603.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_s3.bak';
+backup_id
+603
+Test restore on slave while replication turned on.
+RESTORE FROM 'rpl_bup_s1.bak';
+ERROR HY000: A restore operation was attempted on a slave during replication. You must stop the slave prior to running a restore.
+Stop slave and restart after restore.
+STOP SLAVE;
+RESTORE FROM 'rpl_bup_s3.bak';
+backup_id
+#
+START SLAVE;
+Checking affect on replication.
+INSERT INTO rpl_backup.t1 VALUES (44), (55), (66);
+SELECT * FROM rpl_backup.t1 ORDER BY a;
+a
+10
+11
+20
+22
+30
+33
+44
+55
+66
+SELECT * FROM rpl_backup.t1 ORDER BY a;
+a
+10
+11
+20
+22
+30
+33
+44
+55
+66
+Stop replication and turn off binary log.
+STOP SLAVE;
+SET @orig_sql_log_bin= @@sql_log_bin;
+Turn off binlog.
+SET @@sql_log_bin= 0;
+SHOW VARIABLES LIKE '%log_bin';
+Variable_name	Value
+log_bin	ON
+sql_log_bin	OFF
+Backup_id = 503.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_m3.bak';
+backup_id
+503
+Turn on binlog;
+SET @@sql_log_bin= @orig_sql_log_bin;
+SHOW VARIABLES LIKE '%log_bin';
+Variable_name	Value
+log_bin	ON
+sql_log_bin	ON
+RESET MASTER;
+Get master's binlog position before restore.
+Backup_id = 504.
+RESTORE FROM 'rpl_bup_m3.bak';
+backup_id
+504
+Get master's binlog position after restore.
+Show the incident event issued as a result of restore.
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Incident	1	#	#2 (RESTORE_ON_MASTER)
+master-bin.000001	#	Rotate	1	#	master-bin.000002;pos=4
+Compute the difference of the binlog positions.
+Result should be 0.
+Compare the before position of the master's binlog to
+the after position of the master's binlog. The result
+should be 0.
+Delta
+0
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+DROP DATABASE rpl_backup;
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+DROP DATABASE rpl_backup;

=== added file 'mysql-test/suite/rpl/r/rpl_extraCol_falcon.result'
--- a/mysql-test/suite/rpl/r/rpl_extraCol_falcon.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_extraCol_falcon.result	2008-11-17 10:57:50 +0000
@@ -0,0 +1,969 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+**** Diff Table Def Start ****
+*** On Slave ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t1 (a INT, b INT PRIMARY KEY, c CHAR(20),
+d FLOAT DEFAULT '2.00', 
+e CHAR(4) DEFAULT 'TEST') 
+ENGINE='Falcon';
+*** Create t1 on Master ***
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c CHAR(10)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t1 () VALUES(1,2,'TEXAS'),(2,1,'AUSTIN'),(3,4,'QA');
+SELECT * FROM t1 ORDER BY a;
+a	b	c
+1	2	TEXAS
+2	1	AUSTIN
+3	4	QA
+*** Select from slave ***
+SELECT * FROM t1 ORDER BY a;
+a	b	c	d	e
+1	2	TEXAS	2	TEST
+2	1	AUSTIN	2	TEST
+3	4	QA	2	TEST
+*** Drop t1  ***
+DROP TABLE t1;
+*** Create t2 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t2 (a INT, b INT PRIMARY KEY, c CHAR(5),
+d FLOAT DEFAULT '2.00',
+e CHAR(5) DEFAULT 'TEST2')
+ENGINE='Falcon';
+*** Create t2 on Master ***
+CREATE TABLE t2 (a INT PRIMARY KEY, b INT, c CHAR(10)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Master Data Insert ***
+INSERT INTO t2 () VALUES(1,2,'Kyle, TEX'),(2,1,'JOE AUSTIN'),(3,4,'QA TESTING');
+SELECT * FROM t2 ORDER BY a;
+a	b	c
+1	2	Kyle, TEX
+2	1	JOE AUSTIN
+3	4	QA TESTING
+*** Start Slave ***
+START SLAVE;
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 2 size mismatch - master has size 10, test.t2 on slave has size 6. Master's column size should be <= the slave's column size.
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 2 size mismatch - master has size 10, test.t2 on slave has size 6. Master's column size should be <= the slave's column size.
+STOP SLAVE;
+RESET SLAVE;
+SELECT * FROM t2 ORDER BY a;
+a	b	c	d	e
+RESET MASTER;
+START SLAVE;
+*** Drop t2  ***
+DROP TABLE t2;
+*** Create t3 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t3 (a INT, b INT PRIMARY KEY, c CHAR(20),
+d FLOAT DEFAULT '2.00',
+e CHAR(5) DEFAULT 'TEST2')
+ENGINE='Falcon';
+*** Create t3 on Master ***
+CREATE TABLE t3 (a BLOB, b INT PRIMARY KEY, c CHAR(20)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t3 () VALUES(@b1,2,'Kyle, TEX'),(@b1,1,'JOE AUSTIN'),(@b1,4,'QA TESTING');
+********************************************
+*** Expect slave to fail with Error 1522 ***
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 0 type mismatch - received type 252, test.t3 has type 3
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+START SLAVE;
+*** Drop t3  ***
+DROP TABLE t3;
+*** Create t4 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t4 (a INT, b INT PRIMARY KEY, c CHAR(20),
+d FLOAT DEFAULT '2.00',
+e CHAR(5) DEFAULT 'TEST2')
+ENGINE='Falcon';
+*** Create t4 on Master ***
+CREATE TABLE t4 (a DECIMAL(8,2), b INT PRIMARY KEY, c CHAR(20)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t4 () VALUES(100.22,2,'Kyle, TEX'),(200.26,1,'JOE AUSTIN'),
+(30000.22,4,'QA TESTING');
+********************************************
+*** Expect slave to fail with Error 1522 ***
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 0 type mismatch - received type 246, test.t4 has type 3
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+START SLAVE;
+*** Drop t4  ***
+DROP TABLE t4;
+*** Create t5 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t5 (a INT PRIMARY KEY, b CHAR(5),
+c FLOAT, d INT, e DOUBLE,
+f DECIMAL(8,2))ENGINE='Falcon';
+*** Create t5 on Master ***
+CREATE TABLE t5 (a INT PRIMARY KEY, b VARCHAR(6),
+c DECIMAL(8,2), d BIT, e BLOB,
+f FLOAT) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t5 () VALUES(1,'Kyle',200.23,1,'b1b1',23.00098),
+(2,'JOE',300.01,0,'b2b2',1.0000009);
+********************************************
+*** Expect slave to fail with Error 1522 ***
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 5 type mismatch - received type 4, test.t5 has type 246
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+START SLAVE;
+*** Drop t5  ***
+DROP TABLE t5;
+*** Create t6 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t6 (a INT PRIMARY KEY, b CHAR(5),
+c FLOAT, d INT)ENGINE='Falcon';
+*** Create t6 on Master ***
+CREATE TABLE t6 (a INT PRIMARY KEY, b VARCHAR(6),
+c DECIMAL(8,2), d BIT 
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t6 () VALUES(1,'Kyle',200.23,1),
+(2,'JOE',300.01,0);
+********************************************
+*** Expect slave to fail with Error 1522 ***
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 3 type mismatch - received type 16, test.t6 has type 3
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3;
+*** Drop t6  ***
+DROP TABLE t6;
+DROP TABLE t6;
+START SLAVE;
+**** Diff Table Def End ****
+**** Extra Colums Start ****
+*** Create t7 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t7 (a INT KEY, b BLOB, c CHAR(5),
+d TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00',
+e CHAR(20) DEFAULT 'Extra Column Testing')
+ENGINE='Falcon';
+*** Create t7 on Master ***
+CREATE TABLE t7 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t7 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
+SELECT * FROM t7 ORDER BY a;
+a	b	c
+1	b1b1	Kyle
+2	b1b1	JOE
+3	b1b1	QA
+*** Select from slave ***
+SELECT * FROM t7 ORDER BY a;
+a	b	c	d	e
+1	b1b1	Kyle	0000-00-00 00:00:00	Extra Column Testing
+2	b1b1	JOE	0000-00-00 00:00:00	Extra Column Testing
+3	b1b1	QA	0000-00-00 00:00:00	Extra Column Testing
+*** Drop t7  ***
+DROP TABLE t7;
+*** Create t8 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t8 (a INT KEY, b BLOB, c CHAR(5),
+d TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00',
+e INT)ENGINE='Falcon';
+*** Create t8 on Master ***
+CREATE TABLE t8 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t8 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
+*** Drop t8  ***
+DROP TABLE t8;
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t9 (a INT KEY, b BLOB, c CHAR(5),
+d TIMESTAMP,
+e INT NOT NULL) ENGINE='Falcon';
+*** Create t9 on Master ***
+CREATE TABLE t9 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t9 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1364
+Last_Error	Could not execute Write_rows event on table test.t9; Field 'e' doesn't have a default value, Error_code: 1364; handler error HA_ERR_ROWS_EVENT_APPLY; the event's master log master-bin.000001, end_log_pos 331
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1364
+Last_SQL_Error	Could not execute Write_rows event on table test.t9; Field 'e' doesn't have a default value, Error_code: 1364; handler error HA_ERR_ROWS_EVENT_APPLY; the event's master log master-bin.000001, end_log_pos 331
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+START SLAVE;
+*** Create t10 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t10 (a INT KEY, b BLOB, f DOUBLE DEFAULT '233', 
+c CHAR(5), e INT DEFAULT '1')ENGINE='Falcon';
+*** Create t10 on Master ***
+CREATE TABLE t10 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t10 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
+********************************************
+*** Expect slave to fail with Error 1522 ***
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 2 type mismatch - received type 254, test.t10 has type 5
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+START SLAVE;
+*** Drop t10  ***
+DROP TABLE t10;
+*** Create t11 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t11 (a INT KEY, b BLOB, f TEXT,
+c CHAR(5) DEFAULT 'test', e INT DEFAULT '1')ENGINE='Falcon';
+*** Create t11 on Master ***
+CREATE TABLE t11 (a INT PRIMARY KEY, b BLOB, c VARCHAR(254)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t11 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
+********************************************
+*** Expect slave to fail with Error 1522 ***
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 2 type mismatch - received type 15, test.t11 has type 252
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+START SLAVE;
+*** Drop t11  ***
+DROP TABLE t11;
+*** Create t12 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t12 (a INT KEY, b BLOB, f TEXT,
+c CHAR(5) DEFAULT 'test', e INT DEFAULT '1')ENGINE='Falcon';
+*** Create t12 on Master ***
+CREATE TABLE t12 (a INT PRIMARY KEY, b BLOB, c BLOB
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t12 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
+SELECT * FROM t12 ORDER BY a;
+a	b	c
+1	b1b1b1b1b1b1b1b1	Kyle
+2	b1b1b1b1b1b1b1b1	JOE
+3	b1b1b1b1b1b1b1b1	QA
+*** Select on Slave ***
+SELECT * FROM t12 ORDER BY a;
+a	b	f	c	e
+1	b1b1b1b1b1b1b1b1	Kyle	test	1
+2	b1b1b1b1b1b1b1b1	JOE	test	1
+3	b1b1b1b1b1b1b1b1	QA	test	1
+*** Drop t12  ***
+DROP TABLE t12;
+**** Extra Colums End ****
+*** BUG 22177 Start ***
+*** Create t13 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t13 (a INT KEY, b BLOB, c CHAR(5),
+d INT DEFAULT '1',
+e TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+*** Create t13 on Master ***
+CREATE TABLE t13 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t13 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
+SELECT * FROM t13 ORDER BY a;
+a	b	c
+1	b1b1b1b1b1b1b1b1	Kyle
+2	b1b1b1b1b1b1b1b1	JOE
+3	b1b1b1b1b1b1b1b1	QA
+*** Select on Slave ****
+SELECT * FROM t13 ORDER BY a;
+a	b	c	d	e
+1	b1b1b1b1b1b1b1b1	Kyle	1	CURRENT_TIMESTAMP
+2	b1b1b1b1b1b1b1b1	JOE	1	CURRENT_TIMESTAMP
+3	b1b1b1b1b1b1b1b1	QA	1	CURRENT_TIMESTAMP
+*** Drop t13  ***
+DROP TABLE t13;
+*** 22117 END *** 
+*** Alter Master Table Testing Start ***
+*** Create t14 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t14 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
+c6 INT DEFAULT '1',
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+*** Create t14 on Master ***
+CREATE TABLE t14 (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+ALTER TABLE t14 ADD COLUMN c2 DECIMAL(8,2) AFTER c1;
+ALTER TABLE t14 ADD COLUMN c3 TEXT AFTER c2;
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t14 () VALUES(1,1.00,'Replication Testing Extra Col',@b1,'Kyle'),
+(2,2.00,'This Test Should work',@b1,'JOE'),
+(3,3.00,'If is does not, I will open a bug',@b1,'QA');
+SELECT * FROM t14 ORDER BY c1;
+c1	c2	c3	c4	c5
+1	1.00	Replication Testing Extra Col	b1b1b1b1b1b1b1b1	Kyle
+2	2.00	This Test Should work	b1b1b1b1b1b1b1b1	JOE
+3	3.00	If is does not, I will open a bug	b1b1b1b1b1b1b1b1	QA
+*** Select on Slave ****
+SELECT * FROM t14 ORDER BY c1;
+c1	c2	c3	c4	c5	c6	c7
+1	1.00	Replication Testing Extra Col	b1b1b1b1b1b1b1b1	Kyle	1	CURRENT_TIMESTAMP
+2	2.00	This Test Should work	b1b1b1b1b1b1b1b1	JOE	1	CURRENT_TIMESTAMP
+3	3.00	If is does not, I will open a bug	b1b1b1b1b1b1b1b1	QA	1	CURRENT_TIMESTAMP
+*** Create t14a on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t14a (c1 INT KEY, c4 BLOB, c5 CHAR(5),
+c6 INT DEFAULT '1',
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+*** Create t14a on Master ***
+CREATE TABLE t14a (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t14a () VALUES(1,@b1,'Kyle'),
+(2,@b1,'JOE'),
+(3,@b1,'QA');
+SELECT * FROM t14a ORDER BY c1;
+c1	c4	c5
+1	b1b1b1b1b1b1b1b1	Kyle
+2	b1b1b1b1b1b1b1b1	JOE
+3	b1b1b1b1b1b1b1b1	QA
+*** Select on Slave ****
+SELECT * FROM t14a ORDER BY c1;
+c1	c4	c5	c6	c7
+1	b1b1b1b1b1b1b1b1	Kyle	1	CURRENT_TIMESTAMP
+2	b1b1b1b1b1b1b1b1	JOE	1	CURRENT_TIMESTAMP
+3	b1b1b1b1b1b1b1b1	QA	1	CURRENT_TIMESTAMP
+STOP SLAVE;
+RESET SLAVE;
+*** Master Drop c5 ***
+ALTER TABLE t14a DROP COLUMN c5;
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t14a () VALUES(4,@b1),
+(5,@b1),
+(6,@b1);
+SELECT * FROM t14a ORDER BY c1;
+c1	c4
+1	b1b1b1b1b1b1b1b1
+2	b1b1b1b1b1b1b1b1
+3	b1b1b1b1b1b1b1b1
+4	b1b1b1b1b1b1b1b1
+5	b1b1b1b1b1b1b1b1
+6	b1b1b1b1b1b1b1b1
+*** Select on Slave ****
+SELECT * FROM t14a ORDER BY c1;
+c1	c4	c5	c6	c7
+1	b1b1b1b1b1b1b1b1	Kyle	1	CURRENT_TIMESTAMP
+2	b1b1b1b1b1b1b1b1	JOE	1	CURRENT_TIMESTAMP
+3	b1b1b1b1b1b1b1b1	QA	1	CURRENT_TIMESTAMP
+4	b1b1b1b1b1b1b1b1	NULL	1	CURRENT_TIMESTAMP
+5	b1b1b1b1b1b1b1b1	NULL	1	CURRENT_TIMESTAMP
+6	b1b1b1b1b1b1b1b1	NULL	1	CURRENT_TIMESTAMP
+*** connect to master and drop columns ***
+ALTER TABLE t14 DROP COLUMN c2;
+ALTER TABLE t14 DROP COLUMN c4;
+*** Select from Master ***
+SELECT * FROM t14 ORDER BY c1;
+c1	c3	c5
+1	Replication Testing Extra Col	Kyle
+2	This Test Should work	JOE
+3	If is does not, I will open a bug	QA
+*** Select from Slave ***
+SELECT * FROM t14 ORDER BY c1;
+c1	c3	c5	c6	c7
+1	Replication Testing Extra Col	Kyle	1	CURRENT_TIMESTAMP
+2	This Test Should work	JOE	1	CURRENT_TIMESTAMP
+3	If is does not, I will open a bug	QA	1	CURRENT_TIMESTAMP
+*** Drop t14  ***
+DROP TABLE t14;
+*** Create t15 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t15 (c1 INT KEY, c2 DECIMAL(8,2), c3 TEXT,
+c4 BLOB, c5 CHAR(5),
+c6 INT DEFAULT '1',
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+*** Create t15 on Master ***
+CREATE TABLE t15 (c1 INT PRIMARY KEY, c2 DECIMAL(8,2), c3 TEXT,
+c4 BLOB, c5 CHAR(5)) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t15 () VALUES(1,1.00,'Replication Testing Extra Col',@b1,'Kyle'),
+(2,2.00,'This Test Should work',@b1,'JOE'),
+(3,3.00,'If is does not, I will open a bug',@b1,'QA');
+SELECT * FROM t15 ORDER BY c1;
+c1	c2	c3	c4	c5
+1	1.00	Replication Testing Extra Col	b1b1b1b1b1b1b1b1	Kyle
+2	2.00	This Test Should work	b1b1b1b1b1b1b1b1	JOE
+3	3.00	If is does not, I will open a bug	b1b1b1b1b1b1b1b1	QA
+*** Select on Slave ****
+SELECT * FROM t15 ORDER BY c1;
+c1	c2	c3	c4	c5	c6	c7
+1	1.00	Replication Testing Extra Col	b1b1b1b1b1b1b1b1	Kyle	1	CURRENT_TIMESTAMP
+2	2.00	This Test Should work	b1b1b1b1b1b1b1b1	JOE	1	CURRENT_TIMESTAMP
+3	3.00	If is does not, I will open a bug	b1b1b1b1b1b1b1b1	QA	1	CURRENT_TIMESTAMP
+*** Add column on master that is a Extra on Slave ***
+ALTER TABLE t15 ADD COLUMN c6 INT AFTER c5;
+********************************************
+*** Expect slave to fail with Error 1060 ***
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1060
+Last_Error	Error 'Duplicate column name 'c6'' on query. Default database: 'test'. Query: 'ALTER TABLE t15 ADD COLUMN c6 INT AFTER c5'
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1060
+Last_SQL_Error	Error 'Duplicate column name 'c6'' on query. Default database: 'test'. Query: 'ALTER TABLE t15 ADD COLUMN c6 INT AFTER c5'
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+*** Try to insert in master ****
+INSERT INTO t15 () VALUES(5,2.00,'Replication Testing',@b1,'Buda',2);
+SELECT * FROM t15 ORDER BY c1;
+c1	c2	c3	c4	c5	c6
+1	1.00	Replication Testing Extra Col	b1b1b1b1b1b1b1b1	Kyle	NULL
+2	2.00	This Test Should work	b1b1b1b1b1b1b1b1	JOE	NULL
+3	3.00	If is does not, I will open a bug	b1b1b1b1b1b1b1b1	QA	NULL
+5	2.00	Replication Testing	b1b1b1b1b1b1b1b1	Buda	2
+*** Try to select from slave ****
+SELECT * FROM t15 ORDER BY c1;
+c1	c2	c3	c4	c5	c6	c7
+1	1.00	Replication Testing Extra Col	b1b1b1b1b1b1b1b1	Kyle	1	CURRENT_TIMESTAMP
+2	2.00	This Test Should work	b1b1b1b1b1b1b1b1	JOE	1	CURRENT_TIMESTAMP
+3	3.00	If is does not, I will open a bug	b1b1b1b1b1b1b1b1	QA	1	CURRENT_TIMESTAMP
+5	2.00	Replication Testing	b1b1b1b1b1b1b1b1	Buda	2	CURRENT_TIMESTAMP
+*** DROP TABLE t15 ***
+DROP TABLE t15;
+*** Create t16 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t16 (c1 INT KEY, c2 DECIMAL(8,2), c3 TEXT,
+c4 BLOB, c5 CHAR(5),
+c6 INT DEFAULT '1',
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+*** Create t16 on Master ***
+CREATE TABLE t16 (c1 INT PRIMARY KEY, c2 DECIMAL(8,2), c3 TEXT,
+c4 BLOB, c5 CHAR(5))ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t16 () VALUES(1,1.00,'Replication Testing Extra Col',@b1,'Kyle'),
+(2,2.00,'This Test Should work',@b1,'JOE'),
+(3,3.00,'If is does not, I will open a bug',@b1,'QA');
+SELECT * FROM t16 ORDER BY c1;
+c1	c2	c3	c4	c5
+1	1.00	Replication Testing Extra Col	b1b1b1b1b1b1b1b1	Kyle
+2	2.00	This Test Should work	b1b1b1b1b1b1b1b1	JOE
+3	3.00	If is does not, I will open a bug	b1b1b1b1b1b1b1b1	QA
+*** Select on Slave ****
+SELECT * FROM t16 ORDER BY c1;
+c1	c2	c3	c4	c5	c6	c7
+1	1.00	Replication Testing Extra Col	b1b1b1b1b1b1b1b1	Kyle	1	CURRENT_TIMESTAMP
+2	2.00	This Test Should work	b1b1b1b1b1b1b1b1	JOE	1	CURRENT_TIMESTAMP
+3	3.00	If is does not, I will open a bug	b1b1b1b1b1b1b1b1	QA	1	CURRENT_TIMESTAMP
+*** Add Partition on master ***
+ALTER TABLE t16 PARTITION BY KEY(c1) PARTITIONS 4;
+INSERT INTO t16 () VALUES(4,1.00,'Replication Rocks',@b1,'Omer');
+SHOW CREATE TABLE t16;
+Table	Create Table
+t16	CREATE TABLE `t16` (
+  `c1` int(11) NOT NULL,
+  `c2` decimal(8,2) DEFAULT NULL,
+  `c3` text,
+  `c4` blob,
+  `c5` char(5) DEFAULT NULL,
+  PRIMARY KEY (`c1`)
+) ENGINE=Falcon DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (c1)
+PARTITIONS 4 */
+*** Show table on Slave ****
+SHOW CREATE TABLE t16;
+Table	Create Table
+t16	CREATE TABLE `t16` (
+  `c1` int(11) NOT NULL,
+  `c2` decimal(8,2) DEFAULT NULL,
+  `c3` text,
+  `c4` blob,
+  `c5` char(5) DEFAULT NULL,
+  `c6` int(11) DEFAULT '1',
+  `c7` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`c1`)
+) ENGINE=Falcon DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (c1)
+PARTITIONS 4 */
+*** DROP TABLE t16 ***
+DROP TABLE t16;
+*** Alter Master End ***
+*** Create t17 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t17 (a SMALLINT, b INT PRIMARY KEY, c CHAR(5),
+d FLOAT DEFAULT '2.00',
+e CHAR(5) DEFAULT 'TEST2')
+ENGINE='Falcon';
+*** Create t17 on Master ***
+CREATE TABLE t17 (a BIGINT PRIMARY KEY, b INT, c CHAR(10)
+) ENGINE='Falcon';
+RESET MASTER;
+*** Start Slave ***
+START SLAVE;
+*** Master Data Insert ***
+INSERT INTO t17 () VALUES(9223372036854775807,2,'Kyle, TEX');
+********************************************
+*** Expect slave to fail with Error 1522 ***
+********************************************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	#
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 0 type mismatch - received type 8, test.t17 has type 2
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+START SLAVE;
+** DROP table t17 ***
+DROP TABLE t17;

=== added file 'mysql-test/suite/rpl/r/rpl_extraColmaster_falcon.result'
--- a/mysql-test/suite/rpl/r/rpl_extraColmaster_falcon.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_extraColmaster_falcon.result	2008-11-17 10:57:50 +0000
@@ -0,0 +1,1144 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+
+***********************************************************
+***********************************************************
+***************** Start of Testing ************************
+***********************************************************
+***********************************************************
+* This test format == binlog_format	ROW and engine == 'Falcon'
+***********************************************************
+***********************************************************
+
+***** Testing more columns on the Master *****
+
+CREATE TABLE t1 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20),
+/* extra */
+f5 FLOAT DEFAULT '2.00', 
+f6 CHAR(4) DEFAULT 'TEST',
+f7 INT DEFAULT '0',
+f8 TEXT,
+f9 LONGBLOB,
+f10 BIT(63),
+f11 VARBINARY(64))ENGINE='Falcon';
+
+* Alter Table on Slave and drop columns f5 through f11 *
+
+alter table t1 drop f5, drop f6, drop f7, drop f8, drop f9, drop f10, drop f11;
+
+* Insert data in Master then update and delete some rows*
+
+* Select count and 20 rows from Master *
+
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+40
+
+SELECT f1,f2,f3,f4,f5,f6,f7,f8,f9,
+hex(f10),hex(f11) FROM t1 ORDER BY f3 LIMIT 20;
+f1	f2	f3	f4	f5	f6	f7	f8	f9	hex(f10)	hex(f11)
+2	2	2	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+3	3	3	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+5	5	5	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+6	6	6	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+8	8	8	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+9	9	9	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+11	11	11	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+12	12	12	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+14	14	14	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+15	15	15	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+17	17	17	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+18	18	18	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+20	20	20	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+21	21	21	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+23	23	23	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+24	24	24	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+26	26	26	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+27	27	27	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+29	29	29	second	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+30	30	30	next	2	kaks	2	got stolen from the paradise	very fat blob	1555	123456
+
+* Select count and 20 rows from Slave *
+
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+40
+
+SELECT * FROM t1 ORDER BY f3 LIMIT 20;
+f1	f2	f3	f4
+2	2	2	second
+3	3	3	next
+5	5	5	second
+6	6	6	next
+8	8	8	second
+9	9	9	next
+11	11	11	second
+12	12	12	next
+14	14	14	second
+15	15	15	next
+17	17	17	second
+18	18	18	next
+20	20	20	second
+21	21	21	next
+23	23	23	second
+24	24	24	next
+26	26	26	second
+27	27	27	next
+29	29	29	second
+30	30	30	next
+
+* Show Slave Status *
+
+show slave status;;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	Yes
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	0
+Last_Error	
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	0
+Last_SQL_Error	
+
+
+***** Testing Altering table def scenario *****
+
+CREATE TABLE t2 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20),
+/* extra */
+f5 DOUBLE DEFAULT '2.00', 
+f6 ENUM('a', 'b', 'c') default 'a',
+f7 DECIMAL(17,9) default '1000.00',
+f8 MEDIUMBLOB,
+f9 NUMERIC(6,4) default '2000.00',
+f10 VARCHAR(1024),
+f11 BINARY(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
+f12 SET('a', 'b', 'c') default 'b')
+ENGINE='Falcon';
+Warnings:
+Warning	1264	Out of range value for column 'f9' at row 1
+
+CREATE TABLE t3 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20),
+/* extra */
+f5 DOUBLE DEFAULT '2.00', 
+f6 ENUM('a', 'b', 'c') default 'a',
+f8 MEDIUMBLOB,
+f10 VARCHAR(1024),
+f11 BINARY(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
+f12 SET('a', 'b', 'c') default 'b')
+ENGINE='Falcon';
+
+CREATE TABLE t4 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20),
+/* extra */
+f5 DOUBLE DEFAULT '2.00', 
+f6 DECIMAL(17,9) default '1000.00',
+f7 MEDIUMBLOB,
+f8 NUMERIC(6,4) default '2000.00',
+f9 VARCHAR(1024),
+f10 BINARY(20) not null default '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
+f11 CHAR(255))
+ENGINE='Falcon';
+Warnings:
+Warning	1264	Out of range value for column 'f8' at row 1
+
+CREATE TABLE t31 (f1 INT, f2 INT, f3 INT PRIMARY KEY, f4 CHAR(20),
+/* extra */
+f5  BIGINT,
+f6  BLOB,
+f7  DATE,
+f8  DATETIME,
+f9  FLOAT,
+f10 INT,
+f11 LONGBLOB,
+f12 LONGTEXT,
+f13 MEDIUMBLOB,
+f14 MEDIUMINT,
+f15 MEDIUMTEXT,
+f16 REAL,
+f17 SMALLINT,
+f18 TEXT,
+f19 TIME,
+f20 TIMESTAMP,
+f21 TINYBLOB,
+f22 TINYINT,
+f23 TINYTEXT,
+f24 YEAR,
+f25 BINARY(255),
+f26 BIT(64),
+f27 CHAR(255),
+f28 DECIMAL(30,7),
+f29 DOUBLE,
+f30 ENUM ('a','b', 'c') default 'a',
+f31 FLOAT,
+f32 NUMERIC(17,9),
+f33 SET ('a', 'b', 'c') default 'b',
+f34 VARBINARY(1025),
+f35 VARCHAR(257)       
+) ENGINE='Falcon';
+
+** Alter tables on slave and drop columns **
+
+alter table t2 drop f5, drop f6, drop f7, drop f8, drop f9, drop f10, drop f11, drop
+f12;
+alter table t3 drop f5, drop f6, drop f8, drop f10, drop f11, drop f12;
+alter table t4 drop f5, drop f6, drop f7, drop f8, drop f9, drop f10, drop f11;
+alter table t31 
+drop f5, drop f6, drop f7, drop f8, drop f9, drop f10, drop f11,
+drop f12, drop f13, drop f14, drop f15, drop f16, drop f17, drop f18,
+drop f19, drop f20, drop f21, drop f22, drop f23, drop f24, drop f25,
+drop f26, drop f27, drop f28, drop f29, drop f30, drop f31, drop f32,
+drop f33, drop f34, drop f35;
+
+** Insert Data into Master **
+INSERT into t2 set f1=1, f2=1, f3=1, f4='first', f8='f8: medium size blob', f10='f10:
+some var char';
+INSERT into t2 values (2, 2, 2, 'second',
+2.0, 'b', 2000.0002, 'f8: medium size blob', 2000, 'f10: some var char',
+'01234567', 'c'),
+(3, 3, 3, 'third',
+3.0, 'b', 3000.0003, 'f8: medium size blob', 3000, 'f10: some var char',
+'01234567', 'c');
+Warnings:
+Warning	1264	Out of range value for column 'f9' at row 1
+Warning	1264	Out of range value for column 'f9' at row 2
+INSERT into t3 set f1=1, f2=1, f3=1, f4='first', f10='f10: some var char';
+INSERT into t4 set f1=1, f2=1, f3=1, f4='first', f7='f7: medium size blob', f10='f10:
+binary data';
+INSERT into t31 set f1=1, f2=1, f3=1, f4='first';
+INSERT into t31 set f1=1, f2=1, f3=2, f4='second',
+f9=2.2,  f10='seven samurai', f28=222.222, f35='222';
+Warnings:
+Warning	1366	Incorrect integer value: 'seven samurai' for column 'f10' at row 1
+INSERT into t31 values (1, 1, 3, 'third',
+/* f5  BIGINT,  */            333333333333333333333333,
+/* f6  BLOB,  */              '3333333333333333333333',
+/* f7  DATE,  */              '2007-07-18',
+/* f8  DATETIME,  */          "2007-07-18",
+/* f9  FLOAT,  */             3.33333333,
+/* f10 INT,  */               333333333,
+/* f11 LONGBLOB,  */          '3333333333333333333',
+/* f12 LONGTEXT,  */          '3333333333333333333',
+/* f13 MEDIUMBLOB,  */        '3333333333333333333',
+/* f14 MEDIUMINT,  */         33,
+/* f15 MEDIUMTEXT,  */        3.3,
+/* f16 REAL,  */              3.3,
+/* f17 SMALLINT,  */          3,
+/* f18 TEXT,  */              '33',
+/* f19 TIME,  */              '2:59:58.999',
+/* f20 TIMESTAMP,  */         20000303000000,
+/* f21 TINYBLOB,  */          '3333',
+/* f22 TINYINT,  */           3,
+/* f23 TINYTEXT,  */          '3',
+/* f24 YEAR,  */              3000,
+/* f25 BINARY(255),  */       'three_33333',
+/* f26 BIT(64),  */           b'011', 
+/* f27 CHAR(255),  */         'three',
+/* f28 DECIMAL(30,7),  */     3.333,
+/* f29 DOUBLE,  */            3.333333333333333333333333333,
+/* f30 ENUM ('a','b','c')*/   'c',
+/* f31 FLOAT,  */             3.0,
+/* f32 NUMERIC(17,9),  */     3.3333,
+/* f33 SET ('a','b','c'),*/   'c',
+/*f34 VARBINARY(1025),*/      '3333 minus 3',
+/*f35 VARCHAR(257),*/         'three times three'
+      );
+Warnings:
+Warning	1264	Out of range value for column 'f5' at row 1
+Warning	1264	Out of range value for column 'f24' at row 1
+INSERT into t31 values (1, 1, 4, 'fourth',
+/* f5  BIGINT,  */            333333333333333333333333,
+/* f6  BLOB,  */              '3333333333333333333333',
+/* f7  DATE,  */              '2007-07-18',
+/* f8  DATETIME,  */          "2007-07-18",
+/* f9  FLOAT,  */             3.33333333,
+/* f10 INT,  */               333333333,
+/* f11 LONGBLOB,  */          '3333333333333333333',
+/* f12 LONGTEXT,  */          '3333333333333333333',
+/* f13 MEDIUMBLOB,  */        '3333333333333333333',
+/* f14 MEDIUMINT,  */         33,
+/* f15 MEDIUMTEXT,  */        3.3,
+/* f16 REAL,  */              3.3,
+/* f17 SMALLINT,  */          3,
+/* f18 TEXT,  */              '33',
+/* f19 TIME,  */              '2:59:58.999',
+/* f20 TIMESTAMP,  */         20000303000000,
+/* f21 TINYBLOB,  */          '3333',
+/* f22 TINYINT,  */           3,
+/* f23 TINYTEXT,  */          '3',
+/* f24 YEAR,  */              3000,
+/* f25 BINARY(255),  */       'three_33333',
+/* f26 BIT(64),  */           b'011',
+/* f27 CHAR(255),  */         'three',
+/* f28 DECIMAL(30,7),  */     3.333,
+/* f29 DOUBLE,  */            3.333333333333333333333333333,
+/* f30 ENUM ('a','b','c')*/   'c',
+/* f31 FLOAT,  */             3.0,
+/* f32 NUMERIC(17,9),  */     3.3333,
+/* f33 SET ('a','b','c'),*/   'c',
+/*f34 VARBINARY(1025),*/      '3333 minus 3',
+/*f35 VARCHAR(257),*/         'three times three'
+       ),
+(1, 1, 5, 'fifth',
+/* f5  BIGINT,  */            333333333333333333333333,
+/* f6  BLOB,  */              '3333333333333333333333',
+/* f7  DATE,  */              '2007-07-18',
+/* f8  DATETIME,  */          "2007-07-18",
+/* f9  FLOAT,  */             3.33333333,
+/* f10 INT,  */               333333333,
+/* f11 LONGBLOB,  */          '3333333333333333333',
+/* f12 LONGTEXT,  */          '3333333333333333333',
+/* f13 MEDIUMBLOB,  */        '3333333333333333333',
+/* f14 MEDIUMINT,  */         33,
+/* f15 MEDIUMTEXT,  */        3.3,
+/* f16 REAL,  */              3.3,
+/* f17 SMALLINT,  */          3,
+/* f18 TEXT,  */              '33',
+/* f19 TIME,  */              '2:59:58.999',
+/* f20 TIMESTAMP,  */         20000303000000,
+/* f21 TINYBLOB,  */          '3333',
+/* f22 TINYINT,  */           3,
+/* f23 TINYTEXT,  */          '3',
+/* f24 YEAR,  */              3000,
+/* f25 BINARY(255),  */       'three_33333',
+/* f26 BIT(64),  */           b'011',
+/* f27 CHAR(255),  */         'three',
+/* f28 DECIMAL(30,7),  */     3.333,
+/* f29 DOUBLE,  */            3.333333333333333333333333333,
+/* f30 ENUM ('a','b','c')*/   'c',
+/* f31 FLOAT,  */             3.0,
+/* f32 NUMERIC(17,9),  */     3.3333,
+/* f33 SET ('a','b','c'),*/   'c',
+/*f34 VARBINARY(1025),*/      '3333 minus 3',
+/*f35 VARCHAR(257),*/         'three times three'
+       ),
+(1, 1, 6, 'sixth',
+/* f5  BIGINT,  */            NULL,
+/* f6  BLOB,  */              '3333333333333333333333',
+/* f7  DATE,  */              '2007-07-18',
+/* f8  DATETIME,  */          "2007-07-18",
+/* f9  FLOAT,  */             3.33333333,
+/* f10 INT,  */               333333333,
+/* f11 LONGBLOB,  */          '3333333333333333333',
+/* f12 LONGTEXT,  */          '3333333333333333333',
+/* f13 MEDIUMBLOB,  */        '3333333333333333333',
+/* f14 MEDIUMINT,  */         33,
+/* f15 MEDIUMTEXT,  */        3.3,
+/* f16 REAL,  */              3.3,
+/* f17 SMALLINT,  */          3,
+/* f18 TEXT,  */              '33',
+/* f19 TIME,  */              '2:59:58.999',
+/* f20 TIMESTAMP,  */         20000303000000,
+/* f21 TINYBLOB,  */          '3333',
+/* f22 TINYINT,  */           3,
+/* f23 TINYTEXT,  */          '3',
+/* f24 YEAR,  */              3000,
+/* f25 BINARY(255),  */       'three_33333',
+/* f26 BIT(64),  */           b'011',
+/* f27 CHAR(255),  */         'three',
+/* f28 DECIMAL(30,7),  */     3.333,
+/* f29 DOUBLE,  */            3.333333333333333333333333333,
+/* f30 ENUM ('a','b','c')*/   'c',
+/* f31 FLOAT,  */             3.0,
+/* f32 NUMERIC(17,9),  */     3.3333,
+/* f33 SET ('a','b','c'),*/   'c',
+/*f34 VARBINARY(1025),*/      '3333 minus 3',
+/*f35 VARCHAR(257),*/         NULL
+);
+Warnings:
+Warning	1264	Out of range value for column 'f5' at row 1
+Warning	1264	Out of range value for column 'f24' at row 1
+Warning	1264	Out of range value for column 'f5' at row 2
+Warning	1264	Out of range value for column 'f24' at row 2
+Warning	1264	Out of range value for column 'f24' at row 3
+
+** Sync slave with master ** 
+** Do selects from tables **
+
+select * from t1 order by f3;
+f1	f2	f3	f4
+2	2	2	second
+3	3	3	next
+5	5	5	second
+6	6	6	next
+8	8	8	second
+9	9	9	next
+11	11	11	second
+12	12	12	next
+14	14	14	second
+15	15	15	next
+17	17	17	second
+18	18	18	next
+20	20	20	second
+21	21	21	next
+23	23	23	second
+24	24	24	next
+26	26	26	second
+27	27	27	next
+29	29	29	second
+30	30	30	next
+31	31	31	second
+32	32	32	second
+33	33	33	second
+34	34	34	second
+35	35	35	second
+36	36	36	second
+37	37	37	second
+38	38	38	second
+39	39	39	second
+40	40	40	second
+41	41	41	second
+42	42	42	second
+43	43	43	second
+44	44	44	second
+45	45	45	second
+46	46	46	second
+47	47	47	second
+48	48	48	second
+49	49	49	second
+50	50	50	second
+select * from t2 order by f1;
+f1	f2	f3	f4
+1	1	1	first
+2	2	2	second
+3	3	3	third
+select * from t3 order by f1;
+f1	f2	f3	f4
+1	1	1	first
+select * from t4 order by f1;
+f1	f2	f3	f4
+1	1	1	first
+select * from t31 order by f3;
+f1	f2	f3	f4
+1	1	1	first
+1	1	2	second
+1	1	3	third
+1	1	4	fourth
+1	1	5	fifth
+1	1	6	sixth
+
+** Do updates master **
+
+update t31 set f5=555555555555555 where f3=6;
+update t31 set f2=2 where f3=2;
+update t31 set f1=NULL where f3=1;
+update t31 set f3=0, f27=NULL, f35='f35 new value' where f3=3;
+
+** Delete from Master **
+
+delete from t1;
+delete from t2;
+delete from t3;
+delete from t4;
+delete from t31;
+
+** Check slave status **
+
+select * from t31;
+f1	f2	f3	f4
+show slave status;;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	Yes
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	0
+Last_Error	
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	0
+Last_SQL_Error	
+
+****************************************
+* columns in master at middle of table *
+* Expect: Proper error message         *
+****************************************
+
+** Stop and Reset Slave **
+
+STOP SLAVE;
+RESET SLAVE;
+
+** create table slave side **
+CREATE TABLE t10 (a INT PRIMARY KEY, b BLOB, c CHAR(5)
+) ENGINE='Falcon';
+
+** Connect to master and create table **
+
+CREATE TABLE t10 (a INT KEY, b BLOB, f DOUBLE DEFAULT '233',
+c CHAR(5), e INT DEFAULT '1')ENGINE='Falcon';
+RESET MASTER;
+
+*** Start Slave ***
+START SLAVE;
+
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t10 () VALUES(1,@b1,DEFAULT,'Kyle',DEFAULT),
+(2,@b1,DEFAULT,'JOE',DEFAULT),
+(3,@b1,DEFAULT,'QA',DEFAULT);
+
+********************************************
+*** Expect slave to fail with Error 1523 ***
+********************************************
+
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 2 type mismatch - received type 5, test.t10 has type 254
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 2 type mismatch - received type 5, test.t10 has type 254
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+START SLAVE;
+
+*** Drop t10  ***
+DROP TABLE t10;
+
+*********************************************
+* More columns in master at middle of table *
+* Expect: Proper error message              *
+*********************************************
+
+*** Create t11 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t11 (a INT PRIMARY KEY, b BLOB, c VARCHAR(254)
+) ENGINE='Falcon';
+
+*** Create t11 on Master ***
+CREATE TABLE t11 (a INT KEY, b BLOB, f TEXT,
+c CHAR(5) DEFAULT 'test', e INT DEFAULT '1')ENGINE='Falcon';
+RESET MASTER;
+
+*** Start Slave ***
+START SLAVE;
+
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t11 () VALUES(1,@b1,'Testing is fun','Kyle',DEFAULT),
+(2,@b1,'Testing is cool','JOE',DEFAULT),
+(3,@b1,DEFAULT,'QA',DEFAULT);
+
+********************************************
+*** Expect slave to fail with Error 1523 ***
+********************************************
+
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1535
+Last_Error	Table definition on master and slave does not match: Column 2 type mismatch - received type 252, test.t11 has type 15
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1535
+Last_SQL_Error	Table definition on master and slave does not match: Column 2 type mismatch - received type 252, test.t11 has type 15
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+START SLAVE;
+
+*** Drop t11  ***
+DROP TABLE t11;
+
+*********************************************
+* More columns in master at middle of table *
+* Expect: This one should pass blob-text    *
+*********************************************
+
+*** Create t12 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t12 (a INT PRIMARY KEY, b BLOB, c BLOB
+) ENGINE='Falcon';
+
+*** Create t12 on Master ***
+CREATE TABLE t12 (a INT KEY, b BLOB, f TEXT,
+c CHAR(5) DEFAULT 'test', e INT DEFAULT '1')ENGINE='Falcon';
+RESET MASTER;
+
+*** Start Slave ***
+START SLAVE;
+
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t12 () VALUES(1,@b1,'Kyle',DEFAULT,DEFAULT),
+(2,@b1,'JOE',DEFAULT,DEFAULT),
+(3,@b1,'QA',DEFAULT,DEFAULT);
+
+SELECT a,hex(b),f,c,e FROM t12 ORDER BY a;
+a	hex(b)	f	c	e
+1	62316231623162316231623162316231	Kyle	test	1
+2	62316231623162316231623162316231	JOE	test	1
+3	62316231623162316231623162316231	QA	test	1
+
+*** Select on Slave ***
+SELECT a,hex(b),c FROM t12 ORDER BY a;
+a	hex(b)	c
+1	62316231623162316231623162316231	Kyle
+2	62316231623162316231623162316231	JOE
+3	62316231623162316231623162316231	QA
+
+*** Drop t12  ***
+DROP TABLE t12;
+
+****************************************************
+* - Alter Master adding columns at middle of table *
+*   Expect: columns added                          *
+****************************************************
+
+
+*** Create t14 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t14 (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
+) ENGINE='Falcon';
+
+*** Create t14 on Master ***
+CREATE TABLE t14 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
+c6 INT DEFAULT '1',
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+RESET MASTER;
+
+*** Start Slave ***
+START SLAVE;
+
+*** Master Data Insert ***
+ALTER TABLE t14 ADD COLUMN c2 DECIMAL(8,2) AFTER c1;
+ALTER TABLE t14 ADD COLUMN c3 TEXT AFTER c2;
+
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t14 () VALUES(1,1.00,'Replication Testing Extra Col',@b1,'Kyle',DEFAULT,DEFAULT),
+(2,2.00,'This Test Should work',@b1,'JOE',DEFAULT,DEFAULT),
+(3,3.00,'If is does not, I will open a bug',@b1,'QA',DEFAULT,DEFAULT);
+
+SELECT c1,c2,c3,hex(c4),c5,c6,c7 FROM t14 ORDER BY c1;
+c1	c2	c3	hex(c4)	c5	c6	c7
+1	1.00	Replication Testing Extra Col	62316231623162316231623162316231	Kyle	1	CURRENT_TIMESTAMP
+2	2.00	This Test Should work	62316231623162316231623162316231	JOE	1	CURRENT_TIMESTAMP
+3	3.00	If is does not, I will open a bug	62316231623162316231623162316231	QA	1	CURRENT_TIMESTAMP
+
+*** Select on Slave ****
+SELECT c1,c2,c3,hex(c4),c5 FROM t14 ORDER BY c1;
+c1	c2	c3	hex(c4)	c5
+1	1.00	Replication Testing Extra Col	62316231623162316231623162316231	Kyle
+2	2.00	This Test Should work	62316231623162316231623162316231	JOE
+3	3.00	If is does not, I will open a bug	62316231623162316231623162316231	QA
+
+****************************************************
+* - Alter Master Dropping columns from the middle. *
+*   Expect: columns dropped                        *
+****************************************************
+
+*** connect to master and drop columns ***
+ALTER TABLE t14 DROP COLUMN c2;
+ALTER TABLE t14 DROP COLUMN c7;
+
+*** Select from Master ***
+SELECT c1,c3,hex(c4),c5,c6 FROM t14 ORDER BY c1;
+c1	c3	hex(c4)	c5	c6
+1	Replication Testing Extra Col	62316231623162316231623162316231	Kyle	1
+2	This Test Should work	62316231623162316231623162316231	JOE	1
+3	If is does not, I will open a bug	62316231623162316231623162316231	QA	1
+
+************
+* Bug30415 *
+************
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1091
+Last_Error	Error 'Can't DROP 'c7'; check that column/key exists' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7'
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1091
+Last_SQL_Error	Error 'Can't DROP 'c7'; check that column/key exists' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7'
+STOP SLAVE;
+RESET SLAVE;
+
+*** Drop t14  ***
+DROP TABLE t14;
+DROP TABLE t14;
+RESET MASTER;
+START SLAVE;
+
+*************************************************
+* - Alter Master adding columns at end of table *
+*   Expect: Error 1054                          *
+*************************************************
+
+*** Create t15 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t15 (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
+) ENGINE='Falcon';
+
+*** Create t15 on Master ***
+CREATE TABLE t15 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
+c6 INT DEFAULT '1',
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+RESET MASTER;
+
+*** Start Slave ***
+START SLAVE;
+
+*** Master Data Insert ***
+ALTER TABLE t15 ADD COLUMN c2 DECIMAL(8,2) AFTER c7;
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t15 () VALUES(1,@b1,'Kyle',DEFAULT,DEFAULT,3.00),
+(2,@b1,'JOE',DEFAULT,DEFAULT,3.00),
+(3,@b1,'QA',DEFAULT,DEFAULT,3.00);
+SELECT c1,hex(c4),c5,c6,c7,c2 FROM t15 ORDER BY c1;
+c1	hex(c4)	c5	c6	c7	c2
+1	62316231623162316231623162316231	Kyle	1	CURRENT_TIMESTAMP	3.00
+2	62316231623162316231623162316231	JOE	1	CURRENT_TIMESTAMP	3.00
+3	62316231623162316231623162316231	QA	1	CURRENT_TIMESTAMP	3.00
+
+********************************************
+*** Expect slave to fail with Error 1054 ***
+********************************************
+
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1054
+Last_Error	Error 'Unknown column 'c7' in 't15'' on query. Default database: 'test'. Query: 'ALTER TABLE t15 ADD COLUMN c2 DECIMAL(8,2) AFTER c7'
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1054
+Last_SQL_Error	Error 'Unknown column 'c7' in 't15'' on query. Default database: 'test'. Query: 'ALTER TABLE t15 ADD COLUMN c2 DECIMAL(8,2) AFTER c7'
+STOP SLAVE;
+RESET SLAVE;
+
+*** Drop t15  ***
+DROP TABLE t15;
+DROP TABLE t15;
+RESET MASTER;
+START SLAVE;
+
+************************************************
+* - Create index on Master column not on slave *
+*   Expect:Warning                             *
+************************************************
+
+*** Create t16 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t16 (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
+) ENGINE='Falcon';
+
+*** Create t16 on Master ***
+CREATE TABLE t16 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
+c6 INT DEFAULT '1',
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+RESET MASTER;
+
+*** Start Slave ***
+START SLAVE;
+
+*** Master Create Index and Data Insert ***
+CREATE INDEX part_of_c6 ON t16 (c6);
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t16 () VALUES(1,@b1,'Kyle',DEFAULT,DEFAULT),
+(2,@b1,'JOE',2,DEFAULT),
+(3,@b1,'QA',3,DEFAULT);
+SELECT c1,hex(c4),c5,c6,c7 FROM t16 ORDER BY c1;
+c1	hex(c4)	c5	c6	c7
+1	62316231623162316231623162316231	Kyle	1	CURRENT_TIMESTAMP
+2	62316231623162316231623162316231	JOE	2	CURRENT_TIMESTAMP
+3	62316231623162316231623162316231	QA	3	CURRENT_TIMESTAMP
+
+*****************
+*** BUG 30434 ***
+*****************
+
+SHOW SLAVE STATUS;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	#
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	No
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	1072
+Last_Error	Error 'Key column 'c6' doesn't exist in table' on query. Default database: 'test'. Query: 'CREATE INDEX part_of_c6 ON t16 (c6)'
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	#
+Last_IO_Error	#
+Last_SQL_Errno	1072
+Last_SQL_Error	Error 'Key column 'c6' doesn't exist in table' on query. Default database: 'test'. Query: 'CREATE INDEX part_of_c6 ON t16 (c6)'
+STOP SLAVE;
+RESET SLAVE;
+
+*** Drop t16  ***
+DROP TABLE t16;
+DROP TABLE t16;
+RESET MASTER;
+START SLAVE;
+
+*****************************************************
+* - Delete rows using column on Master not on slave *
+*   Expect: Rows Deleted                            *
+*****************************************************
+
+*** Create t17 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t17 (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
+) ENGINE='Falcon';
+
+*** Create t17 on Master ***
+CREATE TABLE t17 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
+c6 INT DEFAULT '1',
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+RESET MASTER;
+
+*** Start Slave ***
+START SLAVE;
+
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t17 () VALUES(1,@b1,'Kyle',DEFAULT,DEFAULT),
+(2,@b1,'JOE',2,DEFAULT),
+(3,@b1,'QA',3,DEFAULT);
+SELECT c1,hex(c4),c5,c6,c7 FROM t17 ORDER BY c1;
+c1	hex(c4)	c5	c6	c7
+1	62316231623162316231623162316231	Kyle	1	CURRENT_TIMESTAMP
+2	62316231623162316231623162316231	JOE	2	CURRENT_TIMESTAMP
+3	62316231623162316231623162316231	QA	3	CURRENT_TIMESTAMP
+
+** Select * from Slave **
+SELECT c1,hex(c4),c5 FROM t17 ORDER BY c1;
+c1	hex(c4)	c5
+1	62316231623162316231623162316231	Kyle
+2	62316231623162316231623162316231	JOE
+3	62316231623162316231623162316231	QA
+
+** Delete from master **
+DELETE FROM t17 WHERE c6 = 3;
+SELECT c1,hex(c4),c5,c6,c7 FROM t17 ORDER BY c1;
+c1	hex(c4)	c5	c6	c7
+1	62316231623162316231623162316231	Kyle	1	CURRENT_TIMESTAMP
+2	62316231623162316231623162316231	JOE	2	CURRENT_TIMESTAMP
+
+** Check slave **
+SELECT c1,hex(c4),c5 FROM t17 ORDER BY c1;
+c1	hex(c4)	c5
+1	62316231623162316231623162316231	Kyle
+2	62316231623162316231623162316231	JOE
+DROP TABLE t17;
+
+
+*****************************************************
+* - Update row using column on Master not on slave *
+*   Expect: Rows updated                           *
+*****************************************************
+
+** Bug30674 **
+
+*** Create t18 on slave  ***
+
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t18 (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
+) ENGINE='Falcon';
+
+*** Create t18 on Master ***
+CREATE TABLE t18 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
+c6 INT DEFAULT '1',
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+RESET MASTER;
+
+*** Start Slave ***
+START SLAVE;
+
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+set @b1 = concat(@b1,@b1);
+INSERT INTO t18 () VALUES(1,@b1,'Kyle',DEFAULT,DEFAULT),
+(2,@b1,'JOE',2,DEFAULT),
+(3,@b1,'QA',3,DEFAULT);
+SELECT c1,hex(c4),c5,c6,c7 FROM t18 ORDER BY c1;
+c1	hex(c4)	c5	c6	c7
+1	62316231623162316231623162316231	Kyle	1	CURRENT_TIMESTAMP
+2	62316231623162316231623162316231	JOE	2	CURRENT_TIMESTAMP
+3	62316231623162316231623162316231	QA	3	CURRENT_TIMESTAMP
+
+** Select * from Slave **
+SELECT c1,hex(c4),c5 FROM t18 ORDER BY c1;
+c1	hex(c4)	c5
+1	62316231623162316231623162316231	Kyle
+2	62316231623162316231623162316231	JOE
+3	62316231623162316231623162316231	QA
+
+** update from master **
+UPDATE t18 SET c5 = 'TEST' WHERE c6 = 3;
+SELECT c1,hex(c4),c5,c6,c7 FROM t18 ORDER BY c1;
+c1	hex(c4)	c5	c6	c7
+1	62316231623162316231623162316231	Kyle	1	CURRENT_TIMESTAMP
+2	62316231623162316231623162316231	JOE	2	CURRENT_TIMESTAMP
+3	62316231623162316231623162316231	TEST	3	CURRENT_TIMESTAMP
+
+** Check slave **
+SELECT c1,hex(c4),c5 FROM t18 ORDER BY c1;
+c1	hex(c4)	c5
+1	62316231623162316231623162316231	Kyle
+2	62316231623162316231623162316231	JOE
+3	62316231623162316231623162316231	TEST
+DROP TABLE t18;
+
+
+*****************************************************
+* - Insert UUID  column on Master not on slave *
+*   Expect: Rows inserted                      *
+*****************************************************
+
+*** Create t5 on slave  ***
+STOP SLAVE;
+RESET SLAVE;
+CREATE TABLE t5 (c1 INT PRIMARY KEY, c4 BLOB, c5 CHAR(5)
+) ENGINE='Falcon';
+
+*** Create t5 on Master ***
+CREATE TABLE t5 (c1 INT KEY, c4 BLOB, c5 CHAR(5),
+c6 LONG, 
+c7 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
+)ENGINE='Falcon';
+RESET MASTER;
+
+*** Start Slave ***
+START SLAVE;
+
+*** Master Data Insert ***
+set @b1 = 'b1b1b1b1';
+INSERT INTO t5 () VALUES(1,@b1,'Kyle',UUID(),DEFAULT),
+(2,@b1,'JOE',UUID(),DEFAULT),
+(3,@b1,'QA',UUID(),DEFAULT);
+SELECT c1,hex(c4),c5,c6,c7 FROM t5 ORDER BY c1;
+c1	hex(c4)	c5	c6	c7
+1	6231623162316231	Kyle	UUID	TIME
+2	6231623162316231	JOE	UUID	TIME
+3	6231623162316231	QA	UUID	TIME
+
+** Select * from Slave **
+SELECT c1,hex(c4),c5 FROM t5 ORDER BY c1;
+c1	hex(c4)	c5
+1	6231623162316231	Kyle
+2	6231623162316231	JOE
+3	6231623162316231	QA
+DROP TABLE t5;
+

=== added file 'mysql-test/suite/rpl/r/rpl_locktrans_falcon.result'
--- a/mysql-test/suite/rpl/r/rpl_locktrans_falcon.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_locktrans_falcon.result	2008-11-17 10:57:50 +0000
@@ -0,0 +1,439 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+DROP DATABASE  IF EXISTS mysqltest;
+DROP TABLE     IF EXISTS t1, t2, t3, t4, v1;
+DROP VIEW      IF EXISTS t1, t2, t3, t4, v1;
+DROP PROCEDURE IF EXISTS lock_t1_excl;
+DROP PROCEDURE IF EXISTS count_t2;
+DROP PROCEDURE IF EXISTS update_t2;
+DROP TRIGGER   IF EXISTS t1_ai;
+#
+# WL3561 - transactional LOCK TABLE - Syntax tests
+# ================================================
+CREATE TABLE t1 (c1 INT ) ENGINE=Falcon;
+CREATE TABLE t2 (c2 INT ) ENGINE=Falcon;
+CREATE TABLE t3 (c3 INT ) ENGINE=Falcon;
+#
+# Valid syntax for non-transactional locks.
+LOCK TABLE t1 READ, t2 WRITE;
+UNLOCK TABLES;
+LOCK TABLE t1 READ LOCAL, t2 LOW_PRIORITY WRITE;
+UNLOCK TABLES;
+#
+# Valid syntax for transactional locks.
+LOCK TABLE t1 IN SHARE MODE, t2 IN EXCLUSIVE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 't1'
+Warning	1621	Converted to non-transactional lock on 't2'
+UNLOCK TABLES;
+#
+# Valid syntax for aliases with and without 'AS'.
+LOCK TABLE t1 AS a1 READ, t2 a2 WRITE;
+UNLOCK TABLES;
+LOCK TABLE t1 AS a1 IN SHARE MODE, t2 a2 IN EXCLUSIVE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 'a1'
+Warning	1621	Converted to non-transactional lock on 'a2'
+UNLOCK TABLES;
+#
+# Transactional locks taken on a view.
+CREATE VIEW v1 AS SELECT * FROM t1, t2 WHERE t1.c1 = t2.c2;
+LOCK TABLE v1 IN SHARE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 't1'
+Warning	1621	Converted to non-transactional lock on 't2'
+LOCK TABLE v1 IN EXCLUSIVE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 'v1'
+UNLOCK TABLES;
+DROP VIEW v1;
+#
+# Locking INFORMATION_SCHEMA fails on missing privileges.
+LOCK TABLE information_schema.tables IN SHARE MODE;
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
+LOCK TABLE information_schema.tables IN EXCLUSIVE MODE;
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
+LOCK TABLE information_schema.tables READ;
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
+LOCK TABLE information_schema.tables WRITE;
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
+#
+# The new keywords EXCLUSIVE and NOWAIT are not reserved words.
+CREATE TABLE t4 (exclusive INT, nowait INT) ENGINE=Falcon;
+LOCK TABLE t4 WRITE;
+DROP TABLE t4;
+#
+# Syntax errors for misspelled modes or left out symbols.
+##-------------------------------------------------------
+LOCK TABLE t1 IN SHARED MODE;
+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 'SHARED MODE' at line 1
+LOCK TABLE t1 SHARE MODE;
+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 'MODE' at line 1
+LOCK TABLE t1 IN SHARE;
+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
+LOCK TABLE t1 IN MODE;
+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 'MODE' at line 1
+LOCK TABLE t1 READ NOWAIT, t2 WRITE NOWAIT;
+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 'NOWAIT, t2 WRITE NOWAIT' at line 1
+LOCK TABLE t1 READ NOWAIT, t2 IN EXCLUSIVE MODE NOWAIT;
+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 'NOWAIT, t2 IN EXCLUSIVE MODE NOWAIT' at line 1
+LOCK TABLE t1 IN SHARE MODE NOWAIT, t2 WRITE NOWAIT;
+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 'NOWAIT' at line 1
+LOCK TABLE t1 IN SHARED MODE NOWAIT;
+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 'SHARED MODE NOWAIT' at line 1
+LOCK TABLE t1 SHARE MODE NOWAIT;
+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 'MODE NOWAIT' at line 1
+LOCK TABLE t1 IN SHARE NOWAIT;
+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 'NOWAIT' at line 1
+LOCK TABLE t1 IN MODE NOWAIT;
+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 'MODE NOWAIT' at line 1
+##----------------------
+## End of syntax errors.
+#
+#
+# WL3561 - transactional LOCK TABLE - Lock method conversion
+# ==========================================================
+#
+# Implicit lock method conversion due to mix in statement.
+LOCK TABLE t1 READ, t2 IN EXCLUSIVE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 't2'
+UNLOCK TABLES;
+# Lock t1 share (converted to read), t2 write.
+LOCK TABLE t1 IN SHARE MODE, t2 WRITE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 't1'
+# Show t1 is read locked, t2 write locked.
+INSERT INTO t1 SELECT * FROM t2;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+INSERT INTO t2 SELECT * FROM t1;
+#
+# Implicit lock method conversion due to existing non-transact. locks.
+# Implicitly unlock existing non-transactional locks and take new ones.
+# Lock t1 exclusive (converted to write), t2 share (converted to read).
+LOCK TABLE t1 IN EXCLUSIVE MODE, t2 IN SHARE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 't1'
+Warning	1621	Converted to non-transactional lock on 't2'
+# Show t1 is write locked, t2 read locked.
+INSERT INTO t1 SELECT * FROM t2;
+INSERT INTO t2 SELECT * FROM t1;
+ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
+UNLOCK TABLES;
+#
+# Reject lock method conversion in strict mode.
+# Set strict mode.
+SET @wl3561_save_sql_mode= @@SQL_MODE;
+SET @@SQL_MODE= 'STRICT_ALL_TABLES';
+# Try mixed mode locks.
+LOCK TABLE t1 READ, t2 IN EXCLUSIVE MODE;
+ERROR HY000: Cannot convert to non-transactional lock in strict mode on 't2'
+LOCK TABLE t1 IN SHARE MODE, t2 WRITE;
+ERROR HY000: Cannot convert to non-transactional lock in strict mode on 't1'
+# Lock non-transactional.
+LOCK TABLE t1 READ, t2 WRITE;
+# Try transactional locks on top of the existing non-transactional locks.
+LOCK TABLE t1 IN SHARE MODE, t2 IN EXCLUSIVE MODE;
+ERROR HY000: Cannot convert to non-transactional lock in strict mode on 't1'
+## Error is reported on first table only. Show both errors:
+SHOW WARNINGS;
+Level	Code	Message
+Error	1622	Cannot convert to non-transactional lock in strict mode on 't1'
+Error	1622	Cannot convert to non-transactional lock in strict mode on 't2'
+UNLOCK TABLES;
+SET @@SQL_MODE= @wl3561_save_sql_mode;
+#
+# Reject lock method conversion in an active transaction.
+# Start transaction.
+START TRANSACTION;
+# Try mixed mode locks.
+LOCK TABLE t1 READ, t2 IN EXCLUSIVE MODE;
+ERROR HY000: Cannot convert to non-transactional lock in an active transaction on 't2'
+LOCK TABLE t1 IN SHARE MODE, t2 WRITE;
+ERROR HY000: Cannot convert to non-transactional lock in an active transaction on 't1'
+COMMIT;
+#
+# Implicit lock method conversion for non-transactional storage engine.
+# Create a non-transactional table.
+CREATE TABLE t4 (c4 INT) ENGINE= MyISAM;
+# Request a transactional lock, which is converted to non-transactional.
+LOCK TABLE t4 IN SHARE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 't4'
+# Try a conflict with the existing non-transactional lock.
+INSERT INTO t4 VALUES(444);
+ERROR HY000: Table 't4' was locked with a READ lock and can't be updated
+UNLOCK TABLES;
+# Set strict mode.
+SET @@SQL_MODE= 'STRICT_ALL_TABLES';
+# Try a transactional lock, which would need a conversion.
+LOCK TABLE t4 IN SHARE MODE;
+ERROR HY000: Cannot convert to non-transactional lock in strict mode on 't4'
+SET @@SQL_MODE= @wl3561_save_sql_mode;
+#
+# View with transactional and non-transactional storage engine.
+CREATE VIEW v1 AS SELECT * FROM t3, t4 WHERE t3.c3 = t4.c4;
+# Request a share lock on the view, which is converted to read locks.
+LOCK TABLE v1 IN SHARE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 't3'
+Warning	1621	Converted to non-transactional lock on 't4'
+# Show that read locks on the base tables prohibit writing ...
+INSERT INTO t3 SELECT * FROM t4;
+ERROR HY000: Table 't3' was locked with a READ lock and can't be updated
+INSERT INTO t4 SELECT * FROM t3;
+ERROR HY000: Table 't4' was locked with a READ lock and can't be updated
+# ... but allow reading.
+SELECT COUNT(*) FROM t3, t4 WHERE t3.c3 = t4.c4;
+COUNT(*)
+0
+SELECT COUNT(*) FROM v1;
+COUNT(*)
+0
+## Report conversion on view due to existing non-transactional locks.
+LOCK TABLE v1 IN EXCLUSIVE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 'v1'
+INSERT INTO t3 VALUES(333);
+INSERT INTO t4 VALUES(444);
+INSERT INTO t1 VALUES(111);
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+UNLOCK TABLES;
+## Now report conversion on base table again.
+LOCK TABLE v1 IN EXCLUSIVE MODE;
+Warnings:
+Warning	1621	Converted to non-transactional lock on 't3'
+Warning	1621	Converted to non-transactional lock on 't4'
+INSERT INTO t3 VALUES(333);
+INSERT INTO t4 VALUES(444);
+INSERT INTO t1 VALUES(111);
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+UNLOCK TABLES;
+DROP VIEW v1;
+TRUNCATE t4;
+#
+# Insufficient privileges do not unlock tables nor end transactions.
+# Prepare database, tables and an user with insufficient privileges.
+# Make a new connection with this user.
+CREATE DATABASE mysqltest;
+CREATE TABLE mysqltest.t5 (c5 INT) ENGINE=Falcon;
+CREATE TABLE mysqltest.t6 (c6 INT) ENGINE=Falcon;
+CREATE USER mysqltest_1@localhost;
+GRANT SELECT, INSERT ON mysqltest.* TO mysqltest_1@localhost;
+# connection conn1.
+# Show sufficient privileges to lock tables in the test database.
+LOCK TABLE t1 READ, t2 WRITE;
+# Show insufficient privileges in the mysqltest database.
+LOCK TABLE mysqltest.t5 READ, mysqltest.t6 WRITE;
+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
+# Show that the locks in 'test' still exist.
+INSERT INTO t1 SELECT * FROM t2;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+INSERT INTO t2 SELECT * FROM t1;
+# Unlock tables.
+UNLOCK TABLES;
+# Start transaction.
+START TRANSACTION;
+# Insert a value.
+INSERT INTO t1 VALUES(111);
+# Try a lock that fails on privileges.
+LOCK TABLE mysqltest.t5 READ;
+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
+# Rollback transaction.
+ROLLBACK;
+# Show that the inserted value has gone.
+SELECT * FROM t1;
+c1
+# Drop the connection with the unprivileged user.
+# connection default.
+#
+# Sufficient privileges do unlock tables and end transactions.
+# Grant sufficient privileges to the user.
+# Make a new connection with this user.
+GRANT SELECT, INSERT, LOCK TABLES ON mysqltest.* TO mysqltest_1@localhost;
+# connection conn1.
+# Lock tables in the test database.
+LOCK TABLE t1 READ, t2 WRITE;
+# Lock tables in the mysqltest database.
+LOCK TABLE mysqltest.t5 READ, mysqltest.t6 WRITE;
+# Show that the locks in 'test' have been replaced ...
+INSERT INTO t1 SELECT * FROM t2;
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+INSERT INTO t2 SELECT * FROM t1;
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+# ... by the locks in 'mysqltest'.
+INSERT INTO mysqltest.t5 SELECT * FROM mysqltest.t6;
+ERROR HY000: Table 't5' was locked with a READ lock and can't be updated
+INSERT INTO mysqltest.t6 SELECT * FROM mysqltest.t5;
+# Unlock tables.
+UNLOCK TABLES;
+# Start transaction.
+START TRANSACTION;
+# Insert a value.
+INSERT INTO t1 VALUES(111);
+# Take a new lock.
+LOCK TABLE mysqltest.t5 READ;
+# Rollback transaction.
+ROLLBACK;
+UNLOCK TABLES;
+# Show that the inserted value had been committed.
+SELECT * FROM t1;
+c1
+111
+TRUNCATE t1;
+# connection default.
+UNLOCK TABLES;
+DROP USER mysqltest_1@localhost;
+DROP DATABASE mysqltest;
+DROP TABLE t1, t2, t3, t4;
+#
+# WL3594 - transactional LOCK TABLE Testing - Functional tests
+# ============================================================
+# Prepare tables and connections.
+# Set AUTOCOMMIT= 0 in each connection.
+SET AUTOCOMMIT= 0;
+CREATE TABLE t1 (c1 INT) ENGINE=Falcon;
+CREATE TABLE t2 (c2 INT) ENGINE=Falcon;
+# connection conn1.
+SET AUTOCOMMIT= 0;
+# connection conn2.
+SET AUTOCOMMIT= 0;
+# connection default.
+#
+# Normal WRITE locks go before readers (autocommit).
+# Set AUTOCOMMIT= 1.
+SET AUTOCOMMIT= 1;
+# Insert a value.
+INSERT INTO t1 VALUES(111);
+# Take a non-transactional lock.
+LOCK TABLE t1 READ;
+# connection conn1.
+# Set AUTOCOMMIT= 1.
+SET AUTOCOMMIT= 1;
+# Take a non-transactional WRITE lock,
+# which waits in background until first read lock is released.
+LOCK TABLE t1 WRITE;
+# connection default.
+# Wait for the helper thread to sit on its lock.
+# connection conn2.
+# Set AUTOCOMMIT= 1.
+SET AUTOCOMMIT= 1;
+# Take a non-transactional READ lock,
+# which waits in background until the WRITE lock is released.
+LOCK TABLE t1 READ;
+# connection default.
+# Wait for the helper threads to sit on their locks.
+# Unlock this connections non-transactional lock.
+UNLOCK TABLES;
+# connection conn1.
+# Now the WRITE lock is taken.
+# Insert a value.
+INSERT INTO t1 VALUES(1111);
+# Unlock table.
+UNLOCK TABLES;
+# connection conn2.
+# Now the READ lock is taken.
+# Select from the table.
+SELECT * FROM t1;
+c1
+111
+1111
+# Unlock table.
+UNLOCK TABLES;
+# connection default.
+TRUNCATE t1;
+#
+# LOW_PRIORITY WRITE locks wait for readers (autocommit).
+# Insert a value.
+INSERT INTO t1 VALUES(111);
+# Take a non-transactional lock.
+LOCK TABLE t1 READ;
+# connection conn1.
+# Take a non-transactional LOW_PRIORITY WRITE lock,
+# which waits in background until all read locks are released.
+LOCK TABLE t1 LOW_PRIORITY WRITE;
+# connection default.
+# Wait for the helper thread to sit on its lock.
+# connection conn2.
+# Take a non-transactional READ lock,
+# which goes before the LOW_PRIORITY WRITE lock.
+LOCK TABLE t1 READ;
+# The READ lock could be taken immediately.
+# Select from the table.
+SELECT * FROM t1;
+c1
+111
+# Unlock table.
+UNLOCK TABLES;
+SET AUTOCOMMIT= 0;
+# connection default.
+# Unlock this connections non-transactional lock.
+UNLOCK TABLES;
+# connection conn1.
+# Now the LOW_PRIORITY WRITE lock is taken.
+# Insert a value.
+INSERT INTO t1 VALUES(1111);
+# Unlock table.
+UNLOCK TABLES;
+SET AUTOCOMMIT= 0;
+# connection default.
+TRUNCATE t1;
+SET AUTOCOMMIT= 0;
+COMMIT;
+#
+# LOCK TABLE is prohibited in stored procedure.
+CREATE PROCEDURE lock_t1_excl()
+LOCK TABLE t1 IN EXCLUSIVE MODE;
+ERROR 0A000: LOCK is not allowed in stored procedures
+#
+# LOCK TABLE is prohibited in trigger.
+CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
+LOCK TABLE t2 IN EXCLUSIVE MODE;
+ERROR 0A000: LOCK is not allowed in stored procedures
+## Cleanup.
+SET AUTOCOMMIT= 1;
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+show slave status;;
+Slave_IO_State	#
+Master_Host	127.0.0.1
+Master_User	root
+Master_Port	MASTER_PORT
+Connect_Retry	1
+Master_Log_File	master-bin.000001
+Read_Master_Log_Pos	#
+Relay_Log_File	#
+Relay_Log_Pos	#
+Relay_Master_Log_File	master-bin.000001
+Slave_IO_Running	Yes
+Slave_SQL_Running	Yes
+Replicate_Do_DB	
+Replicate_Ignore_DB	
+Replicate_Do_Table	
+Replicate_Ignore_Table	
+Replicate_Wild_Do_Table	
+Replicate_Wild_Ignore_Table	
+Last_Errno	0
+Last_Error	
+Skip_Counter	0
+Exec_Master_Log_Pos	#
+Relay_Log_Space	#
+Until_Condition	None
+Until_Log_File	
+Until_Log_Pos	0
+Master_SSL_Allowed	No
+Master_SSL_CA_File	
+Master_SSL_CA_Path	
+Master_SSL_Cert	
+Master_SSL_Cipher	
+Master_SSL_Key	
+Seconds_Behind_Master	#
+Master_SSL_Verify_Server_Cert	No
+Last_IO_Errno	0
+Last_IO_Error	
+Last_SQL_Errno	0
+Last_SQL_Error	

=== added file 'mysql-test/suite/rpl/r/rpl_relay_space_falcon.result'
--- a/mysql-test/suite/rpl/r/rpl_relay_space_falcon.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_relay_space_falcon.result	2008-11-17 10:57:50 +0000
@@ -0,0 +1,25 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+SHOW VARIABLES LIKE 'relay_log_space_limit';
+Variable_name	Value
+relay_log_space_limit	0
+CREATE TABLE t1 (name varchar(64), age smallint(3))ENGINE=Falcon;
+INSERT INTO t1 SET name='Andy', age=31;
+INSERT INTO t1 SET name='Jacob', age=2;
+INSERT INTO t1 SET name='Caleb', age=1;
+ALTER TABLE t1 ADD id int(8) ZEROFILL AUTO_INCREMENT PRIMARY KEY;
+SELECT * FROM t1 ORDER BY id;
+name	age	id
+Andy	31	00000001
+Jacob	2	00000002
+Caleb	1	00000003
+SELECT * FROM t1 ORDER BY id;
+name	age	id
+Andy	31	00000001
+Jacob	2	00000002
+Caleb	1	00000003
+DROP TABLE t1;

=== added file 'mysql-test/suite/rpl/r/rpl_row_blob_falcon.result'
--- a/mysql-test/suite/rpl/r/rpl_row_blob_falcon.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_blob_falcon.result	2008-11-17 10:57:50 +0000
@@ -0,0 +1,156 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+*****  Table Create Section ****
+
+CREATE TABLE test.t1 (c1 int not null auto_increment, 
+data LONGBLOB, PRIMARY KEY(c1))ENGINE=#;
+
+**** Data Insert Section test.t1 *****
+
+INSERT INTO test.t1 VALUES (NULL, NULL);
+INSERT INTO test.t1 VALUES (NULL, repeat('a',1*1024));
+INSERT INTO test.t1 VALUES (NULL, repeat('b',16*1024));
+
+**** Data Insert Validation Master Section test.t1 ****
+
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 1;
+LENGTH(data)
+NULL
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 2;
+LENGTH(data)
+1024
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 3;
+LENGTH(data)
+16384
+
+**** Data Insert Validation Slave Section test.t1 ****
+
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 1;
+LENGTH(data)
+NULL
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 2;
+LENGTH(data)
+1024
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 3;
+LENGTH(data)
+16384
+
+**** Data Update Section test.t1 ****
+
+UPDATE test.t1 set data=repeat('a',18*1024) where c1 = 1;
+UPDATE t1 set data=repeat('c',17*1024) where c1 = 2;
+
+**** Data Update Validation Master Section test.t1 ****
+
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 1;
+LENGTH(data)
+18432
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 2;
+LENGTH(data)
+17408
+
+**** Data Update Validation Slave Section test.t1 ****
+
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 1;
+LENGTH(data)
+18432
+SELECT LENGTH(data) FROM test.t1 WHERE c1 = 2;
+LENGTH(data)
+17408
+
+**** End Test Section test.t1 ****
+
+**** Create Table test.t2 ****
+
+CREATE TABLE test.t2 (
+c1 INT NOT NULL PRIMARY KEY,
+c2 TEXT,
+c3 INT,
+c4 LONGBLOB,
+KEY(c3))ENGINE=#;
+
+*** Setup Values For test.t2 ***
+set @x0 = '01234567012345670123456701234567';
+set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0);
+set @b1 = 'b1';
+set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
+set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
+set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
+set @b1 = concat(@b1,@x0);
+set @d1 = 'dd1';
+set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
+set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
+set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
+set @b2 = 'b2';
+set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
+set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
+set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
+set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
+set @d2 = 'dd2';
+set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
+set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
+set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
+set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2);
+
+**** Data Insert Section test.t2 *****
+
+INSERT INTO test.t2 VALUES(1,@b1,111,@d1);
+INSERT INTO test.t2 VALUES(2,@b2,222,@d2);
+
+**** Data Insert Validation Master Section test.t2 ****
+
+SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
+FROM test.t2 WHERE c1=1;
+c1	LENGTH(c2)	SUBSTR(c2,1+2*900,2)	LENGTH(c4)	SUBSTR(c4,1+3*900,3)
+1	2256	b1	3000	dd1
+SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
+FROM test.t2 WHERE c1=2;
+c1	LENGTH(c2)	SUBSTR(c2,1+2*900,2)	LENGTH(c4)	SUBSTR(c4,1+3*900,3)
+2	20000	b2	30000	dd2
+
+**** Data Insert Validation Slave Section test.t2 ****
+
+SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
+FROM test.t2 WHERE c1=1;
+c1	LENGTH(c2)	SUBSTR(c2,1+2*900,2)	LENGTH(c4)	SUBSTR(c4,1+3*900,3)
+1	2256	b1	3000	dd1
+SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
+FROM test.t2 WHERE c1=2;
+c1	LENGTH(c2)	SUBSTR(c2,1+2*900,2)	LENGTH(c4)	SUBSTR(c4,1+3*900,3)
+2	20000	b2	30000	dd2
+
+**** Data Update Section test.t2 ****
+
+UPDATE test.t2 SET c2=@b2, c4=@d2 WHERE c1=1;
+UPDATE test.t2 SET c2=@b1, c4=@d1 WHERE c1=2;
+
+**** Data Update Validation Master Section test.t2 ****
+
+SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
+FROM test.t2 WHERE c1=1;
+c1	LENGTH(c2)	SUBSTR(c2,1+2*900,2)	LENGTH(c4)	SUBSTR(c4,1+3*900,3)
+1	20000	b2	30000	dd2
+SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
+FROM test.t2 WHERE c1=2;
+c1	LENGTH(c2)	SUBSTR(c2,1+2*900,2)	LENGTH(c4)	SUBSTR(c4,1+3*900,3)
+2	2256	b1	3000	dd1
+
+**** Data Update Validation Slave Section test.t2 ****
+
+SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
+FROM test.t2 WHERE c1=1;
+c1	LENGTH(c2)	SUBSTR(c2,1+2*900,2)	LENGTH(c4)	SUBSTR(c4,1+3*900,3)
+1	20000	b2	30000	dd2
+SELECT c1, LENGTH(c2), SUBSTR(c2,1+2*900,2), LENGTH(c4), SUBSTR(c4,1+3*900,3)
+FROM test.t2 WHERE c1=2;
+c1	LENGTH(c2)	SUBSTR(c2,1+2*900,2)	LENGTH(c4)	SUBSTR(c4,1+3*900,3)
+2	2256	b1	3000	dd1
+
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;

=== added file 'mysql-test/suite/rpl/r/rpl_truncate_falcon.result'
--- a/mysql-test/suite/rpl/r/rpl_truncate_falcon.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_truncate_falcon.result	2008-11-17 10:57:50 +0000
@@ -0,0 +1,94 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+STOP SLAVE;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1;
+RESET SLAVE;
+START SLAVE;
+**** On Master ****
+SET SESSION BINLOG_FORMAT=ROW;
+SET GLOBAL  BINLOG_FORMAT=ROW;
+CREATE TABLE t1 (a INT, b LONG) ENGINE=Falcon;
+INSERT INTO t1 VALUES (1,1), (2,2);
+SELECT * FROM t1;
+a	b
+1	1
+2	2
+**** On Slave ****
+INSERT INTO t1 VALUE (3,3);
+SELECT * FROM t1;
+a	b
+1	1
+2	2
+3	3
+**** On Master ****
+TRUNCATE TABLE t1;
+SELECT * FROM t1;
+a	b
+**** On Slave ****
+SELECT * FROM t1;
+a	b
+**** On Master ****
+DROP TABLE t1;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS t1
+master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=Falcon
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Query	#	#	use `test`; TRUNCATE TABLE t1
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE t1
+RESET MASTER;
+STOP SLAVE;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1;
+RESET SLAVE;
+START SLAVE;
+**** On Master ****
+SET SESSION BINLOG_FORMAT=ROW;
+SET GLOBAL  BINLOG_FORMAT=ROW;
+CREATE TABLE t1 (a INT, b LONG) ENGINE=Falcon;
+INSERT INTO t1 VALUES (1,1), (2,2);
+SELECT * FROM t1;
+a	b
+1	1
+2	2
+**** On Slave ****
+INSERT INTO t1 VALUE (3,3);
+SELECT * FROM t1;
+a	b
+1	1
+2	2
+3	3
+**** On Master ****
+DELETE FROM t1;
+SELECT * FROM t1;
+a	b
+**** On Slave ****
+SELECT * FROM t1;
+a	b
+3	3
+**** On Master ****
+DROP TABLE t1;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS t1
+master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=Falcon
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; DROP TABLE t1
+RESET MASTER;

=== added file 'mysql-test/suite/rpl/t/rpl_backup.test'
--- a/mysql-test/suite/rpl/t/rpl_backup.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_backup.test	2008-10-31 15:31:52 +0000
@@ -0,0 +1,399 @@
+#
+# Test backup and replication integration.
+#
+
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/have_debug_sync.inc
+--source include/have_debug.inc
+
+connection master;
+
+--echo Create some data...
+CREATE DATABASE rpl_backup;
+CREATE TABLE rpl_backup.t1 (a int);
+INSERT INTO rpl_backup.t1 VALUES (1), (2), (3), (4), (5);
+
+#
+# Use Case 1 - Backup performed on a master.
+#   When a backup is performed on a master, the master shall not log 
+#   the backup event nor shall the master replicate any data produced
+#   (logged) by the backup. 
+
+--echo Remove all entries in the backup logs.
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+
+sync_slave_with_master;
+connection slave;
+
+--echo Remove all entries in the backup logs.
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+
+--echo Get master's binlog position from the slave before backup.
+let $slave_before_pos = 
+  query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
+
+connection master;
+
+--echo Get master's binlog position before backup.
+let $master_before_pos = query_get_value("SHOW MASTER STATUS", Position, 1);
+
+#
+# Now test read of backupid with known id using debug insertion
+#
+SET SESSION debug="+d,set_backup_id";
+
+# We are using debug insertion to set the first backup_id to
+# 500 so we can expect the output of this operation to be 500.
+--echo Backup_id = 500.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_m1.bak';
+
+SET SESSION debug="-d";
+
+--echo Show any events issued as a result of backup.
+--echo Note: There should be none!
+--disable_query_log
+eval SHOW BINLOG EVENTS FROM $master_before_pos;
+--enable_query_log
+
+--echo Verify backup run on master does not advance binlog pos.
+--echo Get master's binlog position after backup.
+let $master_after_pos = query_get_value("SHOW MASTER STATUS", Position, 1);
+
+--disable_query_log
+--echo Compare the before position of the master's binlog to
+--echo the after position of the master's binlog. The result
+--echo should be 0.
+eval SELECT $master_after_pos - $master_before_pos AS Delta;
+--enable_query_log
+
+#
+# Now check slave to see if backup logs are affected.
+# Check slave's master position.
+# Ensure replication is still working.
+#
+sync_slave_with_master;
+connection slave;
+
+#
+# This tests is added to ensure none of the entries in the master's
+# backup logs are replicated to the slave.
+#
+--echo Should have count(*) = 0.
+SELECT count(*) FROM mysql.backup_history;
+
+--echo Verify backup run on master does not advance binlog pos.
+--echo Get master's binlog position on the slave after backup.
+let $slave_after_pos = 
+  query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
+
+--disable_query_log
+--echo Compare the before position of the master's binlog to
+--echo the after position of the slave's binlog as shown on
+--echo on the slave. The result should be 0.
+eval SELECT $slave_after_pos - $slave_before_pos AS Delta;
+--enable_query_log
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 6 # 7 # 8 # 9 # 22 # 23 # 33 #
+--query_vertical SHOW SLAVE STATUS
+
+connection master;
+
+--echo Ensure replication is still working...
+--echo Cleanup from last error on master and slave.
+
+DELETE FROM rpl_backup.t1;
+
+INSERT INTO rpl_backup.t1 VALUES (11), (22), (33);
+
+SELECT count(*) FROM rpl_backup.t1;
+
+sync_slave_with_master;
+connection slave;
+
+SELECT count(*) FROM rpl_backup.t1;
+
+--echo Cleanup backup logs.
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+
+#
+#  Use Case 3 - Backup performed on a slave (part 1 of 2)
+#    Test backup on slave where slave has no slaves.
+#    Also, verify master's binlog information is saved to
+#      the progress log.
+#
+
+connection master;
+
+--echo First, get master's binlog position and filename.
+let $master_pos = query_get_value("SHOW MASTER STATUS", Position, 1);
+let $master_file = query_get_value("SHOW MASTER STATUS", File, 1);
+
+connection slave;
+
+#
+# Now test read of backupid with known id using debug insertion
+#
+
+SET SESSION debug="+d,set_backup_id";
+
+# We are using debug insertion to set the first backup_id to
+# 600 so we can expect the output of this operation to be 600.
+--echo Backup_id = 600.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_s1.bak';
+
+SET SESSION debug="-d";
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 6 # 7 # 8 # 9 # 22 # 23 # 33 #
+--query_vertical SHOW SLAVE STATUS
+
+#
+# Build search string for known master binlog information.
+#
+let $preamble = 'Recording master binlog information. binlog file = ''';
+let $middle = ''', position = ';
+let $end = '.';
+
+--echo Check saving of master's binlog information.
+--echo Should have count(*) = 1.
+--disable_query_log
+eval SELECT count(*) FROM mysql.backup_progress 
+WHERE Backup_id = 600 AND 
+notes = concat($preamble, "$master_file", $middle, $master_pos, $end);
+--enable_query_log
+
+--echo Should have count(*) = 1.
+SELECT count(*) FROM mysql.backup_history;
+
+connection master;
+
+#
+# Run backups for later use.
+#
+
+INSERT INTO rpl_backup.t1 VALUES (10), (20), (30);
+
+--echo Backup_id = 501.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_m2.bak';
+
+SELECT count(*) FROM rpl_backup.t1;
+
+sync_slave_with_master;
+connection slave;
+
+SELECT count(*) FROM rpl_backup.t1;
+
+--echo Make a backup for later use.
+--echo Backup_id = 601.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_s2.bak';
+
+#
+#  Use Case 2 - Restore performed on a master.
+#
+
+connection master;
+
+#
+# Insert some data to check slave with later.
+#
+
+CREATE TABLE rpl_backup.t2 (b int);
+INSERT INTO rpl_backup.t2 VALUES (888), (999);
+
+--echo Get master's binlog position before restore.
+let $master_before_pos = query_get_value("SHOW MASTER STATUS", Position, 1);
+
+--echo Backup_id = 502.
+RESTORE FROM 'rpl_bup_m2.bak';
+
+--echo Show the incident event issued as a result of restore.
+--replace_column 2 # 5 #
+--disable_query_log
+eval SHOW BINLOG EVENTS FROM $master_before_pos;
+--enable_query_log
+
+--echo Showing tables on master.
+SHOW FULL TABLES FROM rpl_backup;
+
+SELECT count(*) FROM rpl_backup.t1;
+
+#
+# Wait for slave to stop as result of incident event.
+#
+source include/wait_for_slave_sql_to_stop.inc;
+
+connection slave;
+
+--echo Check slave got everything up to incident event.
+--echo Should be two rows: 888, 999.
+SELECT * FROM rpl_backup.t2 WHERE b > 800;
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 6 # 7 # 8 # 9 # 22 # 23 # 33 #
+--query_vertical SHOW SLAVE STATUS
+
+--echo Show the slave stopped with an error.
+LET $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+disable_query_log;
+eval SELECT "$last_error" AS Last_SQL_Error;
+enable_query_log;
+
+SET global sql_slave_skip_counter=1;
+
+STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
+
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+
+# Sync with master to ensure nothing is replicated after incident event.
+sync_with_master;
+
+--echo Showing tables on slave.
+SHOW FULL TABLES FROM rpl_backup;
+
+#
+# Cleanup replication for next test case.
+#
+
+# Now stop the slave, do the restore, then restart.
+STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
+
+--echo Backup_id = 602.
+RESTORE FROM '../master-data/rpl_bup_m2.bak';
+
+--echo Showing databases on slave.
+SHOW DATABASES LIKE 'rpl_backup%';
+
+SELECT count(*) FROM rpl_backup.t1;
+
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+
+--echo Make a backup for later use.
+--echo Backup_id = 603.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_s3.bak';
+
+#
+#  Use Case 4 - Restore performed on a slave.
+#
+
+connection slave;
+
+--echo Test restore on slave while replication turned on.
+
+--error ER_RESTORE_ON_SLAVE
+RESTORE FROM 'rpl_bup_s1.bak';
+
+--echo Stop slave and restart after restore.
+STOP SLAVE;
+
+--replace_column 1 #
+RESTORE FROM 'rpl_bup_s3.bak';
+
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+
+connection master;
+
+--echo Checking affect on replication.
+INSERT INTO rpl_backup.t1 VALUES (44), (55), (66);
+SELECT * FROM rpl_backup.t1 ORDER BY a;
+
+sync_slave_with_master;
+connection slave;
+SELECT * FROM rpl_backup.t1 ORDER BY a;
+
+#
+#  Use Case 3 - Backup performed on a slave (part 2 of 2)
+#    Test backup on slave with another slave attached.
+#
+#  Note: To be added as part of WL#4612
+
+#
+#  Use Case 5 - Backup run with no binary log.
+#
+#  Note: This is basically covered in Use Case 2 but the distinction is 
+#        we have explicitly turned off binary logging. 
+#
+
+--echo Stop replication and turn off binary log.
+connection slave;
+
+STOP SLAVE;
+--source include/wait_for_slave_to_stop.inc
+
+connection master;
+
+SET @orig_sql_log_bin= @@sql_log_bin;
+
+--echo Turn off binlog.
+SET @@sql_log_bin= 0;
+SHOW VARIABLES LIKE '%log_bin';
+
+--echo Backup_id = 503.
+BACKUP DATABASE rpl_backup TO 'rpl_bup_m3.bak';
+
+--echo Turn on binlog;
+SET @@sql_log_bin= @orig_sql_log_bin;
+SHOW VARIABLES LIKE '%log_bin';
+
+#
+#  Use Case 6 - Restore run with binary log turned on but no slaves attached.
+#  
+
+RESET MASTER;
+
+--echo Get master's binlog position before restore.
+let $master_before_pos = query_get_value("SHOW MASTER STATUS", Position, 1);
+
+--echo Backup_id = 504.
+RESTORE FROM 'rpl_bup_m3.bak';
+
+--echo Get master's binlog position after restore.
+let $master_after_pos = query_get_value("SHOW MASTER STATUS", Position, 1);
+
+--echo Show the incident event issued as a result of restore.
+--replace_column 2 # 5 #
+--disable_query_log
+eval SHOW BINLOG EVENTS FROM $master_before_pos;
+--enable_query_log
+
+--echo Compute the difference of the binlog positions.
+--echo Result should be 0.
+--disable_query_log
+--echo Compare the before position of the master's binlog to
+--echo the after position of the master's binlog. The result
+--echo should be 0.
+eval SELECT $master_after_pos - $master_before_pos AS Delta;
+--enable_query_log
+
+#
+# Cleanup
+#
+connection master;
+
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+DROP DATABASE rpl_backup;
+
+--remove_file $MYSQLTEST_VARDIR/master-data/rpl_bup_m1.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/rpl_bup_m2.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/rpl_bup_m3.bak
+
+connection slave;
+
+FLUSH BACKUP LOGS;
+PURGE BACKUP LOGS;
+DROP DATABASE rpl_backup;
+
+--remove_file $MYSQLTEST_VARDIR/slave-data/rpl_bup_s1.bak
+--remove_file $MYSQLTEST_VARDIR/slave-data/rpl_bup_s2.bak
+--remove_file $MYSQLTEST_VARDIR/slave-data/rpl_bup_s3.bak
+

=== added file 'mysql-test/suite/rpl/t/rpl_extraCol_falcon.test'
--- a/mysql-test/suite/rpl/t/rpl_extraCol_falcon.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_extraCol_falcon.test	2008-11-17 10:57:50 +0000
@@ -0,0 +1,20 @@
+###################################################################
+# Purpose: To test having extra columns on the slave, using Falcon.
+# WL#3259.
+#
+# This is a test wrapper for the Falcon storage engine, using
+# the "engine independent" test rpl_extraSlave_Col in
+# mysql-test/extra/rpl_tests/.
+###################################################################
+--source include/master-slave.inc
+--source include/have_falcon.inc
+
+# Falcon does not support statement-based replication.
+# In 'mixed' mode only 'row' is used with Falcon.
+--source include/have_binlog_format_mixed_or_row.inc
+
+let $engine_type = 'Falcon';
+
+--source extra/rpl_tests/rpl_extraSlave_Col.test
+
+

=== added file 'mysql-test/suite/rpl/t/rpl_extraColmaster_falcon.test'
--- a/mysql-test/suite/rpl/t/rpl_extraColmaster_falcon.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_extraColmaster_falcon.test	2008-11-17 10:57:50 +0000
@@ -0,0 +1,22 @@
+################################################################
+# Purpose: To test having extra columns on the master. WL#3915.
+#
+# This is a test wrapper for the Falcon storage engine, using
+# the "engine independent" test rpl_extraMaster_Col in 
+# mysql-test/extra/rpl_tests/.
+################################################################
+--source include/master-slave.inc
+--source include/have_falcon.inc
+
+# Falcon does not support statement-based replication.
+# In 'mixed' mode only 'row' is used with Falcon.
+#
+# Test outputs binlog format, so let's not jump through result 
+# file hoops in order to run with different binlog formats, which
+# would be the same for Falcon anyway. Hence, we require 'row' 
+# for this test.
+--source include/have_binlog_format_row.inc
+
+let $engine_type = 'Falcon';
+
+--source extra/rpl_tests/rpl_extraMaster_Col.test

=== added file 'mysql-test/suite/rpl/t/rpl_locktrans_falcon.test'
--- a/mysql-test/suite/rpl/t/rpl_locktrans_falcon.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_locktrans_falcon.test	2008-11-17 10:57:50 +0000
@@ -0,0 +1,41 @@
+#####################################################################
+# Transactional LOCK TABLE tests.
+# Calls include/locktrans.inc.
+# Based on rpl_locktrans_{innodb,myisam}.
+#####################################################################
+
+# Transactional lock tests require multiple sessions.
+--source include/not_embedded.inc
+
+# This is a replication test.
+--source include/master-slave.inc
+
+# This is a falcon test.
+--source include/have_falcon.inc
+let $engine_type= Falcon;
+
+# Falcon does not support statement-based replication.
+# In 'mixed' mode only 'row' is used with Falcon.
+--source include/have_binlog_format_mixed_or_row.inc
+
+# Storage engine supports transactional locking?
+# According to 6.0 docs, only InnoDB supports transactional locking.
+# Falcon does not support it, see http://lists.mysql.com/falcon/179
+let $transactional= 0;
+
+# Storage engine supports the NOWAIT option?
+# According to 6.0 docs, no storage engine supports this...
+let $nowait_support= 0;
+
+# Define a storage engine that does not support transactional locking.
+let $other_non_trans_engine_type= MyISAM;
+
+# The real test
+--source include/locktrans.inc
+
+# Some post-processing (verifying slave status)
+sync_slave_with_master;
+connection slave;
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
+--query_vertical show slave status;

=== added file 'mysql-test/suite/rpl/t/rpl_relay_space_falcon.test'
--- a/mysql-test/suite/rpl/t/rpl_relay_space_falcon.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_relay_space_falcon.test	2008-11-17 10:57:50 +0000
@@ -0,0 +1,19 @@
+########################################################################
+# Wrapper for rpl_sv_relay_space.test.
+# This test is a wrapper for the rpl_sv_relayspace test, which is able 
+# to test multiple storage engines, in this case Falcon.
+#
+# By wrapping we are saving some space and making the test more
+# maintainable by only having one test file and reusing the code.
+# One result file per wrapper is still needed, though.
+########################################################################
+
+-- source include/not_ndb_default.inc
+-- source include/have_falcon.inc
+
+# Falcon does not support statement-based replication.
+# In 'mixed' mode only 'row' is used with Falcon.
+--source include/have_binlog_format_mixed_or_row.inc
+
+let $engine_type=Falcon;
+-- source extra/rpl_tests/rpl_sv_relay_space.test

=== added file 'mysql-test/suite/rpl/t/rpl_row_blob_falcon.test'
--- a/mysql-test/suite/rpl/t/rpl_row_blob_falcon.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_blob_falcon.test	2008-11-17 10:57:50 +0000
@@ -0,0 +1,20 @@
+############################################################
+# Wrapper for rpl_row_blob.test
+#
+# - By johnemb 2008-11-12:
+#    Wrapped to allow reuse of test code for different 
+#    storage engines. Following pattern already used for
+#    myisam and innodb.
+############################################################
+--source include/not_ndb_default.inc
+--source include/have_falcon.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+# Set engine type. All CREATE TABLE statements must specify
+# engine, or default storage engine on slave must be 
+# specified in <test>-slave.opt file.
+
+let $engine_type=Falcon;
+--source extra/rpl_tests/rpl_row_blob.test
+

=== added file 'mysql-test/suite/rpl/t/rpl_truncate_falcon.test'
--- a/mysql-test/suite/rpl/t/rpl_truncate_falcon.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_truncate_falcon.test	2008-11-17 10:57:50 +0000
@@ -0,0 +1,33 @@
+#####################################################################
+# Wrapper for "engine independent" test rpl_truncate_helper.test, 
+# using the Falcon storage engine.
+#
+# This wrapper omits the "middle man" rpl_truncate.test, as that test
+# file explicitly runs rpl_truncate_helper with all 3 binlog
+# formats, and Falcon does not support 'stmt'.
+#####################################################################
+
+--source include/master-slave.inc
+--source include/have_falcon.inc
+--source include/not_ndb_default.inc
+
+# Falcon does not support statement-based replication.
+# In 'mixed' mode only 'row' is used with Falcon, so
+# we don't bother testing that here.
+--source include/have_binlog_format_row.inc
+
+let $engine=Falcon;
+
+# Truncating a table can be done in two ways. Make sure to test both:
+
+# Sourced test includes setting binlog format, so specify it here.
+# Since 'mixed' => 'row' with Falcon, we only test 'row'.
+# Also set truncate method (statement) before running test.
+
+let $format=ROW;
+let $stmt = TRUNCATE TABLE;
+--source extra/rpl_tests/rpl_truncate_helper.test
+
+let $format=ROW;
+let $stmt = DELETE FROM;
+--source extra/rpl_tests/rpl_truncate_helper.test

=== modified file 'sql/backup/backup_info.cc'
--- a/sql/backup/backup_info.cc	2008-10-27 13:06:21 +0000
+++ b/sql/backup/backup_info.cc	2008-11-05 09:41:15 +0000
@@ -543,6 +543,10 @@ int Backup_info::add_dbs(List< ::LEX_STR
   while ((s= it++))
   {
     backup::String db_name(*s);
+
+    // Ignore the database if it has already been inserted into the catalogue.    
+    if (has_db(db_name))
+      continue;
     
     if (is_internal_db_name(&db_name))
     {

=== modified file 'sql/backup/backup_kernel.h'
--- a/sql/backup/backup_kernel.h	2008-10-27 13:06:21 +0000
+++ b/sql/backup/backup_kernel.h	2008-10-30 17:53:24 +0000
@@ -134,6 +134,12 @@ class Backup_restore_ctx: public backup:
   */
   bool m_tables_locked; 
 
+  /**
+    Indicates we must turn binlog back on in the close method. This is
+    set to TRUE in the prepare_for_restore() method.
+  */
+  bool m_engage_binlog;
+
   int lock_tables_for_restore();
   void unlock_tables();
   

=== modified file 'sql/backup/be_snapshot.cc'
--- a/sql/backup/be_snapshot.cc	2008-08-08 19:58:37 +0000
+++ b/sql/backup/be_snapshot.cc	2008-10-30 12:29:54 +0000
@@ -126,7 +126,15 @@ result_t Backup::get_data(Buffer &buf)
     // open_and_lock_tables. Otherwise, open_and_lock_tables will try to open
     // previously opened views and crash.
     locking_thd->m_thd->lex->cleanup_after_one_table_open();
-    open_and_lock_tables(locking_thd->m_thd, locking_thd->tables_in_backup);
+    /*
+      The MYSQL_OPEN_SKIP_TEMPORARY flag is needed so that temporary tables are
+      not opened which would occulde the regular tables selected for backup 
+      (BUG#33574).
+     */ 
+    open_and_lock_tables_derived(locking_thd->m_thd, 
+                                 locking_thd->tables_in_backup,
+                                 FALSE, /* do not process derived tables */
+                                 MYSQL_OPEN_SKIP_TEMPORARY);
     tables_open= TRUE;
   }
   if (locking_thd->lock_state == LOCK_ACQUIRED)

=== modified file 'sql/backup/be_thread.cc'
--- a/sql/backup/be_thread.cc	2008-07-09 07:12:43 +0000
+++ b/sql/backup/be_thread.cc	2008-10-30 12:29:54 +0000
@@ -161,7 +161,16 @@ pthread_handler_t backup_thread_for_lock
     killing the thread. In this case, we need to close the tables 
     and exit.
   */
-  if (open_and_lock_tables(thd, locking_thd->tables_in_backup))
+
+  /*
+    The MYSQL_OPEN_SKIP_TEMPORARY flag is needed so that temporary tables are
+    not opened which would occulde the regular tables selected for backup 
+    (BUG#33574).
+  */ 
+  if (open_and_lock_tables_derived(thd, locking_thd->tables_in_backup,
+                                   FALSE, /* do not process derived tables */
+                                   MYSQL_OPEN_SKIP_TEMPORARY)
+     )
   {
     DBUG_PRINT("info",("Online backup locking thread dying"));
     THD_SET_PROC_INFO(thd, "lock error");

=== modified file 'sql/backup/data_backup.cc'
--- a/sql/backup/data_backup.cc	2008-10-14 12:08:56 +0000
+++ b/sql/backup/data_backup.cc	2008-10-30 20:02:15 +0000
@@ -552,6 +552,25 @@ int write_table_data(THD* thd, Backup_in
     DBUG_PRINT("backup_data",("-- PREPARE PHASE --"));
     DEBUG_SYNC(thd, "before_backup_data_prepare");
 
+    /*
+      Note: block_commits is performed here because of the global read
+      lock/table lock deadlock reported in bug#39602. It should be
+      moved back to right before sch.lock() once a refined commit
+      blocker has been implemented. WL#4610 tracks the work on a
+      refined commit blocker
+    */
+    /*
+      Block commits.
+
+      TODO: Step 2 of the commit blocker has been skipped for this release.
+      When it is included, developer needs to build a list of all of the
+      non-transactional tables and pass that to block_commits().
+    */
+    int error= 0;
+    error= block_commits(thd, NULL);
+    if (error)
+      goto error;
+
     if (sch.prepare())
       goto error;
 
@@ -574,16 +593,8 @@ int write_table_data(THD* thd, Backup_in
     DEBUG_SYNC(thd, "after_backup_validated");
     
     /*
-      Block commits.
-
-      TODO: Step 2 of the commit blocker has been skipped for this release.
-      When it is included, developer needs to build a list of all of the
-      non-transactional tables and pass that to block_commits().
+      Refined commit blocker should be set here; see WL#4610
     */
-    int error= 0;
-    error= block_commits(thd, NULL);
-    if (error)
-      goto error;
 
     DEBUG_SYNC(thd, "before_backup_data_lock");
     if (sch.lock())
@@ -600,6 +611,19 @@ int write_table_data(THD* thd, Backup_in
       }
 
     /*
+      If we are a connected slave, write master's binlog information to
+      the progress log for later use.
+    */
+    st_bstream_binlog_pos master_pos;
+    master_pos.pos= 0;
+    master_pos.file= 0;
+    if (obs::is_slave() && active_mi)
+    {
+      master_pos.pos= (ulong)active_mi->master_log_pos;
+      master_pos.file= active_mi->master_log_name;
+    }
+
+    /*
       Save VP creation time.
     */
     vp_time= my_time(0);
@@ -627,6 +651,13 @@ int write_table_data(THD* thd, Backup_in
       info.m_ctx.report_binlog_pos(info.binlog_pos);
     }
 
+    /*
+      If we are a slave and the master's binlog position has been recorded
+      write it to the log.
+    */
+    if (obs::is_slave() && master_pos.pos)
+      info.m_ctx.report_master_binlog_pos(master_pos);
+
     info.m_ctx.report_state(BUP_RUNNING);
     DEBUG_SYNC(thd, "after_backup_binlog");
 

=== modified file 'sql/backup/image_info.cc'
--- a/sql/backup/image_info.cc	2008-10-14 12:08:56 +0000
+++ b/sql/backup/image_info.cc	2008-11-05 09:41:15 +0000
@@ -206,7 +206,7 @@ int Image_info::add_snapshot(Snapshot_in
 /**
   Check if catalogue contains given database.
  */ 
-bool Image_info::has_db(const String &db_name)
+bool Image_info::has_db(const String &db_name) const
 {
   for (uint n=0; n < m_dbs.count() ; ++n)
     if (m_dbs[n] && m_dbs[n]->name() == db_name)

=== modified file 'sql/backup/image_info.h'
--- a/sql/backup/image_info.h	2008-10-15 15:38:28 +0000
+++ b/sql/backup/image_info.h	2008-11-05 09:41:15 +0000
@@ -83,7 +83,7 @@ public: // public interface
 
    // Examine contents of the catalogue.
 
-   bool has_db(const String&);
+   bool has_db(const String&) const;
 
    // Retrieve objects using their coordinates.
 

=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc	2008-11-06 18:39:27 +0000
+++ b/sql/backup/kernel.cc	2008-11-13 08:40:43 +0000
@@ -211,6 +211,13 @@ execute_backup_command(THD *thd, LEX *le
 
   case SQLCOM_RESTORE:
   {
+
+    /*
+      Restore cannot be run on a slave while connected to a master.
+    */
+    if (obs::is_slave())
+      DBUG_RETURN(send_error(context, ER_RESTORE_ON_SLAVE));
+
     Restore_info *info= context.prepare_for_restore(backupdir, lex->backup_dir, 
                                                     thd->query);
     
@@ -378,7 +385,8 @@ pthread_mutex_t Backup_restore_ctx::run_
 Backup_restore_ctx::Backup_restore_ctx(THD *thd)
  :Logger(thd), m_state(CREATED), m_thd_options(thd->options),
   m_error(0), m_remove_loc(FALSE), m_stream(NULL),
-  m_catalog(NULL), mem_alloc(NULL), m_tables_locked(FALSE)
+  m_catalog(NULL), mem_alloc(NULL), m_tables_locked(FALSE),
+  m_engage_binlog(FALSE)
 {
   /*
     Check for progress tables.
@@ -785,6 +793,25 @@ Backup_restore_ctx::prepare_for_restore(
 
   m_state= PREPARED_FOR_RESTORE;
 
+  /*
+    Do not allow slaves to connect during a restore.
+
+    If the binlog is turned on, write a RESTORE_EVENT as an
+    incident report into the binary log.
+
+    Turn off binlog during restore.
+  */
+  if (obs::is_binlog_engaged())
+  {
+    obs::disable_slave_connections(TRUE);
+
+    DEBUG_SYNC(m_thd, "after_disable_slave_connections");
+
+    obs::write_incident_event(m_thd, obs::RESTORE_EVENT);
+    m_engage_binlog= TRUE;
+    obs::engage_binlog(FALSE);
+  }
+
   return info;
 }
 
@@ -838,11 +865,18 @@ int Backup_restore_ctx::lock_tables_for_
   /*
     Open and lock the tables.
     
-    Note: simple_open_n_lock_tables() must be used here since we don't want
-    to do derived tables processing. Processing derived tables even leads 
-    to crashes as those reported in BUG#34758.
+    Note 1: It is important to not do derived tables processing here. Processing
+    derived tables even leads to crashes as those reported in BUG#34758.
+  
+    Note 2: Skiping tmp tables is also important because otherwise a tmp table
+    can occlude a regular table with the same name (BUG#33574).
   */ 
-  if (simple_open_n_lock_tables(m_thd,tables))
+  if (open_and_lock_tables_derived(m_thd, tables,
+                                   FALSE, /* do not process derived tables */
+                                   MYSQL_OPEN_SKIP_TEMPORARY 
+                                          /* do not open tmp tables */
+                                  )
+     )
   {
     fatal_error(ER_BACKUP_OPEN_TABLES,"RESTORE");
     return m_error;
@@ -923,6 +957,17 @@ int Backup_restore_ctx::close()
 
   using namespace backup;
 
+  /*
+    Allow slaves connect after restore is complete.
+  */
+  obs::disable_slave_connections(FALSE);
+
+  /*
+    Turn binlog back on iff it was turned off earlier.
+  */
+  if (m_engage_binlog)
+    obs::engage_binlog(TRUE);
+
   time_t when= my_time(0);
 
   // unlock tables if they are still locked
@@ -1253,6 +1298,8 @@ int Backup_restore_ctx::do_restore()
 
   report_stats_post(info);                      // Never errors
 
+  DEBUG_SYNC(m_thd, "before_restore_done");
+
   DBUG_RETURN(0);
 }
 

=== modified file 'sql/backup/logger.h'
--- a/sql/backup/logger.h	2008-11-06 18:39:27 +0000
+++ b/sql/backup/logger.h	2008-11-13 08:40:43 +0000
@@ -5,6 +5,7 @@
 #include <backup_stream.h>
 #include <backup/error.h>
 #include "si_logs.h"
+#include "rpl_mi.h"
 
 namespace backup {
 
@@ -56,6 +57,7 @@ class Logger
    void report_state(enum_backup_state);
    void report_vp_time(time_t, bool);
    void report_binlog_pos(const st_bstream_binlog_pos&);
+   void report_master_binlog_pos(const st_bstream_binlog_pos&);
    void report_driver(const char *driver);
    void report_backup_file(char * path);
    void report_stats_pre(const Image_info&);
@@ -271,6 +273,22 @@ void Logger::report_binlog_pos(const st_
 }
 
 /**
+  Report master's binlog information.
+
+  @todo Write this information to the backup image file.
+*/
+inline
+void Logger::report_master_binlog_pos(const st_bstream_binlog_pos &pos)
+{
+  if (active_mi)
+  {
+    backup_log->master_binlog_pos(pos.pos);
+    backup_log->master_binlog_file(pos.file);
+    backup_log->write_master_binlog_info();
+  }
+}
+
+/**
   Report driver.
 */
 inline 

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2008-11-06 18:39:27 +0000
+++ b/sql/log.cc	2008-11-13 08:40:43 +0000
@@ -29,6 +29,7 @@
 #include "rpl_filter.h"
 #include "rpl_rli.h"
 #include "sql_audit.h"
+#include "si_objects.h"
 
 #include <my_dir.h>
 #include <stdarg.h>
@@ -778,10 +779,18 @@ bool Log_to_csv_event_handler::
   bool need_close= FALSE;
   bool need_rnd_end= FALSE;
   Open_tables_state open_tables_backup;
+  ulonglong save_thd_options;
   bool save_time_zone_used;
   char *host= current_thd->security_ctx->host; // host name
   char *user= current_thd->security_ctx->user; // user name
 
+  /*
+    Turn the binlog off and don't replicate the
+    updates to the backup logs.
+  */
+  save_thd_options= thd->options;
+  thd->options&= ~OPTION_BIN_LOG;
+
   save_time_zone_used= thd->time_zone_used;
   bzero(& table_list, sizeof(TABLE_LIST));
   table_list.alias= table_list.table_name= BACKUP_HISTORY_LOG_NAME.str;
@@ -856,6 +865,11 @@ bool Log_to_csv_event_handler::
   if (history_data->start)
   {
     MYSQL_TIME time;
+    /*
+      Set time ahead a few hours to allow backup purge test to test
+      PURGE BACKUP LOGS BEFORE command.
+    */
+    DBUG_EXECUTE_IF("set_log_time", history_data->start= my_time(0) + 100000;);
     my_tz_OFFSET0->gmt_sec_to_TIME(&time, (my_time_t)history_data->start);
 
     table->field[ET_OBH_FIELD_START_TIME]->set_notnull();
@@ -951,6 +965,12 @@ err:
     close_performance_schema_table(thd, & open_tables_backup);
 
   thd->time_zone_used= save_time_zone_used;
+
+  /*
+    Turn binlog back on if disengaged.
+  */
+  thd->options= save_thd_options;
+
   return result;
 }
 
@@ -1096,6 +1116,322 @@ err:
   return result;
 }
 
+/**
+  Delete the current row from a log table.
+
+  This method is used to delete a row from a log that is being
+  accessed as a table. The row to be deleted is the current
+  row that the handler is pointing to via tbl->record[0].
+
+  Note: The handler must be positioned correctly and the
+        tbl->record[0] must be fetched by the appropriate
+        method (e.g., hdl->next()). 
+
+  @param[IN]  hdl   Table handler.
+  @param[IN]  tbl   Table class.
+
+  @returns Result of delete operation
+*/
+static bool delete_current_log_row(handler *hdl, TABLE *tbl)
+{
+  bool result= 0;
+
+  /*
+    Tell the handler to allow deletes for this log table
+    by turning off log table flag.
+  */
+  hdl->extra(HA_EXTRA_ALLOW_LOG_DELETE);
+  result= hdl->ha_delete_row(tbl->record[0]);
+  hdl->extra(HA_EXTRA_MARK_AS_LOG_TABLE);
+  return result;
+}
+
+/**
+  Perform a table scan of the backup log tables for deleting rows.
+
+  This method is a helper method designed to delete rows from the
+  backup logs when the destination includes writing to tables.
+
+  The method is designed to work with either the backup_history or
+  backup_progress log. The log is specified using the @c log_name
+  parameter and should be either BACKUP_HISTORY_LOG_NAME or
+  BACKUP_PROGRESS_LOG_NAME.
+
+  There are three ways this method can be used. The choice of which of 
+  the operations to run depends on the values of the parameters as stated.
+  1. Delete rows whose backup_id is < a given value. This is used
+     for @c PURGE BACKUP LOGS TO <@c backup_id>.
+     To use this method, set @c backup_id to the value passed from the
+     command, @c delete_exact_row = FALSE, and @c datetime_val = 0. 
+  2. Delete rows in the log where backuip_id is == to a given value.
+     This is used when cascading deletes from the backup_history log 
+     to the backup_progress log. 
+     To use this method, set @c backup_id to the value of the rows needing
+     deletion, @c delete_exact_row = TRUE, and @c datetime_val = 0. 
+  3. Delete rows whose start_time < a given value. This is used for
+     @c PURGE BACKUP LOGS BEFORE <datetimeval>.
+     To use this method, set @c backup_id = 0, @c delete_exact_row = FALSE, 
+     and @c datetime_val = value passed from the command. 
+
+  @note Deleting rows by date is limited to the backup_history table.
+
+  @param[IN]  THD                 The current thread
+  @param[IN]  log_name            is used to determine which log to process 
+                                  (backup_history or backup_progress).
+  @param[IN]  backup_id           value specified on the command for deleting 
+                                  rows by id or value for exact match 
+  @param[IN]  datetime_val        value specified on the command for deleting 
+                                  rows by date
+  @param[IN]  delete_exact_row    if TRUE, use the comparison for the log 
+                                  column backup_id_in_row == @c backup_id else 
+                                  use the comparison backup_id_in_row < 
+                                  @c backup_id.
+  @param[OUT] num                 Number of rows affected.
+
+  @returns TRUE if error
+*/
+static bool del_bup_log_row(THD *thd, 
+                            LEX_STRING log_name, 
+                            ulonglong backup_id, 
+                            my_time_t datetime_val,
+                            bool delete_exact_row,
+                            int *rows)
+{
+  TABLE_LIST table_list;
+  handler *hdl;
+  TABLE *tbl;
+  uint result= 0;
+  int num_rows= 0;
+  Open_tables_state open_tables_backup;
+  MYSQL_TIME tmp;
+
+  DBUG_ASSERT((my_strcasecmp(system_charset_info, log_name.str, 
+               BACKUP_HISTORY_LOG_NAME.str) == 0) ||
+              (my_strcasecmp(system_charset_info, log_name.str, 
+               BACKUP_PROGRESS_LOG_NAME.str) == 0));
+
+  /*
+    Setup table list for open.
+  */
+  bzero(&table_list, sizeof(TABLE_LIST));
+  table_list.alias= table_list.table_name= log_name.str;
+  table_list.table_name_length= log_name.length;
+
+  table_list.lock_type= TL_WRITE_CONCURRENT_INSERT;
+
+  table_list.db= MYSQL_SCHEMA_NAME.str;
+  table_list.db_length= MYSQL_SCHEMA_NAME.length;
+
+  tbl= open_performance_schema_table(thd, &table_list,
+                                       &open_tables_backup);
+  hdl= tbl->file;
+  hdl->extra(HA_EXTRA_MARK_AS_LOG_TABLE);
+
+  /*
+    Get time zone conversion of value to compare for
+    PURGE BACKUP LOGS BEFORE <datetime>.
+  */
+  bzero(&tmp, sizeof(MYSQL_TIME));
+  thd->variables.time_zone->gmt_sec_to_TIME(&tmp, datetime_val);
+
+  /*
+    Begin table scan.
+  */
+  result= hdl->ha_rnd_init(1);
+  result= hdl->rnd_next(tbl->record[0]);
+  while (result != HA_ERR_END_OF_FILE)
+  {
+    // backup_id is field number 0 in both logs.
+    ulonglong id= tbl->field[0]->val_int();
+    /*
+      Delete by id.
+    */
+    if (!datetime_val)
+    {
+      /*
+        Here we delete a specific row. For example, a specific
+        row in the backup_history log as the result of a 
+        cascade delete initiated from backup_history log.
+      */
+      if (delete_exact_row)
+      {
+        if (id == backup_id) // delete log row
+        {
+          result= delete_current_log_row(hdl, tbl);
+          if (result)
+            goto error;
+        }
+      }
+      /*
+        Here we execute the delete all rows 'to' a specific
+        id, e.g. PURGE BACKUP LOGS TO 17 -- we delete id < 17.
+      */
+      else if (id < backup_id)
+      {
+        result= delete_current_log_row(hdl, tbl);
+        if (result)
+          goto error;
+        num_rows++;
+      }
+    }
+    /*
+      Delete by date
+    */
+    else  
+    {
+      MYSQL_TIME time;      
+
+      DBUG_ASSERT(my_strcasecmp(system_charset_info, log_name.str, 
+                  BACKUP_HISTORY_LOG_NAME.str) == 0);
+
+      tbl->field[ET_OBH_FIELD_START_TIME]->get_date(&time, TIME_NO_ZERO_DATE);
+      if (my_time_compare(&time, &tmp) < 0)
+      {
+        /*
+          When deleting by date for the backup_history table,
+          we must also delete rows from the backup_progress table
+          for this backup id.
+        */
+        if ((my_strcasecmp(system_charset_info, log_name.str, 
+             BACKUP_HISTORY_LOG_NAME.str) == 0) &&
+            opt_backup_progress_log && 
+            (log_backup_output_options & LOG_TABLE))
+        {
+          int r= 0;
+
+          del_bup_log_row(thd, BACKUP_PROGRESS_LOG_NAME, 
+                          id, 0, TRUE, &r);
+        }
+        result= delete_current_log_row(hdl, tbl);
+        if (result)
+          goto error;
+        num_rows++;
+      }
+    }
+    result= hdl->rnd_next(tbl->record[0]);
+  }
+error:
+  int res_end= hdl->ha_rnd_end();
+  *rows= num_rows;
+  close_performance_schema_table(thd, &open_tables_backup);
+  return (result != HA_ERR_END_OF_FILE) ? result : res_end;
+}
+
+/**
+  Remove all rows from the backup logs.
+
+  This method removes (via truncate) all data from the backup logs. It checks
+  if the backup logs are turned on and if the log_backup_output_option is set
+  to include writing to tables. If these conditions are true, each log 
+  (backup_history, backup_progress) is truncated.
+
+  @param[IN] THD  current thread
+
+  @returns TRUE = success, FALSE = failed
+*/
+bool Log_to_csv_event_handler::purge_backup_logs(THD *thd)
+{
+  TABLE_LIST tables;
+  bool res= FALSE;
+
+  if (opt_backup_history_log && (log_backup_output_options & LOG_TABLE))
+  {
+    // need to truncate the table.
+    tables.init_one_table("mysql", strlen("mysql"), 
+                          "backup_history", strlen("backup_history"),
+                          "backup_history", TL_READ);
+    alloc_mdl_locks(&tables, thd->mem_root);
+    res= mysql_truncate(thd, &tables, 1);
+    close_thread_tables(thd);
+    if (res)
+      goto err;
+  }
+  if (opt_backup_progress_log && (log_backup_output_options & LOG_TABLE))
+  {
+    // need to truncate the table.
+    tables.init_one_table("mysql", strlen("mysql"), 
+                          "backup_progress", strlen("backup_progress"),
+                          "backup_progress", TL_READ);
+    alloc_mdl_locks(&tables, thd->mem_root);
+    res= mysql_truncate(thd, &tables, 1);
+    close_thread_tables(thd);
+  }
+err:
+  return res;
+}
+
+/**
+  Purge backup logs of rows less than backup_id passed.
+
+  This method walks the backup log tables deleting all rows whose
+  backup id is less than @c backup_id passed. 
+
+  @param[IN]  THD                 The current thread
+  @param[IN]  backup_id           Value for backup id
+  @param[OUT] num                 Number of rows affected.
+
+  @retval num  Number of rows affected.
+
+  @returns TRUE if error
+*/
+bool 
+Log_to_csv_event_handler::purge_backup_logs_before_id(THD *thd, 
+                                                      ulonglong backup_id,
+                                                      int *rows)
+{
+  bool res= FALSE;
+
+  if (opt_backup_history_log && (log_backup_output_options & LOG_TABLE))
+  { 
+    res= del_bup_log_row(thd, BACKUP_HISTORY_LOG_NAME, 
+                         backup_id, 0, FALSE, rows);
+    if (res)
+      goto err;
+  }
+  if (opt_backup_progress_log && (log_backup_output_options & LOG_TABLE))
+  {
+    int r= 0;   //ignore this for progress log
+
+    res= del_bup_log_row(thd, BACKUP_PROGRESS_LOG_NAME, 
+                         backup_id, 0, FALSE, &r);
+  }
+err:
+  return res;
+}
+
+/**
+  Purge backup logs of rows previous to start date passed.
+
+  This method walks the backup log tables deleting all rows whose
+  start column value is less than @c t passed. 
+
+  Implementation Description: This method uses cascading delete 
+  functionality to remove rows from the backup_progress log when 
+  rows from the backup_history log are removed. Thus, only one 
+  call to delete rows from the logs is necessary.
+
+  @param[IN]  THD                 The current thread
+  @param[IN]  t                   Value for start datetime
+  @param[OUT] num                 Number of rows affected.
+
+  @retval num  Number of rows affected.
+
+  @returns TRUE if error
+*/
+bool 
+Log_to_csv_event_handler::purge_backup_logs_before_date(THD *thd, 
+                                                        my_time_t t,
+                                                        int *rows)
+{
+  bool res= FALSE;
+
+  if (opt_backup_history_log && (log_backup_output_options & LOG_TABLE))
+    res= del_bup_log_row(thd, BACKUP_HISTORY_LOG_NAME, 
+                         0, t, FALSE, rows);
+  return res;
+}
+
+
 bool Log_to_csv_event_handler::
   log_error(enum loglevel level, const char *format, va_list args)
 {
@@ -1256,12 +1592,55 @@ void Log_to_file_event_handler::flush_ba
     reopen log files 
 
     Where TRUE means perform open on history file (backup_history) and
-    FALSE means perform open on the progress file (backkup_progress).
+    FALSE means perform open on the progress file (backup_progress).
   */
   mysql_backup_history_log.reopen_file(TRUE);
   mysql_backup_progress_log.reopen_file(FALSE);
 }
 
+/**
+  Purge the backup logs of all data.
+
+  This method truncates the backup log files. It will only do so if the
+  log_backup_output_options includes logging to FILE. It also checks to
+  see if each log is turned on (backup_history and backup_progress) and
+  if so, truncates it. Truncate in this case means resetting the size
+  to 0 bytes using my_chsize().
+
+  @returns TRUE = success, FALSE = failed.
+*/
+bool Log_to_file_event_handler::purge_backup_logs()
+{
+  bool res= FALSE;
+
+  if (opt_backup_history_log && (log_backup_output_options & LOG_FILE))
+  {
+    MYSQL_BACKUP_LOG *backup_log= logger.get_backup_history_log_file_handler();
+
+    pthread_mutex_lock(backup_log->get_log_lock());
+    res= my_sync(backup_log->get_file(), MYF(MY_WME));
+    if (!res)
+      res= my_chsize(backup_log->get_file(), 0, 0, MYF(MY_WME));
+    pthread_mutex_unlock(backup_log->get_log_lock());
+    if (res)
+      goto err;
+  }
+  if (opt_backup_progress_log && (log_backup_output_options & LOG_FILE))
+  {
+    MYSQL_BACKUP_LOG *backup_log= logger.get_backup_progress_log_file_handler();
+
+    pthread_mutex_lock(backup_log->get_log_lock());
+    res= my_sync(backup_log->get_file(), MYF(MY_WME));
+    if (!res)
+      res= my_chsize(backup_log->get_file(), 0, 0, MYF(MY_WME));
+    pthread_mutex_unlock(backup_log->get_log_lock());
+    if (res)
+      goto err;
+  }
+err:
+  return res;
+}
+
 void Log_to_file_event_handler::cleanup()
 {
   mysql_log.cleanup();
@@ -1411,6 +1790,91 @@ bool LOGGER::flush_backup_logs(THD *thd)
   return rc;
 }
 
+/**
+  Delete contents of backup logs.
+
+  This method deletes the data from the backup logs. This applies to both
+  log file and table destinations.
+
+  @param[IN]  thd  The current thread.
+
+  @returns TRUE if error.
+*/
+bool LOGGER::purge_backup_logs(THD *thd)
+{
+  my_bool res= FALSE;
+
+  DBUG_ENTER("LOGGER::purge_backup_logs");
+  /*
+    Here we need to truncate the files if writing to files.
+  */
+  res= file_log_handler->purge_backup_logs();
+  if (res)
+    goto err;
+
+  /*
+    We also need to truncate the table if writing to tables.
+  */
+  res= table_log_handler->purge_backup_logs(thd);
+
+err:
+  DBUG_RETURN(res);
+}
+
+/**
+  Delete contents of backup logs where backup id is less than a given id.
+
+  This method deletes the data from the backup logs where a backup id is 
+  less than the backup id specified. This applies only to table destinations.
+
+  @param[IN]  thd        The current thread.
+  @param[IN]  backup_id  The backup id to compare rows to.
+  @param[OUT] rows       The number of rows affected.
+
+  @retval  num  The number of rows affected.
+
+  @returns TRUE if error.
+*/
+bool LOGGER::purge_backup_logs_before_id(THD *thd, 
+                                         ulonglong backup_id, 
+                                         int *rows)
+{
+  my_bool res= FALSE;
+
+  DBUG_ENTER("LOGGER::purge_backup_logs_before_id");
+
+  res= table_log_handler->purge_backup_logs_before_id(thd, backup_id, rows);
+
+  DBUG_RETURN(res);
+}
+
+/**
+  Delete backup rows less than a certain date.
+
+  This method scans the backup history log and deletes the rows for those
+  operations that were created (start column) previous to the date specified in 
+  @c t.
+
+  @param[IN]  thd        The current thread.
+  @param[IN]  t          The date to compare rows to.
+  @param[OUT] rows       The number of rows affected.
+
+  @retval  rows  The number of rows affected.
+
+  @returns TRUE if error.
+*/
+bool LOGGER::purge_backup_logs_before_date(THD *thd, 
+                                           my_time_t t, 
+                                           int *rows)
+{
+  my_bool res= FALSE;
+
+  DBUG_ENTER("LOGGER::purge_backup_logs_before_date");
+
+  res= table_log_handler->purge_backup_logs_before_date(thd, t, rows);
+
+  DBUG_RETURN(res);
+}
 
 /*
   Log slow query with all enabled log event handlers
@@ -1651,6 +2115,7 @@ bool LOGGER::backup_progress_log_write(T
   else
     id= 0;                              /* Log from connect handler */
 
+
   lock_shared();
   while (*current_handler)
     error|= (*current_handler++)->
@@ -3605,7 +4070,7 @@ ulonglong MYSQL_BACKUP_LOG::get_next_bac
   else  // increment the counter
     id= m_next_id + 1;
 
-  DBUG_EXECUTE_IF("set_backup_id", id= 500;);
+  DBUG_EXECUTE_IF("set_backup_id", id= obs::is_slave() ? 600 : 500;);
 
   /* 
     Write the new value to the file

=== modified file 'sql/log.h'
--- a/sql/log.h	2008-10-27 13:06:21 +0000
+++ b/sql/log.h	2008-10-28 14:17:05 +0000
@@ -268,6 +268,14 @@ private:
   time_t last_time;
 };
 
+/*
+  Values for the type enum. This reflects the order of the enum 
+  declaration in the PURGE BACKUP LOGS command.
+*/
+#define TYPE_ENUM_PURGE_BACKUP_LOGS       1
+#define TYPE_ENUM_PURGE_BACKUP_LOGS_ID    2
+#define TYPE_ENUM_PURGE_BACKUP_LOGS_DATE  3
+
 class MYSQL_BACKUP_LOG: public MYSQL_LOG
 {
 public:
@@ -307,6 +315,8 @@ public:
   }
   ulonglong get_next_backup_id();
   my_bool check_backup_logs(THD *thd);
+  File get_file() { return log_file.file; }
+  inline pthread_mutex_t* get_log_lock() { return &LOCK_log; }
 
 private:
   bool write_int(uint num);
@@ -577,6 +587,13 @@ public:
                                    longlong progress,
                                    int error_num,
                                    const char *notes);
+  bool purge_backup_logs(THD *thd);
+  bool purge_backup_logs_before_id(THD *thd, 
+                                   ulonglong backup_id, 
+                                   int *rows);
+  bool purge_backup_logs_before_date(THD *thd, 
+                                     my_time_t t, 
+                                     int *rows);
 
   int activate_log(THD *thd, uint log_type);
 
@@ -630,6 +647,7 @@ public:
 
   void flush();
   void flush_backup_logs();
+  bool purge_backup_logs();
   void init_pthread_objects();
   MYSQL_QUERY_LOG *get_mysql_slow_log() { return &mysql_slow_log; }
   MYSQL_QUERY_LOG *get_mysql_log() { return &mysql_log; }
@@ -684,6 +702,13 @@ public:
   void init_log_tables();
   bool flush_logs(THD *thd);
   bool flush_backup_logs(THD *thd);
+  bool purge_backup_logs(THD *thd);
+  bool purge_backup_logs_before_id(THD *thd, 
+                                   ulonglong backup_id, 
+                                   int *rows);
+  bool purge_backup_logs_before_date(THD *thd, 
+                                     my_time_t t, 
+                                     int *rows);
   /* Perform basic logger cleanup. this will leave e.g. error log open. */
   void cleanup_base();
   /* Free memory. Nothing could be logged after this function is called */

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2008-11-06 18:46:03 +0000
+++ b/sql/log_event.cc	2008-11-14 13:24:32 +0000
@@ -9144,13 +9144,12 @@ Incident_log_event::description() const
 {
   static const char *const description[]= {
     "NOTHING",                                  // Not used
-    "LOST_EVENTS"
+    "LOST_EVENTS",
+    "RESTORE_ON_MASTER"
   };
 
   DBUG_PRINT("info", ("m_incident: %d", m_incident));
 
-  DBUG_ASSERT((size_t) m_incident <= sizeof(description)/sizeof(*description));
-
   return description[m_incident];
 }
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2008-11-06 18:39:27 +0000
+++ b/sql/mysqld.cc	2008-11-13 09:46:39 +0000
@@ -513,6 +513,7 @@ my_bool opt_old_style_user_limits= 0, tr
 volatile bool mqh_used = 0;
 my_bool opt_noacl;
 my_bool sp_automatic_privileges= 1;
+my_bool disable_slaves= 0;
 
 ulong opt_binlog_rows_event_max_size;
 const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
@@ -3244,6 +3245,7 @@ SHOW_VAR com_status_vars[]= {
   {"prepare_sql",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PREPARE]), SHOW_LONG_STATUS},
   {"purge",                (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE]), SHOW_LONG_STATUS},
   {"purge_before_date",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE_BEFORE]), SHOW_LONG_STATUS},
+  {"purge_bup_log",        (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_PURGE_BACKUP_LOGS]), SHOW_LONG_STATUS},
   {"release_savepoint",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RELEASE_SAVEPOINT]), SHOW_LONG_STATUS},
   {"rename_table",         (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS},
   {"rename_user",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_RENAME_USER]), SHOW_LONG_STATUS},
@@ -5848,7 +5850,9 @@ enum options_mysqld
   OPT_DEADLOCK_SEARCH_DEPTH_SHORT,
   OPT_DEADLOCK_SEARCH_DEPTH_LONG,
   OPT_DEADLOCK_TIMEOUT_SHORT,
-  OPT_DEADLOCK_TIMEOUT_LONG
+  OPT_DEADLOCK_TIMEOUT_LONG,
+  OPT_BACKUP_HISTORY_LOG_FILE,
+  OPT_BACKUP_PROGRESS_LOG_FILE
 };
 
 
@@ -6116,6 +6120,16 @@ Disable with --skip-large-pages.",
   {"general_log_file", OPT_GENERAL_LOG_FILE,
    "Log connections and queries to given file.", (uchar**) &opt_logname,
    (uchar**) &opt_logname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"backup_history_log_file", OPT_BACKUP_HISTORY_LOG_FILE,
+   "Log backup history to a given file.", 
+   (uchar**) &opt_backup_history_logname,
+   (uchar**) &opt_backup_history_logname, 0, GET_STR, 
+   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"backup_progress_log_file", OPT_BACKUP_PROGRESS_LOG_FILE,
+   "Log backup progress to a given file.", 
+   (uchar**) &opt_backup_progress_logname,
+   (uchar**) &opt_backup_progress_logname, 0, GET_STR, 
+   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"log-bin", OPT_BIN_LOG,
    "Log update queries in binary format. Optional (but strongly recommended "
    "to avoid replication problems if server's hostname changes) argument "

=== modified file 'sql/rpl_constants.h'
--- a/sql/rpl_constants.h	2007-03-29 18:31:09 +0000
+++ b/sql/rpl_constants.h	2008-10-28 18:14:14 +0000
@@ -11,6 +11,9 @@ enum Incident {
   /** There are possibly lost events in the replication stream */
   INCIDENT_LOST_EVENTS,
 
+  /** Restore event: Restore has occurred on the master during replication */
+  INCIDENT_RESTORE_EVENT,
+
   /** Shall be last event of the enumeration */
   INCIDENT_COUNT
 };

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2008-11-07 14:01:59 +0000
+++ b/sql/set_var.cc	2008-11-13 09:46:39 +0000
@@ -76,7 +76,7 @@ extern ulong ndb_report_thresh_binlog_me
 #endif
 
 extern CHARSET_INFO *character_set_filesystem;
-
+extern my_bool disable_slaves;
 
 static DYNAMIC_ARRAY fixed_show_vars;
 static HASH system_variable_hash;
@@ -552,6 +552,8 @@ static sys_var_thd_ulonglong	sys_tmp_tab
 					   &SV::tmp_table_size);
 static sys_var_bool_ptr  sys_timed_mutexes(&vars, "timed_mutexes",
                                     &timed_mutexes);
+static sys_var_bool_ptr  sys_disable_slaves(&vars, "disable_slave_connections",
+                                             &disable_slaves);
 static sys_var_const_str	sys_version(&vars, "version", server_version);
 static sys_var_const_str	sys_version_comment(&vars, "version_comment",
                                             MYSQL_COMPILATION_COMMENT);
@@ -2398,7 +2400,15 @@ void sys_var_log_state::set_default(THD 
     WARN_DEPRECATED(thd, 7,0, "@@log_slow_queries", "'@@slow_query_log'");
 
   pthread_mutex_lock(&LOCK_global_system_variables);
-  logger.deactivate_log_handler(thd, log_type);
+  /*
+    Default for general and slow log is OFF.
+    Default for backup logs is ON.
+  */
+  if ((this == &sys_var_backup_history_log) ||
+      (this == &sys_var_backup_progress_log))
+    logger.activate_log_handler(thd, log_type);
+  else
+    logger.deactivate_log_handler(thd, log_type);
   pthread_mutex_unlock(&LOCK_global_system_variables);
 }
 
@@ -2561,7 +2571,8 @@ bool update_sys_var_str_path(THD *thd, s
   var_str->value= res;
   var_str->value_length= str_length;
   my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
-  if (file_log && log_state)
+  if ((file_log && log_state) ||
+      (backup_log && log_state))
   {
     /*
       Added support for backup log types.

=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt	2008-11-07 17:07:58 +0000
+++ b/sql/share/errmsg.txt	2008-11-13 08:40:43 +0000
@@ -6416,7 +6416,22 @@ ER_BACKUP_BINLOG
         eng "Error on accessing binlog during BACKUP"
         nor "Lesing av binlog feilet under BACKUP"
         norwegian-ny "Lesing av binlog feila under BACKUP"
-
+ER_BACKUP_LOG_OUTPUT
+  eng "Removing backup log entries by date or backup_id requires logging to tables."
+ER_BACKUP_PURGE_DATETIME
+  eng "The datetime specified is invalid for the '%-.64s' command."
+ER_BACKUP_LOGS_DELETED
+  eng "Backup log entries deleted: "
+ER_BACKUP_LOGS_TRUNCATED
+  eng "All backup logs entries have been deleted"
+ER_MASTER_BLOCKING_SLAVES
+  eng "The master is not allowing slave connections."
+ER_RESTORE_ON_MASTER
+  eng "A restore operation was initiated on the master."
+ER_RESTORE_ON_SLAVE
+  eng "A restore operation was attempted on a slave during replication. You must stop the slave prior to running a restore."
+ER_NONUNIQ_DB 42000 S1009
+        eng "Not unique database: '%-.192s'"
 ER_QUERY_CACHE_DISABLED
 	eng "Query cache is disabled; restart the server with query_cache_type=1 to enable it"
 

=== modified file 'sql/si_logs.cc'
--- a/sql/si_logs.cc	2008-10-15 20:00:48 +0000
+++ b/sql/si_logs.cc	2008-10-30 17:53:24 +0000
@@ -133,6 +133,26 @@ bool Backup_log::write_progress(const ch
                                           error_num, notes);
 }
 
+/**
+  Write master's binlog file and position to progress log.
+
+  @returns results of logging function (i.e., TRUE if error)
+*/
+bool Backup_log::write_master_binlog_info()
+{
+  char buff[1024];
+  bool ret= FALSE;
+
+  if (m_op_hist.master_binlog_file || m_op_hist.master_binlog_pos)
+  {
+    sprintf(buff, 
+      "Recording master binlog information. binlog file = '%s', position = %d.",
+      m_op_hist.master_binlog_file, m_op_hist.master_binlog_pos);
+    ret= write_progress(0, 0, 0, 0, 0, 0, (char *)&buff);
+  }
+  return ret;
+}
+
 /** 
   Report change of the state of operation
  

=== modified file 'sql/si_logs.h'
--- a/sql/si_logs.h	2008-10-15 20:00:48 +0000
+++ b/sql/si_logs.h	2008-10-30 17:53:24 +0000
@@ -58,6 +58,8 @@ struct st_backup_history
   time_t stop;                     ///< stop time of operation
   time_t vp_time;                  ///< point in time validation was assured
   String driver_name;              ///< list of backup engines used
+  int master_binlog_pos;           ///< position in the binary log
+  char *master_binlog_file;        ///< name of the master's binary log file
 };
 
 
@@ -112,6 +114,12 @@ public:
                       longlong progress,
                       int error_num,
                       const char *notes);
+
+  /*
+    Write master's binlog position and file if recorded earlier.
+  */
+  bool write_master_binlog_info();
+
   /*
     Check the backup logs (as tables).
   */
@@ -126,6 +134,11 @@ public:
   void error_num(int code) { m_op_hist.error_num= code; }
   void binlog_pos(unsigned long int pos) { m_op_hist.binlog_pos= pos; }
   void binlog_file(char *file);
+  void master_binlog_pos(unsigned long int pos) 
+  { 
+    m_op_hist.master_binlog_pos= pos; 
+  }
+  void master_binlog_file(char *file);
   void num_objects(int num) { m_op_hist.num_objects= num; }
   void size(longlong s) { m_op_hist.size= s; }
   void start(time_t when);
@@ -192,4 +205,20 @@ void Backup_log::binlog_file(char *file)
     m_op_hist.binlog_file= file;
 }
 
+/** 
+  Report master's binlog position at validity point.
+
+  This method saves the binlog file name in the history data.
+
+  @param[IN] file Binlog file name.
+
+  @note If the file name is 0|NULL, nothing is saved in the history data.
+*/
+inline
+void Backup_log::master_binlog_file(char *file)
+{
+  if (strlen(file) > 0)
+    m_op_hist.master_binlog_file= file;
+}
+
 #endif // SI_LOGS_H_

=== modified file 'sql/si_objects.cc'
--- a/sql/si_objects.cc	2008-10-27 13:06:21 +0000
+++ b/sql/si_objects.cc	2008-10-30 12:29:54 +0000
@@ -25,11 +25,15 @@
 #include "sql_trigger.h"
 #include "sp.h"
 #include "sp_head.h" // for sp_add_to_query_tables().
+#include "rpl_mi.h"
 
 TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list); // defined in sql_show.cc
 
 DDL_blocker_class *DDL_blocker= NULL;
 
+extern HASH slave_list;
+extern my_bool disable_slaves;
+
 ///////////////////////////////////////////////////////////////////////////
 
 namespace {
@@ -459,6 +463,36 @@ COND *create_db_select_condition(THD *th
 ///////////////////////////////////////////////////////////////////////////
 
 /**
+   @class ProcessObj
+
+   This class provides an abstraction to a process object for reading 
+   items from the process list.
+*/
+class ProcessObj : public Obj
+{
+public:
+  ProcessObj(const String *proc_name) { m_command.copy(*proc_name); };
+
+public:
+  bool materialize(uint serialization_version,
+                   const String *serialization)
+  { return FALSE; }
+
+  const String* get_name()
+  { return &m_command; }
+
+  const String *get_db_name() { return NULL; }
+
+private:
+  // These attributes are to be used only for serialization.
+  String m_command;
+
+  bool drop(THD *thd) { return FALSE; }
+  bool do_serialize(THD *thd, String *serialization) { return FALSE; }
+  bool do_execute(THD *thd) { return FALSE; }
+};
+
+/**
    @class DatabaseObj
 
    This class provides an abstraction to a database object for creation and
@@ -945,6 +979,22 @@ protected:
 };
 
 ///////////////////////////////////////////////////////////////////////////
+class ProcesslistIterator : public InformationSchemaIterator
+{
+public:
+  ProcesslistIterator(THD *thd,
+                      TABLE *is_table,
+                      handler *ha,
+                      my_bitmap_map *orig_columns) :
+    InformationSchemaIterator(thd, is_table, ha, orig_columns)
+  { }
+
+protected:
+  virtual ProcessObj *create_obj(TABLE *t);
+};
+
+
+///////////////////////////////////////////////////////////////////////////
 class DatabaseIterator : public InformationSchemaIterator
 {
 public:
@@ -1272,6 +1322,25 @@ Obj *InformationSchemaIterator::next()
 ///////////////////////////////////////////////////////////////////////////
 
 //
+// Implementation: ProcesslistIterator class.
+//
+
+///////////////////////////////////////////////////////////////////////////
+
+ProcessObj* ProcesslistIterator::create_obj(TABLE *t)
+{
+  String name;
+
+  t->field[4]->val_str(&name);
+
+  DBUG_PRINT("ProcesslistIterator::create_obj", (" Found process %s", name.ptr()));
+
+  return new ProcessObj(&name);
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+//
 // Implementation: DatabaseIterator class.
 //
 
@@ -2126,8 +2195,15 @@ bool TableObj::do_serialize(THD *thd, St
 
   /*
     Open the view and its base tables or views
-  */
-  if (open_normal_and_derived_tables(thd, table_list, 0)) {
+
+    The MYSQL_OPEN_SKIP_TEMPORARY flag is needed because TableObj always 
+    refers to a regular table, even if a temporary table with the same name
+    exists in the database (see BUG#33574). 
+  */
+  if (open_normal_and_derived_tables(thd, table_list, 
+                                     MYSQL_OPEN_SKIP_TEMPORARY)
+     ) 
+  {
     close_thread_tables(thd);
     thd->lex->select_lex.table_list.empty();
     DBUG_RETURN(TRUE);
@@ -3861,6 +3937,199 @@ int Name_locker::release_name_locks()
   DBUG_RETURN(0);
 }
 
+///////////////////////////////////////////////////////////////////////////
+
+//
+// Implementation: Replication methods.
+//
+
+///////////////////////////////////////////////////////////////////////////
+
+/*
+  Replication methods
+*/
+
+/**
+  Turn on or off logging for the current thread. 
+
+  This method can be used to turn logging on or off in situations where it is
+  necessary to prevent some operations from being logged, e.g. 
+  BACKUP DATABASE.
+
+  @param[IN] enable  TRUE = turn on, FALSE = turn off
+
+  @returns 0
+*/
+int engage_binlog(bool enable)
+{
+  int ret= 0;
+  THD *thd= current_thd;
+
+  if (enable)
+    thd->options|= OPTION_BIN_LOG;
+  else
+    thd->options&= ~OPTION_BIN_LOG;
+  return ret;
+}
+
+/**
+  Check if binlog is enabled for the current thread. 
+  
+  This method can be used to check to see if logging is enabled and operate 
+  as a gate for those areas of code that are conditional on whether logging is 
+  enabled (or disabled).
+
+  @returns   TRUE  if logging is enabled and binlog is open
+  @returns   FALSE if logging is turned off or binlog is closed
+*/
+bool is_binlog_engaged()
+{
+  THD *thd= current_thd;
+
+  return (thd->options & OPTION_BIN_LOG) && mysql_bin_log.is_open();
+}
+
+/**
+  Check if current server is executing as a slave. 
+
+  This method can be used to detect when running as a slave. This means that 
+  the server is configured to act as a slave. This can make it easier to 
+  organize the code for specialized sections where running as a slave requires
+  additional work, prohibiting backup and restore operations, or error 
+  conditions.
+
+  @returns   TRUE  if operating as a slave
+*/
+bool is_slave()
+{
+  bool running= FALSE;
+
+#ifdef HAVE_REPLICATION
+  if (active_mi)
+  {
+    pthread_mutex_lock(&LOCK_active_mi);
+    running= (active_mi->slave_running == MYSQL_SLAVE_RUN_CONNECT);
+    pthread_mutex_unlock(&LOCK_active_mi);
+  }
+#endif
+  return running;
+}
+
+/**
+  Check if any slaves are connected. 
+
+  This method can be used to detect whether there are slaves attached to the
+  current server. This will allow the code to know if replication is active.
+
+  @returns  int number of slaves currently attached
+*/
+int num_slaves_attached()
+{
+  int num_slaves= 0;
+  TABLE *is_table;
+  handler *ha;
+  my_bitmap_map *orig_columns;
+  ProcesslistIterator *pl= 0;
+  Obj *proc= 0;
+  THD *thd= current_thd;
+
+  if (InformationSchemaIterator::prepare_is_table(
+      thd, &is_table, &ha, &orig_columns, SCH_PROCESSLIST, 
+      thd->lex->db_list))
+    goto err;
+
+  pl= new ProcesslistIterator(thd, is_table, ha, orig_columns);
+
+  if (pl)
+  {
+    while ((proc= pl->next()))
+    {
+      const String *p= proc->get_name();
+      if (my_strcasecmp(system_charset_info, p->ptr(), 
+        "Binlog Dump") == 0)
+        num_slaves++;
+    }
+  }
+err:
+  return num_slaves;
+}
+
+/**
+  Disable or enable connection of new slaves to the master. 
+
+  This method can be used to temporarily prevent new slaves from connecting to
+  the master. This can allow operations such as RESTORE to prevent new slaves
+  from attaching during the execution of RESTORE.
+
+  @param[IN] disable  TRUE = turn off, FALSE = turn on
+
+  @returns value of disable_slaves (TRUE | FALSE)
+*/
+int disable_slave_connections(bool disable)
+{
+  // Protect with a mutex?
+  disable_slaves= disable ? 1 : 0;
+  return disable_slaves;
+}
+
+/**
+  Write an incident event in the binary log.
+
+  This method can be used to issue an incident event to inform the slave
+  that an unusual event has occurred on the master. For example an incident
+  event could represent that a restore has been issued on the master. This 
+  should force the slave to stop and allow the user to analyze the effect
+  of the restore on the master and take the appropriate steps to correct
+  the slave (e.g. running the same restore on the slave.
+
+  @param[IN] thd            The current thread
+  @param[IN] incident_enum  The indicent being reported
+ 
+  @retval FALSE on success.
+  @retval TRUE on error.
+*/
+int write_incident_event(THD *thd, incident_events incident_enum)
+{
+  bool res= FALSE;
+
+#ifdef HAVE_REPLICATION
+  Incident incident;
+
+  /*
+    Generate an incident log event (gap event) to signal the slave
+    that a restore has been issued on the master.
+  */
+  switch (incident_enum){
+    case NONE:
+      incident= INCIDENT_NONE;
+      break;
+    case LOST_EVENTS:
+      incident= INCIDENT_LOST_EVENTS;
+      break;
+    case RESTORE_EVENT:
+      incident= INCIDENT_RESTORE_EVENT;
+      break;
+    default:   // fail safe : should not occur
+      incident= INCIDENT_NONE;
+      break;
+  }
+  DBUG_PRINT("write_incident_event()", ("Before write_incident_event()."));
+  /*
+    Don't write this unless binlog is engaged.
+  */
+  if (incident && is_binlog_engaged())
+  {
+    LEX_STRING msg;
+    msg.str= (char *)ER(ER_RESTORE_ON_MASTER);
+    msg.length = strlen(ER(ER_RESTORE_ON_MASTER));
+    Incident_log_event ev(thd, incident, msg);
+    res= mysql_bin_log.write(&ev);
+    mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
+  }
+#endif
+  return res;
+}
+
 } // obs namespace
 
 ///////////////////////////////////////////////////////////////////////////

=== modified file 'sql/si_objects.h'
--- a/sql/si_objects.h	2008-10-27 13:06:21 +0000
+++ b/sql/si_objects.h	2008-10-28 18:14:14 +0000
@@ -708,6 +708,53 @@ private:
   void free_table_list(TABLE_LIST*);
 };
 
+///////////////////////////////////////////////////////////////////////////
+
+//
+// Replication methods.
+//
+
+/*
+  Turn on or off logging for the current thread. 
+*/
+int engage_binlog(bool enable);
+
+/*
+  Check if binlog is enabled for the current thread. 
+*/
+bool is_binlog_engaged();
+
+/*
+  Check if current server is executing as a slave. 
+*/
+bool is_slave();
+
+/*
+  Check if any slaves are connected. 
+*/
+int num_slaves_attached();
+
+/*
+  Disable or enable connection of new slaves to the master. 
+*/
+int disable_slave_connections(bool disable);
+
+/**
+  Enumeration of the incidents that can occur on the master.
+*/
+enum incident_events {
+  NONE,          // Indicates there was no incident 
+  LOST_EVENTS,   // Indicates lost events 
+  RESTORE_EVENT, // Indicates a restore has executed on the master
+  COUNT          // Value counts the enumerations
+};
+
+/*
+  Write incident event to signal slave an unusual event has been issued 
+  on the master.
+*/
+int write_incident_event(THD *thd, incident_events incident_enum);
+
 } // obs namespace
 
 #endif // SI_OBJECTS_H_

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2008-10-16 02:13:16 +0000
+++ b/sql/sql_lex.cc	2008-11-13 08:40:43 +0000
@@ -3027,3 +3027,28 @@ bool LEX::is_partition_management() cons
            alter_info.flags == ALTER_REORGANIZE_PARTITION));
 }
 
+int LEX::add_db_to_list(LEX_STRING *name)
+{
+  DBUG_ASSERT(name);
+    
+  List_iterator<LEX_STRING> it(db_list);
+  LEX_STRING *copy;
+  
+  while ((copy= it++))
+   if (!my_strnncoll(system_charset_info, 
+                     (const uchar*) name->str, name->length , 
+                     (const uchar*) copy->str, copy->length ))
+   {    
+     my_error(ER_NONUNIQ_DB, MYF(0), name->str);
+     return ER_NONUNIQ_DB;
+   }
+
+  copy= (LEX_STRING*) sql_memdup(name, sizeof(LEX_STRING));
+  if (copy == NULL)
+    return ER_OUT_OF_RESOURCES;
+    
+  if (db_list.push_back(copy))
+    return ER_OUT_OF_RESOURCES;
+
+  return 0;
+}

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2008-11-04 11:30:00 +0000
+++ b/sql/sql_lex.h	2008-11-13 08:40:43 +0000
@@ -117,7 +117,7 @@ enum enum_sql_command {
   SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS,
   SQLCOM_SHOW_CREATE_TRIGGER,
   SQLCOM_ALTER_DB_UPGRADE,
-  SQLCOM_BACKUP, SQLCOM_RESTORE,
+  SQLCOM_BACKUP, SQLCOM_RESTORE, SQLCOM_PURGE_BACKUP_LOGS, 
 #ifdef BACKUP_TEST
   SQLCOM_BACKUP_TEST,
 #endif
@@ -1526,6 +1526,7 @@ struct LEX: public Query_tables_list
   LEX_STRING backup_dir;				/* For RESTORE/BACKUP */
   bool backup_compression;
   char* to_log;                                 /* For PURGE MASTER LOGS TO */
+  ulonglong backup_id;     /* For PURGE BACKUP LOGS */
   char* x509_subject,*x509_issuer,*ssl_cipher;
   String *wild;
   sql_exchange *exchange;
@@ -1872,6 +1873,13 @@ struct LEX: public Query_tables_list
     }
     return FALSE;
   }
+
+  void clear_db_list()
+  {
+    db_list.empty();
+  }
+
+  int add_db_to_list(LEX_STRING *name);
 };
 
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-11-06 18:39:27 +0000
+++ b/sql/sql_parse.cc	2008-11-13 08:40:43 +0000
@@ -2124,6 +2124,94 @@ mysql_execute_command(THD *thd)
     res = purge_master_logs_before_date(thd, (ulong)it->val_int());
     break;
   }
+  /*
+    Purge backup logs command.
+  */
+  case SQLCOM_PURGE_BACKUP_LOGS:
+  {
+    char buff[256];
+    int num= 0;
+    res= 0;
+
+    if (check_global_access(thd, SUPER_ACL))
+      goto error;
+
+    /*
+      If we are attempting to purge to a specified date or backup_id, we
+      must ensure the backup history log is turned on and is
+      being written to a table.
+    */
+    if (((lex->type == TYPE_ENUM_PURGE_BACKUP_LOGS_ID) ||
+         (lex->type == TYPE_ENUM_PURGE_BACKUP_LOGS_DATE)) &&
+         (opt_backup_history_log && !(log_backup_output_options & LOG_TABLE)))
+    {
+      my_error(ER_BACKUP_LOG_OUTPUT, MYF(0), ER(ER_BACKUP_LOG_OUTPUT));
+      goto error;
+    }
+
+    /*
+      Check the type of purge command and process accordingly.
+    */
+    switch (lex->type) {
+    case TYPE_ENUM_PURGE_BACKUP_LOGS:
+    {
+      if (sys_var_backupdir.value_length > 0)
+        res= logger.purge_backup_logs(thd);
+      break;
+    }
+    case TYPE_ENUM_PURGE_BACKUP_LOGS_ID:
+    {
+      res= logger.purge_backup_logs_before_id(thd, thd->lex->backup_id, &num);
+      break;
+    }
+    case TYPE_ENUM_PURGE_BACKUP_LOGS_DATE:
+    {
+      Item *it;
+
+      /*
+        Perform additional error checking for the 
+        PURGE BACKUP LOGS BEFORE <date> command.
+      */
+      it= (Item *)lex->value_list.head();
+      if ((!it->fixed && it->fix_fields(lex->thd, &it)) ||
+          it->check_cols(1))
+      {
+        my_error(ER_WRONG_ARGUMENTS, MYF(0), "PURGE BACKUP LOGS BEFORE");
+        goto error;
+      }
+      it= new Item_func_unix_timestamp(it);
+
+      /*
+        it is OK to only emulate fix_fields, because we need only
+        value of constant
+      */
+      it->quick_fix_field();
+
+      if ((ulong)it->val_int() == 0)
+      {
+        my_error(ER_BACKUP_PURGE_DATETIME, MYF(0), "PURGE BACKUP LOGS BEFORE");
+        goto error;
+      }
+
+      my_time_t t= (ulong)it->val_int();
+
+      res= logger.purge_backup_logs_before_date(thd, t, &num);
+      break;
+    }
+    }
+
+    /*
+      Check result. 
+    */
+    if (res)
+      goto error;
+    if (lex->type == TYPE_ENUM_PURGE_BACKUP_LOGS)
+      my_sprintf(buff, (buff, "%s.", ER(ER_BACKUP_LOGS_TRUNCATED)));
+    else
+      my_sprintf(buff, (buff, "%s %d.", ER(ER_BACKUP_LOGS_DELETED), num));
+    my_ok(thd, num, 0, buff);
+    break;
+  }
 #endif
   case SQLCOM_SHOW_WARNS:
   {

=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc	2008-10-20 09:16:47 +0000
+++ b/sql/sql_repl.cc	2008-10-28 18:14:14 +0000
@@ -28,6 +28,7 @@ my_bool opt_sporadic_binlog_dump_fail = 
 #ifndef DBUG_OFF
 static int binlog_dump_count = 0;
 #endif
+extern my_bool disable_slaves;
 
 /*
     fake_rotate_event() builds a fake (=which does not exist physically in any
@@ -471,6 +472,17 @@ void mysql_binlog_send(THD* thd, char* l
   }
 #endif
 
+  /*
+    Tell the connecting slave the master cannot accept any connections
+    if disable_slaves == TRUE.
+  */
+  if (disable_slaves)
+  {
+     errmsg= "Master does not allow slaves to connect.";
+     my_errno= ER_MASTER_BLOCKING_SLAVES;
+     goto err;
+  }
+
   if (!mysql_bin_log.is_open())
   {
     errmsg = "Binary log is not open";

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2008-11-06 18:39:27 +0000
+++ b/sql/sql_yacc.yy	2008-11-13 08:40:43 +0000
@@ -6422,8 +6422,6 @@ slave_until_opts:
 
 restore:
           RESTORE_SYM
-          FROM
-          TEXT_STRING_sys
           {
             LEX *lex= Lex;
             if (lex->sphead)
@@ -6432,18 +6430,17 @@ restore:
               MYSQL_YYABORT;
             }
             lex->sql_command = SQLCOM_RESTORE;
-            lex->db_list.empty();
-            lex->backup_dir = $3; 
+            lex->clear_db_list();
+          }
+          FROM
+          TEXT_STRING_sys
+          {
+            Lex->backup_dir = $4; 
           }
         ;
 
-backup:
-          BACKUP_SYM
-          DATABASE
-          database_list
-          TO_SYM
-          TEXT_STRING_sys
-          opt_compression
+backup:   
+          BACKUP_SYM 
           {
             LEX *lex= Lex;
             if (lex->sphead)
@@ -6452,7 +6449,15 @@ backup:
               MYSQL_YYABORT;
             }
             lex->sql_command = SQLCOM_BACKUP;
-            lex->backup_dir = $5; 
+            lex->clear_db_list();
+          }
+          DATABASE
+          database_list 
+          TO_SYM 
+          TEXT_STRING_sys
+          opt_compression
+          {
+            Lex->backup_dir = $6;
           }
         | BACKUP_TEST_SYM
           database_list
@@ -6485,29 +6490,19 @@ opt_compression_algorithm:
 
 database_list:
           '*'
-          {
-            Lex->db_list.empty();
-          }
+          {}
         | database_ident_list
         ;
 
 database_ident_list:
           ident
           {
-            LEX *lex= Lex;
-            LEX_STRING* ls= (LEX_STRING*) sql_memdup(&$1, sizeof(LEX_STRING));
-            if (ls == NULL)
-              MYSQL_YYABORT;
-            lex->db_list.empty();
-            if (lex->db_list.push_back(ls))
+            if (Lex->add_db_to_list(&$1))
               YYABORT;
           }
         | database_ident_list ',' ident
           {
-            LEX_STRING *ls= (LEX_STRING*) sql_memdup(&$3, sizeof(LEX_STRING));
-            if (ls == NULL)
-              MYSQL_YYABORT;
-            if (Lex->db_list.push_back(ls))
+            if (Lex->add_db_to_list(&$3))
               YYABORT;
           }
         ;
@@ -10813,10 +10808,32 @@ purge:
             lex->type=0;
             lex->sql_command = SQLCOM_PURGE;
           }
-          purge_options
-          {}
-        ;
+          purge_options {}
+          | PURGE BACKUP_SYM LOGS_SYM 
+          {
+            LEX *lex=Lex;
+            lex->type=TYPE_ENUM_PURGE_BACKUP_LOGS;
+            lex->sql_command = SQLCOM_PURGE_BACKUP_LOGS;
+          }
+          purge_bup_log_option {}
+          ; 
 
+purge_bup_log_option:
+          {}
+          | TO_SYM NUM_literal
+          {
+            LEX *lex= Lex;
+            lex->backup_id= (ulonglong)$2->val_int(); 
+            lex->type=TYPE_ENUM_PURGE_BACKUP_LOGS_ID;
+          }
+          | BEFORE_SYM expr
+          {
+            LEX *lex= Lex;
+            lex->value_list.empty();
+            lex->value_list.push_front($2);
+            lex->type=TYPE_ENUM_PURGE_BACKUP_LOGS_DATE;
+          }
+          ;
 purge_options:
           master_or_binary LOGS_SYM purge_option
         ;

=== modified file 'storage/csv/ha_tina.cc'
--- a/storage/csv/ha_tina.cc	2008-10-20 19:13:22 +0000
+++ b/storage/csv/ha_tina.cc	2008-10-28 14:17:05 +0000
@@ -80,7 +80,6 @@ static handler *tina_create_handler(hand
                                     TABLE_SHARE *table, 
                                     MEM_ROOT *mem_root);
 
-
 /*****************************************************************************
  ** TINA tables
  *****************************************************************************/
@@ -169,6 +168,7 @@ static TINA_SHARE *get_share(const char 
     share->update_file_opened= FALSE;
     share->tina_write_opened= FALSE;
     share->data_file_version= 0;
+    share->allow_log_delete= FALSE;
     strmov(share->table_name, table_name);
     fn_format(share->data_file_name, table_name, "", CSV_EXT,
               MY_REPLACE_EXT|MY_UNPACK_FILENAME);
@@ -995,8 +995,13 @@ int ha_tina::delete_row(const uchar * bu
   share->rows_recorded--;
   pthread_mutex_unlock(&share->mutex);
 
-  /* DELETE should never happen on the log table */
-  DBUG_ASSERT(!share->is_log_table);
+  /* 
+     DELETE should never happen on the log table
+     UNLESS extra() has been called with HA_EXTRA_ALLOW_LOG_DELETE 
+     which sets allow_log_delete flag. The flag is reset with 
+     HA_EXTRA_MARK_AS_LOG_TABLE.     
+  */
+  DBUG_ASSERT(!share->is_log_table || share->allow_log_delete);
 
   DBUG_RETURN(0);
 }
@@ -1169,6 +1174,13 @@ int ha_tina::extra(enum ha_extra_functio
  {
    pthread_mutex_lock(&share->mutex);
    share->is_log_table= TRUE;
+   share->allow_log_delete= FALSE;
+   pthread_mutex_unlock(&share->mutex);
+ }
+ else if (operation == HA_EXTRA_ALLOW_LOG_DELETE)
+ {
+   pthread_mutex_lock(&share->mutex);
+   share->allow_log_delete= TRUE;
    pthread_mutex_unlock(&share->mutex);
  }
   DBUG_RETURN(0);

=== modified file 'storage/csv/ha_tina.h'
--- a/storage/csv/ha_tina.h	2008-06-28 11:00:59 +0000
+++ b/storage/csv/ha_tina.h	2008-10-28 14:17:05 +0000
@@ -50,6 +50,7 @@ typedef struct st_tina_share {
   bool crashed;             /* Meta file is crashed */
   ha_rows rows_recorded;    /* Number of rows in tables */
   uint data_file_version;   /* Version of the data file used */
+  bool allow_log_delete;
 } TINA_SHARE;
 
 struct tina_set {

=== modified file 'storage/falcon/DeferredIndex.cpp'
--- a/storage/falcon/DeferredIndex.cpp	2008-10-16 02:53:35 +0000
+++ b/storage/falcon/DeferredIndex.cpp	2008-11-14 15:38:44 +0000
@@ -862,6 +862,10 @@ void DeferredIndex::chill(Dbb *dbb)
 	leaf->count = 0;
 	root = leaf;
 	count = 0;
+	minValue = NULL;
+	maxValue = NULL;
+	haveMinValue = true;
+	haveMaxValue = true;
 
 	Log::log(LogInfo, "%d: Index chill: transaction %ld, index %ld, %ld bytes, address %p, vofs %llx\n",
 				dbb->database->deltaTime, transaction->transactionId, index->indexId, sizeEstimate, this, virtualOffset);

=== modified file 'storage/falcon/Log.h'
--- a/storage/falcon/Log.h	2007-11-29 22:51:08 +0000
+++ b/storage/falcon/Log.h	2008-11-13 13:27:13 +0000
@@ -38,6 +38,9 @@ static const int	LogScrub		= 128;
 static const int	LogException	= 256;
 static const int	LogScavenge		= 512;
 static const int	LogXARecovery	= 1024;
+static const int	LogMysqlInfo		= 0x20000000;
+static const int	LogMysqlWarning		= 0x40000000;
+static const int	LogMysqlError		= 0x80000000;
 
 typedef void (Listener) (int, const char*, void *arg);
 

=== modified file 'storage/falcon/PageInventoryPage.cpp'
--- a/storage/falcon/PageInventoryPage.cpp	2008-06-17 17:41:54 +0000
+++ b/storage/falcon/PageInventoryPage.cpp	2008-11-14 02:30:11 +0000
@@ -31,6 +31,8 @@
 #include "Transaction.h"
 #include "Log.h"
 #include "SQLError.h"
+#include "SerialLog.h"
+#include "Database.h"
 
 #ifdef _DEBUG
 #undef THIS_FILE
@@ -80,6 +82,8 @@ Bdb* PageInventoryPage::createInventoryP
 
 Bdb* PageInventoryPage::allocPage(Dbb * dbb, PageType pageType, TransId transId)
 {
+	SerialLog *serialLog = dbb->database->serialLog;
+	ASSERT(!(serialLog->recovering && (serialLog->recoveryPhase ==2)));
 	for (int32 pip = dbb->lastPageAllocated / dbb->pagesPerPip;; ++pip)
 		{
 		int32 pipPageNumber = (pip == 0) ? PIP_PAGE : pip * dbb->pagesPerPip - 1;

=== modified file 'storage/falcon/SRLBlobDelete.h'
--- a/storage/falcon/SRLBlobDelete.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLBlobDelete.h	2008-11-14 02:30:11 +0000
@@ -29,8 +29,7 @@ public:
 	void pass2(void);
 	void redo(void);
 	void print(void);
-	
-	int		tableSpaceId;
+
 	int32	locatorPage;
 	int		locatorLine;
 	int32	dataPage;

=== modified file 'storage/falcon/SRLBlobUpdate.h'
--- a/storage/falcon/SRLBlobUpdate.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLBlobUpdate.h	2008-11-14 02:30:11 +0000
@@ -39,7 +39,6 @@ public:
 	virtual void	pass2(void);
 	virtual void	redo(void);
 
-	int			tableSpaceId;
 	int32		sectionId;
 	int32		locatorPage;
 	int			locatorLine;

=== modified file 'storage/falcon/SRLCreateIndex.h'
--- a/storage/falcon/SRLCreateIndex.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLCreateIndex.h	2008-11-14 02:30:11 +0000
@@ -38,7 +38,6 @@ public:
 	virtual void	read();
 	virtual void	commit(void);
 
-	int			tableSpaceId;
 	int32		indexId;
 	int			indexVersion;
 };

=== modified file 'storage/falcon/SRLCreateSection.h'
--- a/storage/falcon/SRLCreateSection.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLCreateSection.h	2008-11-14 02:30:11 +0000
@@ -39,7 +39,6 @@ public:
 	SRLCreateSection();
 	virtual ~SRLCreateSection();
 
-	int		tableSpaceId;
 	int		sectionId;
 };
 

=== modified file 'storage/falcon/SRLCreateTableSpace.cpp'
--- a/storage/falcon/SRLCreateTableSpace.cpp	2008-07-17 13:52:17 +0000
+++ b/storage/falcon/SRLCreateTableSpace.cpp	2008-11-14 02:30:11 +0000
@@ -85,14 +85,14 @@ void SRLCreateTableSpace::read()
 
 void SRLCreateTableSpace::pass1()
 {
-	TableSpaceInit tsInit;
-	tsInit.comment		= comment;
-	log->database->tableSpaceManager->redoCreateTableSpace(tableSpaceId, nameLength, name, filenameLength, filename, type, &tsInit);
+
 }
 
 void SRLCreateTableSpace::pass2()
 {
-
+	TableSpaceInit tsInit;
+	tsInit.comment		= comment;
+	log->database->tableSpaceManager->redoCreateTableSpace(tableSpaceId, nameLength, name, filenameLength, filename, type, &tsInit);
 }
 
 void SRLCreateTableSpace::commit()

=== modified file 'storage/falcon/SRLCreateTableSpace.h'
--- a/storage/falcon/SRLCreateTableSpace.h	2008-07-17 13:52:17 +0000
+++ b/storage/falcon/SRLCreateTableSpace.h	2008-11-14 02:30:11 +0000
@@ -44,7 +44,6 @@ public:
 
 	const char	*name;
 	const char	*filename;
-	int			tableSpaceId;
 	int			nameLength;
 	int			filenameLength;
 	int			type;

=== modified file 'storage/falcon/SRLData.h'
--- a/storage/falcon/SRLData.h	2007-10-16 19:40:17 +0000
+++ b/storage/falcon/SRLData.h	2008-11-14 02:30:11 +0000
@@ -44,7 +44,6 @@ public:
 	
 	void			append(Dbb *dbb, Transaction *transaction, int32 sectionId, int32 recordId, Stream *stream);
 
-	int			tableSpaceId;
 	int32		sectionId;
 	int32		recordId;
 	int32		length;

=== modified file 'storage/falcon/SRLDelete.h'
--- a/storage/falcon/SRLDelete.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLDelete.h	2008-11-14 02:30:11 +0000
@@ -40,7 +40,6 @@ public:
 	SRLDelete();
 	virtual ~SRLDelete();
 
-	int			tableSpaceId;
 	int32		sectionId;
 	int32		recordId;
 	int32		length;

=== modified file 'storage/falcon/SRLDeleteIndex.cpp'
--- a/storage/falcon/SRLDeleteIndex.cpp	2008-07-15 18:57:27 +0000
+++ b/storage/falcon/SRLDeleteIndex.cpp	2008-11-14 02:30:11 +0000
@@ -72,8 +72,14 @@ void SRLDeleteIndex::read()
 void SRLDeleteIndex::pass1()
 {
 	log->bumpIndexIncarnation(indexId, tableSpaceId, objDeleted);
-	Dbb *dbb = log->findDbb(tableSpaceId);
+}
+
+void SRLDeleteIndex::redo()
+{
+	if (!log->bumpIndexIncarnation(indexId, tableSpaceId, objDeleted))
+		return;
 
+	Dbb *dbb = log->findDbb(tableSpaceId);
 	if (!dbb)
 		return;
 		
@@ -92,12 +98,6 @@ void SRLDeleteIndex::pass1()
 		}
 }
 
-void SRLDeleteIndex::redo()
-{
-	if (!log->bumpIndexIncarnation(indexId, tableSpaceId, objDeleted))
-		return;
-}
-
 void SRLDeleteIndex::print()
 {
 	logPrint("Delete Index %d\n", indexId);

=== modified file 'storage/falcon/SRLDeleteIndex.h'
--- a/storage/falcon/SRLDeleteIndex.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLDeleteIndex.h	2008-11-14 02:30:11 +0000
@@ -38,7 +38,6 @@ public:
 	void			append(Dbb *dbb, TransId transId, int indexId, int idxVersion);
 	void			print();
 
-	int		tableSpaceId;
 	int32	indexId;
 	int		indexVersion;
 };

=== modified file 'storage/falcon/SRLDropTableSpace.cpp'
--- a/storage/falcon/SRLDropTableSpace.cpp	2008-06-08 22:12:35 +0000
+++ b/storage/falcon/SRLDropTableSpace.cpp	2008-11-14 02:30:11 +0000
@@ -63,14 +63,16 @@ void SRLDropTableSpace::read()
 		transactionId = 0;
 }
 
+
 void SRLDropTableSpace::pass1()
 {
-
+	log->setTableSpaceDropped(tableSpaceId);
 }
 
 void SRLDropTableSpace::pass2()
 {
 
+	log->tableSpaceManager->expungeTableSpace(tableSpaceId);
 }
 
 void SRLDropTableSpace::commit()
@@ -80,5 +82,4 @@ void SRLDropTableSpace::commit()
 
 void SRLDropTableSpace::redo()
 {
-	log->tableSpaceManager->expungeTableSpace(tableSpaceId);
 }

=== modified file 'storage/falcon/SRLDropTableSpace.h'
--- a/storage/falcon/SRLDropTableSpace.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLDropTableSpace.h	2008-11-14 02:30:11 +0000
@@ -42,7 +42,6 @@ public:
 	virtual void read();
 	void append (TableSpace *tableSpace, Transaction *transaction);
 
-	int		tableSpaceId;
 };
 
 #endif // !defined(AFX_SRLDROPTABLESPACE_H__3A416C47_6B8F_49CC_9471_B9F75D024B12__INCLUDED_)

=== modified file 'storage/falcon/SRLFreePage.h'
--- a/storage/falcon/SRLFreePage.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLFreePage.h	2008-11-14 02:30:11 +0000
@@ -41,7 +41,6 @@ public:
 	
 	void			append (Dbb *dbb, int32 pageNumber);
 
-	int			tableSpaceId;
 	int32		pageNumber;
 	int			incarnation;
 };

=== modified file 'storage/falcon/SRLIndexAdd.h'
--- a/storage/falcon/SRLIndexAdd.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLIndexAdd.h	2008-11-14 02:30:11 +0000
@@ -39,7 +39,6 @@ public:
 	SRLIndexAdd();
 	virtual ~SRLIndexAdd();
 
-	int			tableSpaceId;
 	int32		indexId;
 	int32		recordId;
 	int32		length;

=== modified file 'storage/falcon/SRLIndexDelete.h'
--- a/storage/falcon/SRLIndexDelete.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLIndexDelete.h	2008-11-14 02:30:11 +0000
@@ -38,7 +38,6 @@ public:
 	SRLIndexDelete();
 	virtual ~SRLIndexDelete();
 
-	int			tableSpaceId;
 	int32		indexId;
 	int32		recordId;
 	int32		length;

=== modified file 'storage/falcon/SRLIndexPage.h'
--- a/storage/falcon/SRLIndexPage.h	2008-02-13 18:45:15 +0000
+++ b/storage/falcon/SRLIndexPage.h	2008-11-14 02:30:11 +0000
@@ -38,7 +38,6 @@ public:
 	SRLIndexPage();
 	virtual ~SRLIndexPage();
 
-	int			tableSpaceId;
 	int			indexVersion;
 	int32		pageNumber;
 	int32		parent;

=== modified file 'storage/falcon/SRLInversionPage.h'
--- a/storage/falcon/SRLInversionPage.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLInversionPage.h	2008-11-14 02:30:11 +0000
@@ -38,7 +38,6 @@ public:
 	SRLInversionPage();
 	virtual ~SRLInversionPage();
 
-	int			tableSpaceId;
 	int32		pageNumber;
 	int32		parent;
 	int32		prior;

=== modified file 'storage/falcon/SRLOverflowPages.h'
--- a/storage/falcon/SRLOverflowPages.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLOverflowPages.h	2008-11-14 02:30:11 +0000
@@ -32,7 +32,6 @@ public:
 	virtual void	redo(void);
 	virtual void	print(void);
 	
-	int				tableSpaceId;
 	int				dataLength;
 	const UCHAR*	data;
 };

=== modified file 'storage/falcon/SRLRecordLocator.h'
--- a/storage/falcon/SRLRecordLocator.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLRecordLocator.h	2008-11-14 02:30:11 +0000
@@ -39,7 +39,6 @@ public:
 	SRLRecordLocator();
 	virtual ~SRLRecordLocator();
 
-	int		tableSpaceId;
 	int		sectionId;
 	int		sequence;
 	int32	pageNumber;

=== modified file 'storage/falcon/SRLRecordStub.h'
--- a/storage/falcon/SRLRecordStub.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLRecordStub.h	2008-11-14 02:30:11 +0000
@@ -37,7 +37,6 @@ public:
 	SRLRecordStub();
 	virtual ~SRLRecordStub();
 
-	int		tableSpaceId;
 	int32	sectionId;
 	int32	recordId;
 

=== modified file 'storage/falcon/SRLSectionLine.h'
--- a/storage/falcon/SRLSectionLine.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLSectionLine.h	2008-11-14 02:30:11 +0000
@@ -31,7 +31,6 @@ public:
 	virtual void redo(void);
 	virtual void print(void);
 
-	int		tableSpaceId;
 	int32	pageNumber;
 	int32	dataPageNumber;
 };

=== modified file 'storage/falcon/SRLSectionPage.h'
--- a/storage/falcon/SRLSectionPage.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLSectionPage.h	2008-11-14 02:30:11 +0000
@@ -38,7 +38,6 @@ public:
 	SRLSectionPage();
 	virtual ~SRLSectionPage();
 
-	int		tableSpaceId;
 	int32	parentPage;
 	int32	pageNumber;
 	int		sectionSlot;

=== modified file 'storage/falcon/SRLSectionPromotion.h'
--- a/storage/falcon/SRLSectionPromotion.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLSectionPromotion.h	2008-11-14 02:30:11 +0000
@@ -30,7 +30,6 @@ public:
 	virtual void	pass2(void);
 	virtual void	redo(void);
 	
-	int			tableSpaceId;
 	int			sectionId;
 	int			length;
 	int32		rootPageNumber;

=== modified file 'storage/falcon/SRLSequencePage.h'
--- a/storage/falcon/SRLSequencePage.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLSequencePage.h	2008-11-14 02:30:11 +0000
@@ -30,7 +30,6 @@ public:
 	virtual void redo(void);
 	
 	int		pageSequence;
-	int		tableSpaceId;
 	int32	pageNumber;
 	virtual void print(void);
 };

=== modified file 'storage/falcon/SRLUpdateBlob.h'
--- a/storage/falcon/SRLUpdateBlob.h	2007-10-16 19:40:17 +0000
+++ b/storage/falcon/SRLUpdateBlob.h	2008-11-14 02:30:11 +0000
@@ -35,7 +35,6 @@ public:
 	
 	const UCHAR		*data;
 	int			recordNumber;
-	int			tableSpaceId;
 	int			length;
 	int			sectionId;
 };

=== modified file 'storage/falcon/SRLUpdateIndex.cpp'
--- a/storage/falcon/SRLUpdateIndex.cpp	2008-11-11 22:33:27 +0000
+++ b/storage/falcon/SRLUpdateIndex.cpp	2008-11-14 15:38:44 +0000
@@ -60,14 +60,16 @@ void SRLUpdateIndex::append(DeferredInde
 	uint64 virtualOffset = 0;
 	uint64 virtualOffsetAtEnd = 0;
 
-	// Save the absolute offset of the DeferredIndex record within the serial log
-
-	virtualOffset = log->writeWindow->getNextVirtualOffset();
-
 	for (DINode *node = walker.next(); node;)
 		{
 		START_RECORD(srlUpdateIndex, "SRLUpdateIndex::append(2)");
 		
+		// Save the absolute offset of the DeferredIndex record within the serial log.
+		// This must be done inside the SerialLog::syncWrite lock set by START_RECORD().
+
+		if (virtualOffset == 0)
+			virtualOffset = log->startRecordVirtualOffset;
+
 		log->updateIndexUseVector(indexId, tableSpaceId, 1);
 		SerialLogTransaction *srlTrans = log->getTransaction(transaction->transactionId);
 		srlTrans->setTransaction(transaction);
@@ -238,9 +240,9 @@ void SRLUpdateIndex::thaw(DeferredIndex*
 {
 	Sync sync(&log->syncWrite, "SRLUpdateIndex::thaw");
 	sync.lock(Exclusive);
+
 	uint64 virtualOffset = deferredIndex->virtualOffset;
 	int recordNumber = 0;  // a valid record number to get into the loop.
-	ASSERT(deferredIndex->virtualOffset);
 	Transaction *trans = deferredIndex->transaction;
 	TransId transId = trans->transactionId;
 	indexId = deferredIndex->index->indexId;
@@ -255,7 +257,7 @@ void SRLUpdateIndex::thaw(DeferredIndex*
 	
 	if (window == NULL)
 		{
-		Log::log("A window for DeferredIndex::virtualOffset=" I64FORMAT " could not be found.\n", deferredIndex->virtualOffset);
+		Log::log("Index thaw FAIL: A window for DeferredIndex::virtualOffset=" I64FORMAT " could not be found.\n", deferredIndex->virtualOffset);
 		log->printWindows();
 		return;
 		}
@@ -302,7 +304,10 @@ void SRLUpdateIndex::thaw(DeferredIndex*
 	if (srlRecord && srlRecord->type == srlVersion)
 		srlRecord = control->nextRecord();
 		
-	ASSERT(srlRecord->type == srlUpdateIndex);
+	if (srlRecord)
+		ASSERT(srlRecord->type == srlUpdateIndex);
+	else
+		Log::log("Index thaw FAIL: SRLUpdateIndex record not found. DeferredIndex::virtualOffset=" I64FORMAT "\n", deferredIndex->virtualOffset);
 	
 	// The DeferredIndex may reside in several serial log records. Read each record and
 	// rebuild the index from the nodes stored within the record.

=== modified file 'storage/falcon/SRLUpdateIndex.h'
--- a/storage/falcon/SRLUpdateIndex.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/SRLUpdateIndex.h	2008-11-14 02:30:11 +0000
@@ -39,7 +39,6 @@ public:
 	void			append(DeferredIndex* deferredIndex);
 	void			thaw(DeferredIndex* deferredIndex);
 
-	int				tableSpaceId;
 	int				indexId;
 	const UCHAR		*data;
 	const UCHAR		*ptr;

=== modified file 'storage/falcon/SRLUpdateRecords.cpp'
--- a/storage/falcon/SRLUpdateRecords.cpp	2008-11-09 01:44:58 +0000
+++ b/storage/falcon/SRLUpdateRecords.cpp	2008-11-19 17:00:02 +0000
@@ -76,6 +76,9 @@ int SRLUpdateRecords::thaw(RecordVersion
 	if (!window)
 		return 0;
 		
+	Sync sync(&log->syncWrite, "SRLUpdateRecords::thaw");
+	sync.lock(Exclusive);
+	
 	// Return pointer to record data
 
 	control->input = window->buffer + (record->getVirtualOffset() - window->virtualOffset);
@@ -84,24 +87,25 @@ int SRLUpdateRecords::thaw(RecordVersion
 	// Get section id, record id and data length written. Input pointer will be at
 	// beginning of record data.
 
-	int tableSpaceId = 0;
+	int recordTableSpaceId = 0;
 	
 	if (control->version >= srlVersion8)
-		tableSpaceId = control->getInt();
+		recordTableSpaceId = control->getInt();
 		
 	control->getInt();			// sectionId
 	int recordNumber = control->getInt();
 	int dataLength   = control->getInt();
 	int bytesReallocated = 0;
 	
+	window->deactivateWindow();
+	sync.unlock();
+	
 	// setRecordData() handles race conditions with an interlocked compare and exchange,
 	// but check the state and record number anyway
 
 	if (record->state == recChilled && recordNumber == record->recordNumber)
 		bytesReallocated = record->setRecordData(control->input, dataLength);
 
-	window->deactivateWindow();
-
 	if (bytesReallocated > 0)
 		{
 		ASSERT(recordNumber == record->recordNumber);
@@ -179,7 +183,7 @@ void SRLUpdateRecords::append(Transactio
 				break;
 	
 			Table *table = record->format->table;
-			tableSpaceId = table->dbb->tableSpaceId;
+			int recordTableSpaceId = table->dbb->tableSpaceId;
 			Stream stream;
 			
 			// A non-zero virtual offset indicates that the record was previously
@@ -227,7 +231,7 @@ void SRLUpdateRecords::append(Transactio
 			// Ensure record fits within current window
 
 			if (log->writePtr + 
-				 byteCount(tableSpaceId) + 
+				 byteCount(recordTableSpaceId) + 
 				 byteCount(table->dataSectionId) + 
 				 byteCount(record->recordNumber) + 
 				 byteCount(stream.totalLength) + stream.totalLength >= end)
@@ -240,9 +244,9 @@ void SRLUpdateRecords::append(Transactio
 
 			record->setVirtualOffset(log->writeWindow->currentLength + log->writeWindow->virtualOffset);
 			uint32 sectionId = table->dataSectionId;
-			log->updateSectionUseVector(sectionId, tableSpaceId, 1);
+			log->updateSectionUseVector(sectionId, recordTableSpaceId, 1);
 			
-			putInt(tableSpaceId);
+			putInt(recordTableSpaceId);
 			putInt(record->getPriorVersion() ? sectionId : -(int) sectionId - 1);
 			putInt(record->recordNumber);
 			putStream(&stream);
@@ -303,23 +307,25 @@ void SRLUpdateRecords::redo(void)
 	if (transaction->state == sltCommitted)
 		for (const UCHAR *p = data, *end = data + dataLength; p < end;)
 			{
+			int recordTableSpaceId;
 			if (control->version >= srlVersion8)
-				tableSpaceId = getInt(&p);
+				recordTableSpaceId = getInt(&p);
 			else
-				tableSpaceId = 0;
+				recordTableSpaceId = 0;
 		
 			int id = getInt(&p);
 			uint sectionId = (id >= 0) ? id : -id - 1;
 			int recordNumber = getInt(&p);
 			int length = getInt(&p);
-			log->updateSectionUseVector(sectionId, tableSpaceId, -1);
+			log->updateSectionUseVector(sectionId, recordTableSpaceId, -1);
 
 			if (log->traceRecord && recordNumber == log->traceRecord)
 				print();
 					
-			if (log->bumpSectionIncarnation(sectionId, tableSpaceId, objInUse))
+			if (log->bumpSectionIncarnation(sectionId, recordTableSpaceId, objInUse)
+				&& (!log->isTableSpaceDropped(recordTableSpaceId)))
 				{
-				Dbb *dbb = log->getDbb(tableSpaceId);
+				Dbb *dbb = log->getDbb(recordTableSpaceId);
 				
 				if (length)
 					{
@@ -346,16 +352,20 @@ void SRLUpdateRecords::pass1(void)
 
 	for (const UCHAR *p = data, *end = data + dataLength; p < end;)
 		{
+		int recordTableSpaceId;
 		if (control->version >= srlVersion8)
-			tableSpaceId = getInt(&p);
+			recordTableSpaceId = getInt(&p);
 		else
-			tableSpaceId = 0;
-			
+			recordTableSpaceId = 0;
+
 		int id = getInt(&p);
 		uint sectionId = (id >= 0) ? id : -id - 1;
 		getInt(&p);			// recordNumber
 		int length = getInt(&p);
-		log->bumpSectionIncarnation(sectionId, tableSpaceId, objInUse);
+
+		if (!log->isTableSpaceDropped(recordTableSpaceId))
+			log->bumpSectionIncarnation(sectionId, recordTableSpaceId, objInUse);
+
 		p += length;
 		}
 }
@@ -380,20 +390,21 @@ void SRLUpdateRecords::commit(void)
 	
 	for (const UCHAR *p = data, *end = data + dataLength; p < end;)
 		{
+		int recordTableSpaceId;
 		if (control->version >= srlVersion8)
-			tableSpaceId = getInt(&p);
+			recordTableSpaceId = getInt(&p);
 		else
-			tableSpaceId = 0;
+			recordTableSpaceId = 0;
 			
 		int id = getInt(&p);
 		uint sectionId = (id >= 0) ? id : -id - 1;
 		int recordNumber = getInt(&p);
 		int length = getInt(&p);
-		log->updateSectionUseVector(sectionId, tableSpaceId, -1);
+		log->updateSectionUseVector(sectionId, recordTableSpaceId, -1);
 		
-		if (log->isSectionActive(sectionId, tableSpaceId))
+		if (log->isSectionActive(sectionId, recordTableSpaceId))
 			{
-			Dbb *dbb = log->getDbb(tableSpaceId);
+			Dbb *dbb = log->getDbb(recordTableSpaceId);
 
 			if (length)
 				{
@@ -415,10 +426,11 @@ void SRLUpdateRecords::print(void)
 	
 	for (const UCHAR *p = data, *end = data + dataLength; p < end;)
 		{
+		int recordTableSpaceId;
 		if (control->version >= srlVersion8)
-			tableSpaceId = getInt(&p);
+			recordTableSpaceId = getInt(&p);
 		else
-			tableSpaceId = 0;
+			recordTableSpaceId = 0;
 
 		int id = getInt(&p);
 		uint sectionId = (id >= 0) ? id : -id - 1;
@@ -426,7 +438,7 @@ void SRLUpdateRecords::print(void)
 		int length = getInt(&p);
 		char temp[40];
 		Log::debug("   rec %d, len %d to section %d/%d %s\n", 
-					recordNumber, length, sectionId, tableSpaceId, format(length, p, sizeof(temp), temp));
+					recordNumber, length, sectionId, recordTableSpaceId, format(length, p, sizeof(temp), temp));
 		p += length;
 		}
 }

=== modified file 'storage/falcon/SRLUpdateRecords.h'
--- a/storage/falcon/SRLUpdateRecords.h	2008-02-14 21:06:10 +0000
+++ b/storage/falcon/SRLUpdateRecords.h	2008-11-14 02:30:11 +0000
@@ -37,7 +37,6 @@ public:
 	int				thaw(RecordVersion *record, bool *thawed);
 	
 	const UCHAR		*data;
-	int				tableSpaceId;
 	int				savepointId;
 	int				dataLength;
 };

=== modified file 'storage/falcon/SerialLog.cpp'
--- a/storage/falcon/SerialLog.cpp	2008-10-30 00:22:54 +0000
+++ b/storage/falcon/SerialLog.cpp	2008-11-19 17:00:02 +0000
@@ -131,6 +131,7 @@ SerialLog::SerialLog(Database *db, JStri
 	gophers = NULL;
 	wantToSerializeGophers = 0;
 	serializeGophers = 0;
+	startRecordVirtualOffset = 0;
 	
 	for (uint n = 0; n < falcon_gopher_threads; ++n)
 		{
@@ -344,7 +345,8 @@ void SerialLog::recover()
 	// Next, make a second pass to reallocate any necessary pages
 
 	while ( (record = control.nextRecord()) )
-		record->pass2();
+		if (!isTableSpaceDropped(record->tableSpaceId) || record->type == srlDropTableSpace)
+			record->pass2();
 
 	recoveryPages->reset();
 	recoveryIndexes->reset();
@@ -362,8 +364,10 @@ void SerialLog::recover()
 	// Make a third pass doing things
 
 	while ( (record = control.nextRecord()) )
-		record->redo();
-		
+		if (!isTableSpaceDropped(record->tableSpaceId))
+			record->redo();
+
+
 	for (SerialLogTransaction *action, **ptr = &running.first; (action = *ptr);)
 		if (action->completedRecovery())
 			{
@@ -400,6 +404,7 @@ void SerialLog::recover()
 	recoveryPages = NULL;
 	recoveryIndexes = NULL;
 	recoverySections = NULL;
+	droppedTablespaces.clear();
 	
 	for (window = firstWindow; window; window = window->next)
 		if (!(window->inUse == 0 || window == writeWindow))
@@ -711,6 +716,8 @@ void SerialLog::startRecord()
 	if (writeError)
 		throw SQLError(IO_ERROR_SERIALLOG, "Previous I/O error on serial log prevents further processing");
 
+	startRecordVirtualOffset = writeWindow->getNextVirtualOffset();
+	
 	if (writePtr == writeBlock->data)
 		putVersion();
 
@@ -1150,7 +1157,7 @@ bool SerialLog::bumpPageIncarnation(int3
 
 	bool ret = recoveryPages->bumpIncarnation(pageNumber, tableSpaceId, state, pass1);
 	
-	if (ret && pass1)
+	if (ret && recoveryPhase==2)
 		{
 		Dbb *dbb = getDbb(tableSpaceId);
 		dbb->reallocPage(pageNumber);
@@ -1285,6 +1292,18 @@ void SerialLog::setIndexInactive(int id,
 	recoveryIndexes->setInactive(id, tableSpaceId);
 }
 
+void SerialLog::setTableSpaceDropped(int tableSpaceId)
+{
+	ASSERT(recovering);
+	droppedTablespaces.set(tableSpaceId);
+}
+
+bool SerialLog::isTableSpaceDropped(int tableSpaceId)
+{
+	ASSERT(recovering);
+	return droppedTablespaces.isSet(tableSpaceId);
+}
+
 bool SerialLog::sectionInUse(int sectionId, int tableSpaceId)
 {
 	TableSpaceInfo *info = getTableSpaceInfo(tableSpaceId);
@@ -1461,6 +1480,7 @@ void SerialLog::printWindows(void)
 
 Dbb* SerialLog::getDbb(int tableSpaceId)
 {
+	ASSERT(recoveryPhase != 1);
 	if (tableSpaceId == 0)
 		return defaultDbb;
 		
@@ -1469,6 +1489,7 @@ Dbb* SerialLog::getDbb(int tableSpaceId)
 
 Dbb* SerialLog::findDbb(int tableSpaceId)
 {
+	ASSERT(recoveryPhase != 1);
 	if (tableSpaceId == 0)
 		return defaultDbb;
 	

=== modified file 'storage/falcon/SerialLog.h'
--- a/storage/falcon/SerialLog.h	2008-10-20 21:28:11 +0000
+++ b/storage/falcon/SerialLog.h	2008-11-19 17:00:02 +0000
@@ -29,6 +29,7 @@
 #include "Stack.h"
 #include "DenseArray.h"
 #include "Queue.h"
+#include "Bitmap.h"
 
 static const unsigned int altLogFlag	= 0x80000000;
 static const int srlSignature			= 123456789;
@@ -126,6 +127,8 @@ public:
 	void			setSectionInactive(int id, int tableSpaceId);
 	void			setIndexActive(int id, int tableSpaceId);
 	void			setIndexInactive(int id, int tableSpaceId);
+	void			setTableSpaceDropped(int tableSpaceId);
+	bool			isTableSpaceDropped(int tableSpaceId);
 	void			updateSectionUseVector(uint sectionId, int tableSpaceId, int delta);
 	void			updateIndexUseVector(uint indexId, int tableSpaceId, int delta);
 	bool			sectionInUse(int sectionId, int tableSpaceId);
@@ -170,6 +173,7 @@ public:
 	RecoveryObjects		*recoveryPages;
 	RecoveryObjects		*recoverySections;
 	RecoveryObjects		*recoveryIndexes;
+	Bitmap				droppedTablespaces;
 	Dbb					*defaultDbb;
 	Gopher				*gophers;
 	Thread				*srlQueue;
@@ -224,6 +228,7 @@ public:
 	uint64				chilledBytes;
 	int32				wantToSerializeGophers;
 	int32				serializeGophers;
+	uint64				startRecordVirtualOffset;
 
 	TableSpaceInfo		*tableSpaces[SLT_HASH_SIZE];
 	TableSpaceInfo		*tableSpaceInfo;

=== modified file 'storage/falcon/SerialLogRecord.cpp'
--- a/storage/falcon/SerialLogRecord.cpp	2008-11-11 22:33:27 +0000
+++ b/storage/falcon/SerialLogRecord.cpp	2008-11-14 02:30:11 +0000
@@ -100,6 +100,7 @@ int init()
 SerialLogRecord::SerialLogRecord()
 {
 	transactionId = 0;
+	tableSpaceId = 0;
 	type = 0;
 }
 
@@ -268,6 +269,8 @@ SerialLogTransaction* SerialLogRecord::g
 	return transaction;
 }
 
+
+
 void SerialLogRecord::pass1()
 {
 
@@ -323,3 +326,4 @@ void SerialLogRecord::logPrint(const cha
 	else
 		printf("Log %s", temp);
 }
+

=== modified file 'storage/falcon/SerialLogRecord.h'
--- a/storage/falcon/SerialLogRecord.h	2008-11-11 22:33:27 +0000
+++ b/storage/falcon/SerialLogRecord.h	2008-11-14 02:30:11 +0000
@@ -111,6 +111,7 @@ public:
 	SerialLog			*log;
 	SerialLogControl	*control;
 	TransId				transactionId;
+	int					tableSpaceId;
 	UCHAR				type;
 };
 

=== modified file 'storage/falcon/StorageHandler.cpp'
--- a/storage/falcon/StorageHandler.cpp	2008-10-31 10:13:58 +0000
+++ b/storage/falcon/StorageHandler.cpp	2008-11-13 13:27:13 +0000
@@ -998,6 +998,8 @@ void StorageHandler::initialize(void)
 
 		try
 			{
+			Log::log(LogMysqlInfo, "Falcon: unable to open system data files.");
+			Log::log(LogMysqlInfo, "Falcon: creating new system data files.");
 			createDatabase();
 			}
 		catch(SQLException &e2)

=== modified file 'storage/falcon/StorageVersion.h'
--- a/storage/falcon/StorageVersion.h	2008-11-13 14:35:58 +0000
+++ b/storage/falcon/StorageVersion.h	2008-11-14 16:02:16 +0000
@@ -14,5 +14,5 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 
-#define FALCON_VERSION	"T1.3-4"
-#define FALCON_DATE		"13 November, 2008"
+#define FALCON_VERSION	"T1.3-5"
+#define FALCON_DATE		"14 November, 2008"

=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp	2008-11-05 14:51:37 +0000
+++ b/storage/falcon/ha_falcon.cpp	2008-11-16 11:30:45 +0000
@@ -35,6 +35,7 @@
 #include "InfoTable.h"
 #include "Format.h"
 #include "Error.h"
+#include "Log.h"
 
 #ifdef _WIN32
 #define I64FORMAT			"%I64d"
@@ -181,8 +182,8 @@ int StorageInterface::falcon_init(void *
 
 	if (!checkExceptionSupport()) 
 		{
-		sql_print_error("Falcon must be compiled with C++ exceptions enabled to work");
-		DBUG_RETURN(1);
+		sql_print_error("Falcon must be compiled with C++ exceptions enabled to work. Please adjust your compile flags.");
+		FATAL("Falcon exiting process.\n");
 		}
 
 	StorageHandler::setDataDirectory(mysql_real_data_home);
@@ -227,7 +228,9 @@ int StorageInterface::falcon_init(void *
 	falcon_hton->fill_is_table = StorageInterface::fill_is_table;
 	//falcon_hton->show_status  = StorageInterface::show_status;
 	falcon_hton->flags = HTON_NO_FLAGS;
+	falcon_debug_mask&= ~(LogMysqlInfo|LogMysqlWarning|LogMysqlError);
 	storageHandler->addNfsLogger(falcon_debug_mask, StorageInterface::logger, NULL);
+	storageHandler->addNfsLogger(LogMysqlInfo|LogMysqlWarning|LogMysqlError, StorageInterface::mysqlLogger, NULL);
 
 	if (falcon_debug_server)
 		storageHandler->startNfsServer();
@@ -536,6 +539,10 @@ int StorageInterface::open(const char *n
 
 	int ret = storageTable->open();
 
+	if (ret == StorageErrorTableNotFound)
+		sql_print_error("Server is attempting to access a table %s,\n"
+				"which doesn't exist in Falcon.", name);
+
 	if (ret)
 		DBUG_RETURN(error(ret));
 
@@ -1025,6 +1032,10 @@ int StorageInterface::delete_table(const
 	storageTable->deleteStorageTable();
 	storageTable = NULL;
 
+	if (res == StorageErrorTableNotFound)
+		sql_print_error("Server is attempting to drop a table %s,\n"
+				"which doesn't exist in Falcon.", tableName);
+
 	// (hk) Fix for Bug#31465 Running Falcon test suite leads
 	//                        to warnings about temp tables
 	// This fix could affect other DROP TABLE scenarios.
@@ -2401,6 +2412,16 @@ void StorageInterface::logger(int mask, 
 		}
 }
 
+void StorageInterface::mysqlLogger(int mask, const char* text, void* arg)
+{
+	if (mask & LogMysqlError)
+		sql_print_error("%s", text);
+	else if (mask & LogMysqlWarning)
+		sql_print_warning("%s", text);
+	else if (mask & LogMysqlInfo)
+		sql_print_information("%s", text);
+}
+
 int StorageInterface::setIndex(TABLE *table, int indexId)
 {
 	StorageIndexDesc indexDesc;
@@ -3520,6 +3541,7 @@ void StorageInterface::updateRecordScave
 void StorageInterface::updateDebugMask(MYSQL_THD thd, struct st_mysql_sys_var* variable, void* var_ptr, const void* save)
 {
 	falcon_debug_mask = *(uint*) save;
+	falcon_debug_mask&= ~(LogMysqlInfo|LogMysqlWarning|LogMysqlError);
 	storageHandler->deleteNfsLogger(StorageInterface::logger, NULL);
 	storageHandler->addNfsLogger(falcon_debug_mask, StorageInterface::logger, NULL);
 }

=== modified file 'storage/falcon/ha_falcon.h'
--- a/storage/falcon/ha_falcon.h	2008-10-22 20:44:09 +0000
+++ b/storage/falcon/ha_falcon.h	2008-11-13 13:27:13 +0000
@@ -150,6 +150,7 @@ public:
 	static void		shutdown(handlerton *);
 	static int		closeConnection(handlerton *, THD *thd);
 	static void		logger(int mask, const char *text, void *arg);
+	static void		mysqlLogger(int mask, const char *text, void *arg);
 	static int		panic(handlerton* hton, ha_panic_function flag);
 	//static bool	show_status(handlerton* hton, THD* thd, stat_print_fn* print, enum ha_stat_type stat);
 	static int		getMySqlError(int storageError);

Thread
bzr commit into mysql-6.0-falcon-team branch (klewis:2913) Kevin Lewis20 Nov