List:Commits« Previous MessageNext Message »
From:Chuck Bell Date:August 20 2009 7:53pm
Subject:bzr commit into mysql-6.0-backup branch (charles.bell:2862) WL#4722
View as plain text  
#At file:///Users/cbell/source/bzr/mysql-6.0-wl-4722/ based on revid:charles.bell@stripped

 2862 Chuck Bell	2009-08-20 [merge]
      WL#4722 : Identify methods for testing failure classes
      
      Problem: Currently, only 35% of of the backup error messages are covered in
      the suite of backup tests. 
      
      This patch adds about 70 test cases using debug and error code insertion to
      allow for 100% coverage of backup error messages.
     @ mysql-test/suite/backup/include/basic_data.inc
        New include file for common database creation and population.
     @ mysql-test/suite/backup/include/error_name_to_number.inc
        New error number mapping for backup debug and error code insertion tests.
        Note: This is needed until BUG#46528 is fixed.
     @ mysql-test/suite/backup/include/test_for_error.inc
        This is the main test run for the debug and error code insertion tests.
        It is parameterized to allow execution of either backup or restore with
        debug active then again without debug to demonstrate debug code has not
        changed the behavior.
     @ mysql-test/suite/backup/r/backup_errors_debug_1.result
        New result file.
     @ mysql-test/suite/backup/r/backup_errors_debug_2.result
        New result file.
     @ mysql-test/suite/backup/r/backup_errors_debug_3.result
        New result file.
     @ mysql-test/suite/backup/r/backup_logs.result
        Corrected result file.
     @ mysql-test/suite/backup/r/backup_security.result
        Corrected result file.
     @ mysql-test/suite/backup/t/backup_errors_debug_1.test
        New test file (part ` of 3) for testing error messages using debug and
        error code insertion.
     @ mysql-test/suite/backup/t/backup_errors_debug_2.test
        New test file (part 2 of 3) for testing error messages using debug and
        error code insertion.
     @ mysql-test/suite/backup/t/backup_errors_debug_3.test
        New test file (part 3 of 3) for testing error messages using debug and
        error code insertion.
     @ mysql-test/suite/backup/t/backup_logs.test
        Added test cases for log path errors.
     @ mysql-test/suite/backup/t/backup_security.test
        Reworked test to use common database setup.
     @ sql/backup/backup_info.cc
        Added debug insertion and error condition insertion code for 
        error message testing.
     @ sql/backup/be_native.h
        Added debug insertion and error condition insertion code for 
        error message testing.
     @ sql/backup/data_backup.cc
        Added debug insertion and error condition insertion code for 
        error message testing.
     @ sql/backup/kernel.cc
        Added debug insertion and error condition insertion code for 
        error message testing.
     @ sql/backup/logger.cc
        Added debug insertion and error condition insertion code for 
        error message testing.
     @ sql/backup/stream.cc
        Added debug insertion and error condition insertion code for 
        error message testing.
     @ sql/backup/stream_v1.h
        Added new value for error conditions.
     @ sql/log.cc
        Added debug insertion and error condition insertion code for 
        error message testing.
     @ sql/set_var.cc
        Removed path from error message to allow cross-platform reporting.
     @ sql/share/errmsg-utf8.txt
        Removed path from message to allow cross-platform error reporting.
     @ sql/share/errmsg.txt
        Removed path from message to allow cross-platform error reporting.

    added:
      mysql-test/suite/backup/include/basic_data.inc
      mysql-test/suite/backup/include/error_name_to_number.inc
      mysql-test/suite/backup/include/test_for_error.inc
      mysql-test/suite/backup/r/backup_errors_debug_1.result
      mysql-test/suite/backup/r/backup_errors_debug_2.result
      mysql-test/suite/backup/r/backup_errors_debug_3.result
      mysql-test/suite/backup/t/backup_errors_debug_1.test
      mysql-test/suite/backup/t/backup_errors_debug_2.test
      mysql-test/suite/backup/t/backup_errors_debug_3.test
    modified:
      mysql-test/suite/backup/r/backup_logs.result
      mysql-test/suite/backup/r/backup_security.result
      mysql-test/suite/backup/t/backup_logs.test
      mysql-test/suite/backup/t/backup_security.test
      sql/backup/backup_info.cc
      sql/backup/be_native.h
      sql/backup/data_backup.cc
      sql/backup/kernel.cc
      sql/backup/logger.cc
      sql/backup/stream.cc
      sql/backup/stream_v1.h
      sql/log.cc
      sql/set_var.cc
      sql/share/errmsg-utf8.txt
      sql/share/errmsg.txt
=== added file 'mysql-test/suite/backup/include/basic_data.inc'
--- a/mysql-test/suite/backup/include/basic_data.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/basic_data.inc	2009-08-09 21:33:03 +0000
@@ -0,0 +1,47 @@
+#
+# This include file is created to provide a simple database and
+# data to be used in testing backup. It contains at least one
+# object in the database.
+#
+# NOTICE: The caller is responsible for creating and deleting
+#         the database 'backup_test'.
+#
+
+--echo #
+--echo # Create database and data to test.
+--echo #
+CREATE DATABASE backup_test;
+CREATE TABLE backup_test.t1 (a char(30)) ENGINE=MEMORY;
+INSERT INTO backup_test.t1 VALUES ("01 Test Basic database example"); 
+INSERT INTO backup_test.t1 VALUES ("02 Test Basic database example"); 
+INSERT INTO backup_test.t1 VALUES ("03 Test Basic database example"); 
+INSERT INTO backup_test.t1 VALUES ("04 Test Basic database example"); 
+INSERT INTO backup_test.t1 VALUES ("05 Test Basic database example"); 
+INSERT INTO backup_test.t1 VALUES ("06 Test Basic database example"); 
+INSERT INTO backup_test.t1 VALUES ("07 Test Basic database example"); 
+
+CREATE TABLE backup_test.t2 (a char(30)) ENGINE=MYISAM;
+INSERT INTO backup_test.t2 VALUES ("11 Test Basic database example"); 
+INSERT INTO backup_test.t2 VALUES ("12 Test Basic database example"); 
+INSERT INTO backup_test.t2 VALUES ("13 Test Basic database example"); 
+
+--echo #
+--echo # Now create more database objects for test.
+--echo #
+CREATE PROCEDURE backup_test.p1(p1 CHAR(20))
+  INSERT INTO backup_test.t1 VALUES ("50");
+
+CREATE TRIGGER backup_test.trg AFTER INSERT ON backup_test.t1 FOR EACH ROW
+ INSERT INTO backup_test.t1 VALUES('Test objects count');
+
+CREATE FUNCTION backup_test.f1() RETURNS INT RETURN (SELECT 1);
+
+CREATE VIEW backup_test.v1 as SELECT * FROM backup_test.t1;
+
+CREATE EVENT backup_test.e1 ON SCHEDULE EVERY 1 YEAR DO
+  DELETE FROM backup_test.t1 WHERE a = "not there";
+
+--echo #
+--echo # Now we need some privileges
+--echo #
+GRANT ALL ON backup_test.* TO 'joe'@'user';

=== added file 'mysql-test/suite/backup/include/error_name_to_number.inc'
--- a/mysql-test/suite/backup/include/error_name_to_number.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/error_name_to_number.inc	2009-08-09 21:33:03 +0000
@@ -0,0 +1,129 @@
+# Change and error name to its number value.
+
+--LET $ER_GET_ERRMSG = 1296
+--LET $ER_BACKUP_ACCESS_DBS_INCOMPLETE = 1793
+--LET $ER_BACKUP_ACCESS_DENIED_ERROR = 1791
+--LET $ER_BACKUP_ACCESS_OBJS_INCOMPLETE = 1794
+--LET $ER_BACKUP_BACKUP = 1647
+--LET $ER_BACKUP_BACKUP_DBS = 1770
+--LET $ER_BACKUP_BACKUP_DONE = 1642
+--LET $ER_BACKUP_BACKUP_PREPARE = 1650
+--LET $ER_BACKUP_BACKUP_START = 1641
+--LET $ER_BACKUP_BAD_MAGIC = 1713
+--LET $ER_BACKUP_BINLOG = 1758
+--LET $ER_BACKUP_CANCEL_BACKUP = 1682
+--LET $ER_BACKUP_CANCEL_RESTORE = 1683
+--LET $ER_BACKUP_CANNOT_INCLUDE_DB = 1646
+--LET $ER_BACKUP_CANT_FIND_SE = 1693
+--LET $ER_BACKUP_CANT_RESTORE_DB = 1697
+--LET $ER_BACKUP_CANT_RESTORE_EVENT = 1701
+--LET $ER_BACKUP_CANT_RESTORE_PRIV = 1751
+--LET $ER_BACKUP_CANT_RESTORE_SROUT = 1700
+--LET $ER_BACKUP_CANT_RESTORE_TABLE = 1698
+--LET $ER_BACKUP_CANT_RESTORE_TRIGGER = 1702
+--LET $ER_BACKUP_CANT_RESTORE_TS = 1736
+--LET $ER_BACKUP_CANT_RESTORE_VIEW = 1699
+--LET $ER_BACKUP_CAT_ENUM = 1735
+--LET $ER_BACKUP_CATALOG_ADD_DB = 1703
+--LET $ER_BACKUP_CATALOG_ADD_EVENT = 1707
+--LET $ER_BACKUP_CATALOG_ADD_PRIV = 1749
+--LET $ER_BACKUP_CATALOG_ADD_SROUT = 1706
+--LET $ER_BACKUP_CATALOG_ADD_TABLE = 1704
+--LET $ER_BACKUP_CATALOG_ADD_TRIGGER = 1708
+--LET $ER_BACKUP_CATALOG_ADD_TS = 1740
+--LET $ER_BACKUP_CATALOG_ADD_VIEW = 1705
+--LET $ER_BACKUP_CLOSE = 1757
+--LET $ER_BACKUP_CONTEXT_CREATE = 1714
+--LET $ER_BACKUP_CONTEXT_REMOVE = 1715
+--LET $ER_BACKUP_CREATE_BACKUP_DRIVER = 1665
+--LET $ER_BACKUP_CREATE_BE = 1727
+--LET $ER_BACKUP_CREATE_META = 1670
+--LET $ER_BACKUP_CREATE_RESTORE_DRIVER = 1666
+--LET $ER_BACKUP_CREATE_VP = 1680
+--LET $ER_BACKUP_FAILED_TO_INIT_COMPRESSION = 1743
+--LET $ER_BACKUP_GET_BUF = 1671
+--LET $ER_BACKUP_GET_DATA = 1684
+--LET $ER_BACKUP_GET_META_DB = 1721
+--LET $ER_BACKUP_GET_META_EVENT = 1725
+--LET $ER_BACKUP_GET_META_PRIV = 1750
+--LET $ER_BACKUP_GET_META_SROUT = 1724
+--LET $ER_BACKUP_GET_META_TABLE = 1722
+--LET $ER_BACKUP_GET_META_TRIGGER = 1726
+--LET $ER_BACKUP_GET_META_TS = 1738
+--LET $ER_BACKUP_GET_META_VIEW = 1723
+--LET $ER_BACKUP_GRANT_SKIPPED = 1752
+--LET $ER_BACKUP_GRANT_WRONG_DB = 1753
+--LET $ER_BACKUP_INIT_BACKUP_DRIVER = 1675
+--LET $ER_BACKUP_INIT_RESTORE_DRIVER = 1676
+--LET $ER_BACKUP_INTERRUPTED = 1786
+--LET $ER_BACKUP_INVALID_LOC = 1652
+--LET $ER_BACKUP_LIST_DB_EVENTS = 1731
+--LET $ER_BACKUP_LIST_DB_PRIV = 1748
+--LET $ER_BACKUP_LIST_DB_SROUT = 1730
+--LET $ER_BACKUP_LIST_DB_TABLES = 1657
+--LET $ER_BACKUP_LIST_DB_TRIGGERS = 1732
+--LET $ER_BACKUP_LIST_DB_VIEWS = 1729
+--LET $ER_BACKUP_LIST_DBS = 1655
+--LET $ER_BACKUP_LIST_PERDB = 1728
+--LET $ER_BACKUP_LIST_TABLES = 1656
+--LET $ER_BACKUP_LOG_OUTPUT = 1759
+--LET $ER_BACKUP_LOG_WRITE_ERROR = 1733
+--LET $ER_BACKUP_LOGGER_INIT = 1718
+--LET $ER_BACKUP_LOGPATH_INVALID = 1755
+--LET $ER_BACKUP_LOGPATHS = 1754
+--LET $ER_BACKUP_LOGS_DELETED = 1761
+--LET $ER_BACKUP_LOGS_TRUNCATED = 1762
+--LET $ER_BACKUP_NEXT_CHUNK = 1674
+--LET $ER_BACKUP_NO_BACKUP_DRIVER = 1663
+--LET $ER_BACKUP_NO_ENGINE = 1659
+--LET $ER_BACKUP_NO_NATIVE_BE = 1694
+--LET $ER_BACKUP_NO_NDB = 1789
+--LET $ER_BACKUP_NOT_ACCEPTED = 1664
+--LET $ER_BACKUP_NOT_ENABLED = 1787
+--LET $ER_BACKUP_NOTHING_TO_BACKUP = 1645
+--LET $ER_BACKUP_OBTAIN_NAME_LOCK_FAILED = 1744
+--LET $ER_BACKUP_OPEN_RD = 1712
+--LET $ER_BACKUP_OPEN_TABLES = 1687
+--LET $ER_BACKUP_OPEN_WR = 1711
+--LET $ER_BACKUP_PREPARE_DRIVER = 1679
+--LET $ER_BACKUP_PROGRESS_TABLES = 1689
+--LET $ER_BACKUP_PURGE_DATETIME = 1760
+--LET $ER_BACKUP_READ_DATA = 1673
+--LET $ER_BACKUP_READ_HEADER = 1661
+--LET $ER_BACKUP_READ_LOC = 1653
+--LET $ER_BACKUP_READ_META = 1669
+--LET $ER_BACKUP_READ_SUMMARY = 1720
+--LET $ER_BACKUP_RELEASE_NAME_LOCK_FAILED = 1745
+--LET $ER_BACKUP_RESTORE = 1648
+--LET $ER_BACKUP_RESTORE_DBS = 1771
+--LET $ER_BACKUP_RESTORE_DONE = 1644
+--LET $ER_BACKUP_RESTORE_PREPARE = 1651
+--LET $ER_BACKUP_RESTORE_START = 1643
+--LET $ER_BACKUP_RUNNING = 1649
+--LET $ER_BACKUP_SEND_DATA = 1685
+--LET $ER_BACKUP_SEND_DATA_RETRY = 1686
+--LET $ER_BACKUP_SEND_REPLY = 1756
+--LET $ER_BACKUP_SKIP_VIEW = 1658
+--LET $ER_BACKUP_STOP_BACKUP_DRIVER = 1677
+--LET $ER_BACKUP_STOP_RESTORE_DRIVERS = 1678
+--LET $ER_BACKUP_SYNCHRONIZE = 1773
+--LET $ER_BACKUP_TABLE_OPEN = 1660
+--LET $ER_BACKUP_THREAD_INIT = 1688
+--LET $ER_BACKUP_TOO_MANY_IMAGES = 1667
+--LET $ER_BACKUP_TS_CHANGE = 1737
+--LET $ER_BACKUP_UNEXPECTED_DATA = 1769
+--LET $ER_BACKUP_UNKNOWN_BE = 1695
+--LET $ER_BACKUP_UNKNOWN_OBJECT = 1709
+--LET $ER_BACKUP_UNKNOWN_OBJECT_TYPE = 1710
+--LET $ER_BACKUP_UNLOCK_DRIVER = 1681
+--LET $ER_BACKUP_WRITE_DATA = 1672
+--LET $ER_BACKUP_WRITE_HEADER = 1662
+--LET $ER_BACKUP_WRITE_LOC = 1654
+--LET $ER_BACKUP_WRITE_META = 1668
+--LET $ER_BACKUP_WRITE_SUMMARY = 1719
+--LET $ER_BACKUP_WRONG_TABLE_BE = 1696
+--LET $ER_RESTORE_ACCESS_DENIED_ERROR = 1792
+--LET $ER_RESTORE_CANNOT_START_SLAVE = 1774
+--LET $ER_RESTORE_DB_EXISTS = 1767
+--LET $ER_RESTORE_ON_MASTER = 1764
+--LET $ER_RESTORE_ON_SLAVE = 1765

=== added file 'mysql-test/suite/backup/include/test_for_error.inc'
--- a/mysql-test/suite/backup/include/test_for_error.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/include/test_for_error.inc	2009-08-20 19:53:25 +0000
@@ -0,0 +1,149 @@
+#
+# Include file test_for_error
+#
+# This include file executes either a backup or restore of the
+# backup_test database. It is designed to test for a specific
+# error using either debug insertion or error condition insertion
+# via the DBUG_EXECUTE_IF() macro.
+#
+# Prerequisites
+#  (1) There exists a database named 'backup_test'
+#  (2) There exists a backup image file named 'backup_test_orig.bak'
+#
+# Parameters (required)
+#   $caseno      The test case number
+#   $operation   'BACKUP'  = execute backup database w/o options
+#                'RESTORE' = execute restore from
+#   $errname     The name of the error. e.g. ER_SOME_ERROR
+#   $errno       The numeric value of the error 
+#                (see error_name_to_number.inc)
+#   $compress    Use the compression option for backup
+#                Valid values: ON or OFF
+#   $suppress    Suppress error numbers in warning or error
+#                messages on backup. "ON" = suppress
+#                Valid values: ON or OFF
+#
+
+--echo #
+--echo # Test case $caseno - testing error $errname
+--echo #
+--echo # Set debug SESSION variable for $errname
+--echo #
+eval SET SESSION debug="+d,$errname";
+
+# Check to see operation is for backup
+if (`SELECT STRCMP("$operation", "BACKUP") = 0`)
+{
+  --echo #
+  --echo # Execute backup
+  --echo #
+  --disable_abort_on_error
+  --replace_column 1 #
+  # Suppress error numbers if turned on.
+  if (`SELECT STRCMP("$suppress", "ON") = 0`)
+  {
+    --replace_regex /[0-9]+/####/
+  }
+  # Use compression if turned on.
+  if (`SELECT STRCMP("$compress", "ON") = 0`)
+  {
+    BACKUP DATABASE backup_test TO 'backup_test_err.bak' WITH COMPRESSION;
+  }
+  if (`SELECT STRCMP("$compress", "ON") <> 0`)
+  {
+    BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+  }
+  --error 0,1
+  remove_file $MYSQLD_BACKUPDIR/backup_test_err.bak;
+  --enable_abort_on_error
+}
+
+# Check to see operation is for restore
+if (`SELECT STRCMP("$operation", "RESTORE") = 0`)
+{
+  --echo #
+  --echo # Execute restore
+  --echo #
+  --disable_abort_on_error
+  --replace_column 1 #
+  RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+  --enable_abort_on_error
+}
+
+let $my_err = $mysql_errno;
+
+# If error number matches the error we are testing, the case passes.
+if (`SELECT $my_err = $errno`)
+{
+  --echo #
+  --echo # Test case for error $errname PASSED.
+  --echo #
+
+  if (`SELECT $errno = 0`)
+  {
+    --replace_column 2 ####
+    SHOW WARNINGS;
+  }
+  
+  --echo #
+  --echo # Show warning/error from progress and history log
+  --echo # if they exist.
+  --echo #
+
+  # Mask out error number from select statement.
+  --replace_column 1 # 3 ####
+  SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+
+  PURGE BACKUP LOGS;
+}
+
+# If error number does not match, the test case has failed.
+if (`SELECT $my_err <> $errno`)
+{
+  --echo #
+  --echo # Test case for error $errname FAILED. Aborting test.
+  --echo # Test returned error code $my_err.
+  --echo #
+  exit;
+}
+
+--echo #
+--echo # Turn off debug SESSION.
+--echo #
+SET SESSION debug="-d";
+
+--echo #
+--echo # Now demonstrate that the command will work without the
+--echo # debug session tag.
+
+# Check to see operation is for backup
+if (`SELECT STRCMP("$operation", "BACKUP") = 0`)
+{
+  --echo #
+  --echo # Running backup - should not fail.
+  --echo #
+  --replace_column 1 #
+  # Use compression if turned on.
+  if (`SELECT STRCMP("$compress", "ON") = 0`)
+  {
+    BACKUP DATABASE backup_test TO 'backup_test_err.bak' WITH COMPRESSION;
+  }
+  if (`SELECT STRCMP("$compress", "ON") <> 0`)
+  {
+    BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+  }
+  remove_file $MYSQLD_BACKUPDIR/backup_test_err.bak;
+}
+
+# Check to see operation is for restore
+if (`SELECT STRCMP("$operation", "RESTORE") = 0`)
+{
+  --echo #
+  --echo # Running restore - should not fail.
+  --echo #
+  --replace_column 1 #
+  RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+}
+--echo #
+--echo # Done.
+--echo #

=== added file 'mysql-test/suite/backup/r/backup_errors_debug_1.result'
--- a/mysql-test/suite/backup/r/backup_errors_debug_1.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_errors_debug_1.result	2009-08-09 21:33:03 +0000
@@ -0,0 +1,1095 @@
+DROP DATABASE IF EXISTS backup_test;
+#
+# Use the basic data setup in backup_test database.
+#
+#
+# Create database and data to test.
+#
+CREATE DATABASE backup_test;
+CREATE TABLE backup_test.t1 (a char(30)) ENGINE=MEMORY;
+INSERT INTO backup_test.t1 VALUES ("01 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("02 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("03 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("04 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("05 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("06 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("07 Test Basic database example");
+CREATE TABLE backup_test.t2 (a char(30)) ENGINE=MYISAM;
+INSERT INTO backup_test.t2 VALUES ("11 Test Basic database example");
+INSERT INTO backup_test.t2 VALUES ("12 Test Basic database example");
+INSERT INTO backup_test.t2 VALUES ("13 Test Basic database example");
+#
+# Now create more database objects for test.
+#
+CREATE PROCEDURE backup_test.p1(p1 CHAR(20))
+INSERT INTO backup_test.t1 VALUES ("50");
+CREATE TRIGGER backup_test.trg AFTER INSERT ON backup_test.t1 FOR EACH ROW
+INSERT INTO backup_test.t1 VALUES('Test objects count');
+CREATE FUNCTION backup_test.f1() RETURNS INT RETURN (SELECT 1);
+CREATE VIEW backup_test.v1 as SELECT * FROM backup_test.t1;
+CREATE EVENT backup_test.e1 ON SCHEDULE EVERY 1 YEAR DO
+DELETE FROM backup_test.t1 WHERE a = "not there";
+#
+# Now we need some privileges
+#
+GRANT ALL ON backup_test.* TO 'joe'@'user';
+#
+# Create a backup image file for use with restores.
+#
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak';
+backup_id
+#
+PURGE BACKUP LOGS;
+#
+# Begin test cases.
+#
+#
+# Test case 2 - testing error ER_BACKUP_CANT_RESTORE_DB
+#
+# Set debug SESSION variable for ER_BACKUP_CANT_RESTORE_DB
+#
+SET SESSION debug="+d,ER_BACKUP_CANT_RESTORE_DB";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Could not restore database `backup_test`
+#
+# Test case for error ER_BACKUP_CANT_RESTORE_DB PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not restore database `backup_test`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 3a - testing error ER_BACKUP_CANT_RESTORE_EVENT_1
+#
+# Set debug SESSION variable for ER_BACKUP_CANT_RESTORE_EVENT_1
+#
+SET SESSION debug="+d,ER_BACKUP_CANT_RESTORE_EVENT_1";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Could not restore event `backup_test`.`e1`
+#
+# Test case for error ER_BACKUP_CANT_RESTORE_EVENT_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not restore event `backup_test`.`e1`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 3b - testing error ER_BACKUP_CANT_RESTORE_EVENT_2
+#
+# Set debug SESSION variable for ER_BACKUP_CANT_RESTORE_EVENT_2
+#
+SET SESSION debug="+d,ER_BACKUP_CANT_RESTORE_EVENT_2";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Could not restore event `backup_test`.`e1`
+#
+# Test case for error ER_BACKUP_CANT_RESTORE_EVENT_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not restore event `backup_test`.`e1`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 4 - testing error ER_BACKUP_CANT_RESTORE_PRIV
+#
+# Set debug SESSION variable for ER_BACKUP_CANT_RESTORE_PRIV
+#
+SET SESSION debug="+d,ER_BACKUP_CANT_RESTORE_PRIV";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Could not execute grant 'Debug insertion test'.
+#
+# Test case for error ER_BACKUP_CANT_RESTORE_PRIV PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not execute grant 'Debug insertion test'.
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 5a - testing error ER_BACKUP_CANT_RESTORE_SROUT_P
+#
+# Set debug SESSION variable for ER_BACKUP_CANT_RESTORE_SROUT_P
+#
+SET SESSION debug="+d,ER_BACKUP_CANT_RESTORE_SROUT_P";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Could not restore stored routine `backup_test`.`p1`
+#
+# Test case for error ER_BACKUP_CANT_RESTORE_SROUT_P PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not restore stored routine `backup_test`.`p1`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 5b - testing error ER_BACKUP_CANT_RESTORE_SROUT_F
+#
+# Set debug SESSION variable for ER_BACKUP_CANT_RESTORE_SROUT_F
+#
+SET SESSION debug="+d,ER_BACKUP_CANT_RESTORE_SROUT_F";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Could not restore stored routine `backup_test`.`f1`
+#
+# Test case for error ER_BACKUP_CANT_RESTORE_SROUT_F PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not restore stored routine `backup_test`.`f1`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 6 - testing error ER_BACKUP_CANT_RESTORE_TS
+#
+# Set debug SESSION variable for ER_BACKUP_CANT_RESTORE_TS
+#
+SET SESSION debug="+d,ER_BACKUP_CANT_RESTORE_TS";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Could not create tablespace Debug insertion test needed by tables being restored.
+#
+# Test case for error ER_BACKUP_CANT_RESTORE_TS PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not create tablespace Debug insertion test needed by tables being restored.
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 7 - testing error ER_BACKUP_GET_META_EVENT
+#
+# Set debug SESSION variable for ER_BACKUP_GET_META_EVENT
+#
+SET SESSION debug="+d,ER_BACKUP_GET_META_EVENT";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to obtain meta-data for event `backup_test`.`e1`
+#
+# Test case for error ER_BACKUP_GET_META_EVENT PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to obtain meta-data for event `backup_test`.`e1`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 8 - testing error ER_BACKUP_GET_META_PRIV
+#
+# Set debug SESSION variable for ER_BACKUP_GET_META_PRIV
+#
+SET SESSION debug="+d,ER_BACKUP_GET_META_PRIV";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to obtain meta-data for grant 'Debug insertion test'.
+#
+# Test case for error ER_BACKUP_GET_META_PRIV PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to obtain meta-data for grant 'Debug insertion test'.
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 9a - testing error ER_BACKUP_GET_META_SROUT_P
+#
+# Set debug SESSION variable for ER_BACKUP_GET_META_SROUT_P
+#
+SET SESSION debug="+d,ER_BACKUP_GET_META_SROUT_P";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to obtain meta-data for stored routine `backup_test`.`p1`
+#
+# Test case for error ER_BACKUP_GET_META_SROUT_P PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to obtain meta-data for stored routine `backup_test`.`p1`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 9b - testing error ER_BACKUP_GET_META_SROUT_F
+#
+# Set debug SESSION variable for ER_BACKUP_GET_META_SROUT_F
+#
+SET SESSION debug="+d,ER_BACKUP_GET_META_SROUT_F";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to obtain meta-data for stored routine `backup_test`.`f1`
+#
+# Test case for error ER_BACKUP_GET_META_SROUT_F PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to obtain meta-data for stored routine `backup_test`.`f1`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 10 - testing error ER_BACKUP_GET_META_TABLE
+#
+# Set debug SESSION variable for ER_BACKUP_GET_META_TABLE
+#
+SET SESSION debug="+d,ER_BACKUP_GET_META_TABLE";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to obtain meta-data for table `backup_test`.`t1`
+#
+# Test case for error ER_BACKUP_GET_META_TABLE PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to obtain meta-data for table `backup_test`.`t1`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 11 - testing error ER_BACKUP_GET_META_TS
+#
+# Set debug SESSION variable for ER_BACKUP_GET_META_TS
+#
+SET SESSION debug="+d,ER_BACKUP_GET_META_TS";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to obtain meta-data for tablespace Debug insertion test.
+#
+# Test case for error ER_BACKUP_GET_META_TS PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to obtain meta-data for tablespace Debug insertion test.
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 12 - testing error ER_BACKUP_INIT_BACKUP_DRIVER
+#
+# Set debug SESSION variable for ER_BACKUP_INIT_BACKUP_DRIVER
+#
+SET SESSION debug="+d,ER_BACKUP_INIT_BACKUP_DRIVER";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't initialize MyISAM backup driver
+#
+# Test case for error ER_BACKUP_INIT_BACKUP_DRIVER PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't initialize MyISAM backup driver
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 13 - testing error ER_BACKUP_INIT_RESTORE_DRIVER
+#
+# Set debug SESSION variable for ER_BACKUP_INIT_RESTORE_DRIVER
+#
+SET SESSION debug="+d,ER_BACKUP_INIT_RESTORE_DRIVER";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Can't initialize Default restore driver
+#
+# Test case for error ER_BACKUP_INIT_RESTORE_DRIVER PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't initialize Default restore driver
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 14a - testing error ER_BACKUP_LOG_WRITE_ERROR_H
+#
+# Set debug SESSION variable for ER_BACKUP_LOG_WRITE_ERROR_H
+#
+SET SESSION debug="+d,ER_BACKUP_LOG_WRITE_ERROR_H";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+Warnings:
+#	####	Can't write to the online backup progress log mysql.backup_history.
+#
+# Test case for error ER_BACKUP_LOG_WRITE_ERROR_H PASSED.
+#
+SHOW WARNINGS;
+Level	Code	Message
+Warning	####	Can't write to the online backup progress log mysql.backup_history.
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 14b - testing error ER_BACKUP_LOG_WRITE_ERROR_P
+#
+# Set debug SESSION variable for ER_BACKUP_LOG_WRITE_ERROR_P
+#
+SET SESSION debug="+d,ER_BACKUP_LOG_WRITE_ERROR_P";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+Warnings:
+#	####	Can't write to the online backup progress log mysql.backup_progress.
+#	####	Can't write to the online backup progress log mysql.backup_progress.
+#	####	Can't write to the online backup progress log mysql.backup_progress.
+#	####	Can't write to the online backup progress log mysql.backup_progress.
+#	####	Can't write to the online backup progress log mysql.backup_progress.
+#	####	Can't write to the online backup progress log mysql.backup_progress.
+#
+# Test case for error ER_BACKUP_LOG_WRITE_ERROR_P PASSED.
+#
+SHOW WARNINGS;
+Level	Code	Message
+Warning	####	Can't write to the online backup progress log mysql.backup_progress.
+Warning	####	Can't write to the online backup progress log mysql.backup_progress.
+Warning	####	Can't write to the online backup progress log mysql.backup_progress.
+Warning	####	Can't write to the online backup progress log mysql.backup_progress.
+Warning	####	Can't write to the online backup progress log mysql.backup_progress.
+Warning	####	Can't write to the online backup progress log mysql.backup_progress.
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 15 - testing error ER_BACKUP_FAILED_TO_INIT_COMPRESSION
+#
+# Set debug SESSION variable for ER_BACKUP_FAILED_TO_INIT_COMPRESSION
+#
+SET SESSION debug="+d,ER_BACKUP_FAILED_TO_INIT_COMPRESSION";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak' WITH COMPRESSION;
+ERROR HY000: Could not initialize compression of backup image (function deflateInit2 returned error code 0: (null))
+#
+# Test case for error ER_BACKUP_FAILED_TO_INIT_COMPRESSION PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not initialize compression of backup image (function deflateInit2 returned error code 0: (null
+#		####	Can't write to backup location 'backup_test_err.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak' WITH COMPRESSION;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 16 - testing error ER_BACKUP_OPEN_RD
+#
+# Set debug SESSION variable for ER_BACKUP_OPEN_RD
+#
+SET SESSION debug="+d,ER_BACKUP_OPEN_RD";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Cannot open backup stream for reading
+#
+# Test case for error ER_BACKUP_OPEN_RD PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Cannot open backup stream for reading
+#		####	Can't read backup location 'backup_test_orig.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 17 - testing error ER_BACKUP_OPEN_WR
+#
+# Set debug SESSION variable for ER_BACKUP_OPEN_WR
+#
+SET SESSION debug="+d,ER_BACKUP_OPEN_WR";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Cannot open backup stream for writing
+#
+# Test case for error ER_BACKUP_OPEN_WR PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Cannot open backup stream for writing
+#		####	Can't write to backup location 'backup_test_err.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 19 - testing error ER_BACKUP_NOTHING_TO_BACKUP
+#
+# Set debug SESSION variable for ER_BACKUP_NOTHING_TO_BACKUP
+#
+SET SESSION debug="+d,ER_BACKUP_NOTHING_TO_BACKUP";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Nothing to backup
+#
+# Test case for error ER_BACKUP_NOTHING_TO_BACKUP PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Nothing to backup
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 20 - testing error ER_BACKUP_BACKUP
+#
+# Set debug SESSION variable for ER_BACKUP_BACKUP
+#
+SET SESSION debug="+d,ER_BACKUP_BACKUP";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Error during backup operation - see SHOW WARNINGS for more information
+#
+# Test case for error ER_BACKUP_BACKUP PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 21a - testing error ER_BACKUP_BACKUP_PREPARE_1
+#
+# Set debug SESSION variable for ER_BACKUP_BACKUP_PREPARE_1
+#
+SET SESSION debug="+d,ER_BACKUP_BACKUP_PREPARE_1";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Error when preparing for backup operation
+#
+# Test case for error ER_BACKUP_BACKUP_PREPARE_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 21b - testing error ER_BACKUP_BACKUP_PREPARE_2
+#
+# Set debug SESSION variable for ER_BACKUP_BACKUP_PREPARE_2
+#
+SET SESSION debug="+d,ER_BACKUP_BACKUP_PREPARE_2";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Error when preparing for backup operation
+#
+# Test case for error ER_BACKUP_BACKUP_PREPARE_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 21c - testing error ER_BACKUP_BACKUP_PREPARE_3
+#
+# Set debug SESSION variable for ER_BACKUP_BACKUP_PREPARE_3
+#
+SET SESSION debug="+d,ER_BACKUP_BACKUP_PREPARE_3";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Error when preparing for backup operation
+#
+# Test case for error ER_BACKUP_BACKUP_PREPARE_3 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 22 - testing error ER_BACKUP_CANT_FIND_SE
+#
+# Set debug SESSION variable for ER_BACKUP_CANT_FIND_SE
+#
+SET SESSION debug="+d,ER_BACKUP_CANT_FIND_SE";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Backup image contains data created by a native driver of MyISAM storage engine but this engine can not be found on this server
+#
+# Test case for error ER_BACKUP_CANT_FIND_SE PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup image contains data created by a native driver of MyISAM storage engine but this engine can n
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 23 - testing error ER_BACKUP_CAT_ENUM
+#
+# Set debug SESSION variable for ER_BACKUP_CAT_ENUM
+#
+SET SESSION debug="+d,ER_BACKUP_CAT_ENUM";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Could not access the contents of the backup catalog when writing backup image preamble
+#
+# Test case for error ER_BACKUP_CAT_ENUM PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not access the contents of the backup catalog when writing backup image preamble
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Cleanup
+#
+DROP DATABASE backup_test;
+DROP USER 'joe'@'user';

=== added file 'mysql-test/suite/backup/r/backup_errors_debug_2.result'
--- a/mysql-test/suite/backup/r/backup_errors_debug_2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_errors_debug_2.result	2009-08-20 19:53:25 +0000
@@ -0,0 +1,1037 @@
+DROP DATABASE IF EXISTS backup_test;
+#
+# Use the basic data setup in backup_test database.
+#
+#
+# Create database and data to test.
+#
+CREATE DATABASE backup_test;
+CREATE TABLE backup_test.t1 (a char(30)) ENGINE=MEMORY;
+INSERT INTO backup_test.t1 VALUES ("01 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("02 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("03 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("04 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("05 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("06 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("07 Test Basic database example");
+CREATE TABLE backup_test.t2 (a char(30)) ENGINE=MYISAM;
+INSERT INTO backup_test.t2 VALUES ("11 Test Basic database example");
+INSERT INTO backup_test.t2 VALUES ("12 Test Basic database example");
+INSERT INTO backup_test.t2 VALUES ("13 Test Basic database example");
+#
+# Now create more database objects for test.
+#
+CREATE PROCEDURE backup_test.p1(p1 CHAR(20))
+INSERT INTO backup_test.t1 VALUES ("50");
+CREATE TRIGGER backup_test.trg AFTER INSERT ON backup_test.t1 FOR EACH ROW
+INSERT INTO backup_test.t1 VALUES('Test objects count');
+CREATE FUNCTION backup_test.f1() RETURNS INT RETURN (SELECT 1);
+CREATE VIEW backup_test.v1 as SELECT * FROM backup_test.t1;
+CREATE EVENT backup_test.e1 ON SCHEDULE EVERY 1 YEAR DO
+DELETE FROM backup_test.t1 WHERE a = "not there";
+#
+# Now we need some privileges
+#
+GRANT ALL ON backup_test.* TO 'joe'@'user';
+#
+# Create a backup image file for use with restores.
+#
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak';
+backup_id
+#
+PURGE BACKUP LOGS;
+#
+# Begin test cases.
+#
+#
+# Test case 24 - testing error ER_BACKUP_CATALOG_ADD_EVENT
+#
+# Set debug SESSION variable for ER_BACKUP_CATALOG_ADD_EVENT
+#
+SET SESSION debug="+d,ER_BACKUP_CATALOG_ADD_EVENT";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to add event `backup_test`.`e1` to the catalog
+#
+# Test case for error ER_BACKUP_CATALOG_ADD_EVENT PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to add event `backup_test`.`e1` to the catalog
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 2 - testing error ER_BACKUP_CATALOG_ADD_PRIV
+#
+# Set debug SESSION variable for ER_BACKUP_CATALOG_ADD_PRIV
+#
+SET SESSION debug="+d,ER_BACKUP_CATALOG_ADD_PRIV";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to add grant 'backup_test' to the catalog
+#
+# Test case for error ER_BACKUP_CATALOG_ADD_PRIV PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to add grant 'backup_test' to the catalog
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 26a - testing error ER_BACKUP_CATALOG_ADD_SROUT_F
+#
+# Set debug SESSION variable for ER_BACKUP_CATALOG_ADD_SROUT_F
+#
+SET SESSION debug="+d,ER_BACKUP_CATALOG_ADD_SROUT_F";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to add stored routine `backup_test`.`f1` to the catalog
+#
+# Test case for error ER_BACKUP_CATALOG_ADD_SROUT_F PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to add stored routine `backup_test`.`f1` to the catalog
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 26b - testing error ER_BACKUP_CATALOG_ADD_SROUT_P
+#
+# Set debug SESSION variable for ER_BACKUP_CATALOG_ADD_SROUT_P
+#
+SET SESSION debug="+d,ER_BACKUP_CATALOG_ADD_SROUT_P";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to add stored routine `backup_test`.`p1` to the catalog
+#
+# Test case for error ER_BACKUP_CATALOG_ADD_SROUT_P PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to add stored routine `backup_test`.`p1` to the catalog
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 27 - testing error ER_BACKUP_CATALOG_ADD_TABLE
+#
+# Set debug SESSION variable for ER_BACKUP_CATALOG_ADD_TABLE
+#
+SET SESSION debug="+d,ER_BACKUP_CATALOG_ADD_TABLE";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to add table `backup_test`.`t1` to the catalog
+#
+# Test case for error ER_BACKUP_CATALOG_ADD_TABLE PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to add table `backup_test`.`t1` to the catalog
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 28 - testing error ER_BACKUP_CATALOG_ADD_TRIGGER
+#
+# Set debug SESSION variable for ER_BACKUP_CATALOG_ADD_TRIGGER
+#
+SET SESSION debug="+d,ER_BACKUP_CATALOG_ADD_TRIGGER";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to add trigger `backup_test`.`trg` to the catalog
+#
+# Test case for error ER_BACKUP_CATALOG_ADD_TRIGGER PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to add trigger `backup_test`.`trg` to the catalog
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 29 - testing error ER_BACKUP_CATALOG_ADD_TS
+#
+# Set debug SESSION variable for ER_BACKUP_CATALOG_ADD_TS
+#
+SET SESSION debug="+d,ER_BACKUP_CATALOG_ADD_TS";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to add tablespace `Debug insertion test` to the catalog
+#
+# Test case for error ER_BACKUP_CATALOG_ADD_TS PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to add tablespace `Debug insertion test` to the catalog
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 30a - testing error ER_BACKUP_CLOSE_1
+#
+# Set debug SESSION variable for ER_BACKUP_CLOSE_1
+#
+SET SESSION debug="+d,ER_BACKUP_CLOSE_1";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Backup/Restore: Error on close of backup stream
+#
+# Test case for error ER_BACKUP_CLOSE_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup/Restore: Error on close of backup stream
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 30b - testing error ER_BACKUP_CLOSE_2
+#
+# Set debug SESSION variable for ER_BACKUP_CLOSE_2
+#
+SET SESSION debug="+d,ER_BACKUP_CLOSE_2";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Backup/Restore: Error on close of backup stream
+#
+# Test case for error ER_BACKUP_CLOSE_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup/Restore: Error on close of backup stream
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 32a - testing error ER_BACKUP_CONTEXT_REMOVE
+#
+# Set debug SESSION variable for ER_BACKUP_CONTEXT_REMOVE
+#
+SET SESSION debug="+d,ER_BACKUP_CONTEXT_REMOVE";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Error when cleaning up after backup/restore operation
+#
+# Test case for error ER_BACKUP_CONTEXT_REMOVE PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 32b - testing error ER_BACKUP_CONTEXT_REMOVE
+#
+# Set debug SESSION variable for ER_BACKUP_CONTEXT_REMOVE
+#
+SET SESSION debug="+d,ER_BACKUP_CONTEXT_REMOVE";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Error when cleaning up after backup/restore operation
+#
+# Test case for error ER_BACKUP_CONTEXT_REMOVE PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 33 - testing error ER_BACKUP_CREATE_BACKUP_DRIVER
+#
+# Set debug SESSION variable for ER_BACKUP_CREATE_BACKUP_DRIVER
+#
+SET SESSION debug="+d,ER_BACKUP_CREATE_BACKUP_DRIVER";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't create Default backup driver
+#
+# Test case for error ER_BACKUP_CREATE_BACKUP_DRIVER PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't create Default backup driver
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 34 - testing error ER_BACKUP_CREATE_BE
+#
+# Set debug SESSION variable for ER_BACKUP_CREATE_BE
+#
+SET SESSION debug="+d,ER_BACKUP_CREATE_BE";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+Warnings:
+#	1727	Cannot create backup engine for storage engine MyISAM
+#
+# Test case for error ER_BACKUP_CREATE_BE PASSED.
+#
+SHOW WARNINGS;
+Level	Code	Message
+Warning	####	Cannot create backup engine for storage engine MyISAM
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 35 - testing error ER_BACKUP_CREATE_RESTORE_DRIVER
+#
+# Set debug SESSION variable for ER_BACKUP_CREATE_RESTORE_DRIVER
+#
+SET SESSION debug="+d,ER_BACKUP_CREATE_RESTORE_DRIVER";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Can't create Default restore driver
+#
+# Test case for error ER_BACKUP_CREATE_RESTORE_DRIVER PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't create Default restore driver
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 36 - testing error ER_BACKUP_CREATE_VP
+#
+# Set debug SESSION variable for ER_BACKUP_CREATE_VP
+#
+SET SESSION debug="+d,ER_BACKUP_CREATE_VP";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Default backup driver can't create its validity point
+#
+# Test case for error ER_BACKUP_CREATE_VP PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Default backup driver can't create its validity point
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 37 - testing error ER_BACKUP_INTERRUPTED
+#
+# Set debug SESSION variable for ER_BACKUP_INTERRUPTED
+#
+SET SESSION debug="+d,ER_BACKUP_INTERRUPTED";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Cannot create backup/restore execution context
+#
+# Test case for error ER_BACKUP_INTERRUPTED PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 38 - testing error ER_BACKUP_LIST_DB_EVENTS
+#
+# Set debug SESSION variable for ER_BACKUP_LIST_DB_EVENTS
+#
+SET SESSION debug="+d,ER_BACKUP_LIST_DB_EVENTS";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't enumerate events in database `backup_test`
+#
+# Test case for error ER_BACKUP_LIST_DB_EVENTS PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't enumerate events in database `backup_test`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 39 - testing error ER_BACKUP_LIST_DB_PRIV
+#
+# Set debug SESSION variable for ER_BACKUP_LIST_DB_PRIV
+#
+SET SESSION debug="+d,ER_BACKUP_LIST_DB_PRIV";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't enumerate grants in database 'backup_test'.
+#
+# Test case for error ER_BACKUP_LIST_DB_PRIV PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't enumerate grants in database 'backup_test'.
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 40a - testing error ER_BACKUP_LIST_DB_SROUT_F
+#
+# Set debug SESSION variable for ER_BACKUP_LIST_DB_SROUT_F
+#
+SET SESSION debug="+d,ER_BACKUP_LIST_DB_SROUT_F";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't enumerate stored routines in database `backup_test`
+#
+# Test case for error ER_BACKUP_LIST_DB_SROUT_F PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't enumerate stored routines in database `backup_test`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 40b - testing error ER_BACKUP_LIST_DB_SROUT_P
+#
+# Set debug SESSION variable for ER_BACKUP_LIST_DB_SROUT_P
+#
+SET SESSION debug="+d,ER_BACKUP_LIST_DB_SROUT_P";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't enumerate stored routines in database `backup_test`
+#
+# Test case for error ER_BACKUP_LIST_DB_SROUT_P PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't enumerate stored routines in database `backup_test`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 41 - testing error ER_BACKUP_LIST_DB_TABLES
+#
+# Set debug SESSION variable for ER_BACKUP_LIST_DB_TABLES
+#
+SET SESSION debug="+d,ER_BACKUP_LIST_DB_TABLES";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't enumerate tables in database backup_test
+#
+# Test case for error ER_BACKUP_LIST_DB_TABLES PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't enumerate tables in database backup_test
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 42 - testing error ER_BACKUP_LIST_DB_TRIGGERS
+#
+# Set debug SESSION variable for ER_BACKUP_LIST_DB_TRIGGERS
+#
+SET SESSION debug="+d,ER_BACKUP_LIST_DB_TRIGGERS";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't enumerate triggers in database `backup_test`
+#
+# Test case for error ER_BACKUP_LIST_DB_TRIGGERS PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't enumerate triggers in database `backup_test`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 43 - testing error ER_BACKUP_LIST_DB_VIEWS
+#
+# Set debug SESSION variable for ER_BACKUP_LIST_DB_VIEWS
+#
+SET SESSION debug="+d,ER_BACKUP_LIST_DB_VIEWS";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't enumerate views in database `backup_test`
+#
+# Test case for error ER_BACKUP_LIST_DB_VIEWS PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't enumerate views in database `backup_test`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 44 - testing error ER_BACKUP_LIST_DBS
+#
+# Set debug SESSION variable for ER_BACKUP_LIST_DBS
+#
+SET SESSION debug="+d,ER_BACKUP_LIST_DBS";
+#
+# Execute backup
+#
+BACKUP DATABASE * TO 'backup_test_err.bak';
+ERROR HY000: Can't enumerate server databases
+SHOW ERRORS;
+Level	Code	Message
+Error	####	Can't enumerate server databases
+SHOW WARNINGS;
+Level	Code	Message
+Error	####	Can't enumerate server databases
+Warning	####	Operation aborted
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 47 - testing error ER_BACKUP_NO_BACKUP_DRIVER
+#
+# Set debug SESSION variable for ER_BACKUP_NO_BACKUP_DRIVER
+#
+SET SESSION debug="+d,ER_BACKUP_NO_BACKUP_DRIVER";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't find backup driver for table `backup_test`.`t1`
+#
+# Test case for error ER_BACKUP_NO_BACKUP_DRIVER PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't enumerate server databases
+#		####	Can't find backup driver for table `backup_test`.`t1`
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 48 - testing error ER_BACKUP_NO_NATIVE_BE
+#
+# Set debug SESSION variable for ER_BACKUP_NO_NATIVE_BE
+#
+SET SESSION debug="+d,ER_BACKUP_NO_NATIVE_BE";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Backup image contains data created by a native driver of MyISAM storage engine but it has no native backup support on this server
+#
+# Test case for error ER_BACKUP_NO_NATIVE_BE PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup image contains data created by a native driver of MyISAM storage engine but it has no native
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Cleanup
+#
+DROP DATABASE backup_test;
+DROP USER 'joe'@'user';

=== added file 'mysql-test/suite/backup/r/backup_errors_debug_3.result'
--- a/mysql-test/suite/backup/r/backup_errors_debug_3.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_errors_debug_3.result	2009-08-20 19:53:25 +0000
@@ -0,0 +1,1351 @@
+DROP DATABASE IF EXISTS backup_test;
+#
+# Use the basic data setup in backup_test database.
+#
+#
+# Create database and data to test.
+#
+CREATE DATABASE backup_test;
+CREATE TABLE backup_test.t1 (a char(30)) ENGINE=MEMORY;
+INSERT INTO backup_test.t1 VALUES ("01 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("02 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("03 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("04 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("05 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("06 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("07 Test Basic database example");
+CREATE TABLE backup_test.t2 (a char(30)) ENGINE=MYISAM;
+INSERT INTO backup_test.t2 VALUES ("11 Test Basic database example");
+INSERT INTO backup_test.t2 VALUES ("12 Test Basic database example");
+INSERT INTO backup_test.t2 VALUES ("13 Test Basic database example");
+#
+# Now create more database objects for test.
+#
+CREATE PROCEDURE backup_test.p1(p1 CHAR(20))
+INSERT INTO backup_test.t1 VALUES ("50");
+CREATE TRIGGER backup_test.trg AFTER INSERT ON backup_test.t1 FOR EACH ROW
+INSERT INTO backup_test.t1 VALUES('Test objects count');
+CREATE FUNCTION backup_test.f1() RETURNS INT RETURN (SELECT 1);
+CREATE VIEW backup_test.v1 as SELECT * FROM backup_test.t1;
+CREATE EVENT backup_test.e1 ON SCHEDULE EVERY 1 YEAR DO
+DELETE FROM backup_test.t1 WHERE a = "not there";
+#
+# Now we need some privileges
+#
+GRANT ALL ON backup_test.* TO 'joe'@'user';
+#
+# Create a backup image file for use with restores.
+#
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak';
+backup_id
+#
+PURGE BACKUP LOGS;
+#
+# Begin test cases.
+#
+#
+# Test case 49a - testing error ER_BACKUP_RESTORE_1
+#
+# Set debug SESSION variable for ER_BACKUP_RESTORE_1
+#
+SET SESSION debug="+d,ER_BACKUP_RESTORE_1";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Error during restore operation - see SHOW WARNINGS for more information
+#
+# Test case for error ER_BACKUP_RESTORE_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 49b - testing error ER_BACKUP_RESTORE_2
+#
+# Set debug SESSION variable for ER_BACKUP_RESTORE_2
+#
+SET SESSION debug="+d,ER_BACKUP_RESTORE_2";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Error during restore operation - see SHOW WARNINGS for more information
+#
+# Test case for error ER_BACKUP_RESTORE_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 50a - testing error ER_BACKUP_RESTORE_PREPARE_1
+#
+# Set debug SESSION variable for ER_BACKUP_RESTORE_PREPARE_1
+#
+SET SESSION debug="+d,ER_BACKUP_RESTORE_PREPARE_1";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Error when preparing for restore operation
+#
+# Test case for error ER_BACKUP_RESTORE_PREPARE_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 50b - testing error ER_BACKUP_RESTORE_PREPARE_2
+#
+# Set debug SESSION variable for ER_BACKUP_RESTORE_PREPARE_2
+#
+SET SESSION debug="+d,ER_BACKUP_RESTORE_PREPARE_2";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Error when preparing for restore operation
+#
+# Test case for error ER_BACKUP_RESTORE_PREPARE_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 52 - testing error ER_BACKUP_SEND_DATA_RETRY
+#
+# Set debug SESSION variable for ER_BACKUP_SEND_DATA_RETRY
+#
+SET SESSION debug="+d,ER_BACKUP_SEND_DATA_RETRY";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: After 8 attempts Default restore driver still can't accept next block of data
+#
+# Test case for error ER_BACKUP_SEND_DATA_RETRY PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	After 8 attempts Default restore driver still can't accept next block of data
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 53a - testing error ER_BACKUP_SEND_REPLY_1
+#
+# Set debug SESSION variable for ER_BACKUP_SEND_REPLY_1
+#
+SET SESSION debug="+d,ER_BACKUP_SEND_REPLY_1";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to send reply to client after successful BACKUP operation
+#
+# Test case for error ER_BACKUP_SEND_REPLY_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to send reply to client after successful BACKUP operation
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 53b - testing error ER_BACKUP_SEND_REPLY_2
+#
+# Set debug SESSION variable for ER_BACKUP_SEND_REPLY_2
+#
+SET SESSION debug="+d,ER_BACKUP_SEND_REPLY_2";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Failed to send reply to client after successful BACKUP operation
+#
+# Test case for error ER_BACKUP_SEND_REPLY_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to send reply to client after successful BACKUP operation
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 53c - testing error ER_BACKUP_SEND_REPLY_1
+#
+# Set debug SESSION variable for ER_BACKUP_SEND_REPLY_1
+#
+SET SESSION debug="+d,ER_BACKUP_SEND_REPLY_1";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Failed to send reply to client after successful RESTORE operation
+#
+# Test case for error ER_BACKUP_SEND_REPLY_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to send reply to client after successful RESTORE operation
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 53d - testing error ER_BACKUP_SEND_REPLY_2
+#
+# Set debug SESSION variable for ER_BACKUP_SEND_REPLY_2
+#
+SET SESSION debug="+d,ER_BACKUP_SEND_REPLY_2";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Failed to send reply to client after successful RESTORE operation
+#
+# Test case for error ER_BACKUP_SEND_REPLY_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Failed to send reply to client after successful RESTORE operation
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 54 - testing error ER_BACKUP_STOP_BACKUP_DRIVER
+#
+# Set debug SESSION variable for ER_BACKUP_STOP_BACKUP_DRIVER
+#
+SET SESSION debug="+d,ER_BACKUP_STOP_BACKUP_DRIVER";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't shut down Default backup driver
+#
+# Test case for error ER_BACKUP_STOP_BACKUP_DRIVER PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't shut down Default backup driver
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 55 - testing error ER_BACKUP_STOP_RESTORE_DRIVERS
+#
+# Set debug SESSION variable for ER_BACKUP_STOP_RESTORE_DRIVERS
+#
+SET SESSION debug="+d,ER_BACKUP_STOP_RESTORE_DRIVERS";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Can't shut down  restore driver(s)
+#
+# Test case for error ER_BACKUP_STOP_RESTORE_DRIVERS PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't shut down  restore driver(s)
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 56 - testing error ER_BACKUP_TOO_MANY_IMAGES
+#
+# Set debug SESSION variable for ER_BACKUP_TOO_MANY_IMAGES
+#
+SET SESSION debug="+d,ER_BACKUP_TOO_MANY_IMAGES";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Backup image uses 2 backup engines but maximum 256 are supported
+#
+# Test case for error ER_BACKUP_TOO_MANY_IMAGES PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup image uses 2 backup engines but maximum 256 are supported
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 57 - testing error ER_BACKUP_UNKNOWN_BE
+#
+# Set debug SESSION variable for ER_BACKUP_UNKNOWN_BE
+#
+SET SESSION debug="+d,ER_BACKUP_UNKNOWN_BE";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Backup engine #1 needed for restoring from backup image has unknown type
+#
+# Test case for error ER_BACKUP_UNKNOWN_BE PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup engine #1 needed for restoring from backup image has unknown type
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 58 - testing error ER_BACKUP_UNKNOWN_OBJECT
+#
+# Set debug SESSION variable for ER_BACKUP_UNKNOWN_OBJECT
+#
+SET SESSION debug="+d,ER_BACKUP_UNKNOWN_OBJECT";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Backup image refers to an object which could not be found in the catalog
+#
+# Test case for error ER_BACKUP_UNKNOWN_OBJECT PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup image refers to an object which could not be found in the catalog
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 59 - testing error ER_BACKUP_UNKNOWN_OBJECT_TYPE
+#
+# Set debug SESSION variable for ER_BACKUP_UNKNOWN_OBJECT_TYPE
+#
+SET SESSION debug="+d,ER_BACKUP_UNKNOWN_OBJECT_TYPE";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Backup image refers to an object of unknown type
+#
+# Test case for error ER_BACKUP_UNKNOWN_OBJECT_TYPE PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup image refers to an object of unknown type
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 60 - testing error ER_BACKUP_UNLOCK_DRIVER
+#
+# Set debug SESSION variable for ER_BACKUP_UNLOCK_DRIVER
+#
+SET SESSION debug="+d,ER_BACKUP_UNLOCK_DRIVER";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't unlock Default backup driver after creating the validity point
+#
+# Test case for error ER_BACKUP_UNLOCK_DRIVER PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't unlock Default backup driver after creating the validity point
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 61 - testing error ER_BACKUP_WRITE_DATA
+#
+# Set debug SESSION variable for ER_BACKUP_WRITE_DATA
+#
+SET SESSION debug="+d,ER_BACKUP_WRITE_DATA";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Error when writing data from Default backup driver (data block for table #1)
+#
+# Test case for error ER_BACKUP_WRITE_DATA PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Error when writing data from Default backup driver (data block for table #1)
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 62a - testing error ER_BACKUP_WRITE_HEADER_1
+#
+# Set debug SESSION variable for ER_BACKUP_WRITE_HEADER_1
+#
+SET SESSION debug="+d,ER_BACKUP_WRITE_HEADER_1";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't write backup archive preamble
+#
+# Test case for error ER_BACKUP_WRITE_HEADER_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't write backup archive preamble
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 62b - testing error ER_BACKUP_WRITE_HEADER_2
+#
+# Set debug SESSION variable for ER_BACKUP_WRITE_HEADER_2
+#
+SET SESSION debug="+d,ER_BACKUP_WRITE_HEADER_2";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't write backup archive preamble
+#
+# Test case for error ER_BACKUP_WRITE_HEADER_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't write backup archive preamble
+#		####	Can't write to backup location 'backup_test_err.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 63 - testing error ER_BACKUP_WRITE_SUMMARY
+#
+# Set debug SESSION variable for ER_BACKUP_WRITE_SUMMARY
+#
+SET SESSION debug="+d,ER_BACKUP_WRITE_SUMMARY";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Error when writing summary section of backup image
+#
+# Test case for error ER_BACKUP_WRITE_SUMMARY PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Error when writing summary section of backup image
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 64 - testing error ER_BACKUP_BAD_MAGIC
+#
+# Set debug SESSION variable for ER_BACKUP_BAD_MAGIC
+#
+SET SESSION debug="+d,ER_BACKUP_BAD_MAGIC";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Could not find correct signature at the beginning of backup stream
+#
+# Test case for error ER_BACKUP_BAD_MAGIC PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Could not find correct signature at the beginning of backup stream
+#		####	Can't read backup location 'backup_test_orig.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 65 - testing error ER_BACKUP_GET_BUF
+#
+# Set debug SESSION variable for ER_BACKUP_GET_BUF
+#
+SET SESSION debug="+d,ER_BACKUP_GET_BUF";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't allocate buffer for image data transfer
+#
+# Test case for error ER_BACKUP_GET_BUF PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't allocate buffer for image data transfer
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 66a - testing error ER_BACKUP_LOGGER_INIT_1
+#
+# Set debug SESSION variable for ER_BACKUP_LOGGER_INIT_1
+#
+SET SESSION debug="+d,ER_BACKUP_LOGGER_INIT_1";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Error when preparing for backup operation
+#
+# Test case for error ER_BACKUP_LOGGER_INIT_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 66b - testing error ER_BACKUP_LOGGER_INIT_2
+#
+# Set debug SESSION variable for ER_BACKUP_LOGGER_INIT_2
+#
+SET SESSION debug="+d,ER_BACKUP_LOGGER_INIT_2";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Error when preparing for restore operation
+#
+# Test case for error ER_BACKUP_LOGGER_INIT_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 67a - testing error ER_BACKUP_READ_LOC_1
+#
+# Set debug SESSION variable for ER_BACKUP_READ_LOC_1
+#
+SET SESSION debug="+d,ER_BACKUP_READ_LOC_1";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Can't read backup location 'backup_test_err.bak'
+#
+# Test case for error ER_BACKUP_READ_LOC_1 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't read backup location 'backup_test_err.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 67b - testing error ER_BACKUP_READ_LOC_2
+#
+# Set debug SESSION variable for ER_BACKUP_READ_LOC_2
+#
+SET SESSION debug="+d,ER_BACKUP_READ_LOC_2";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Can't read backup location 'backup_test_orig.bak'
+#
+# Test case for error ER_BACKUP_READ_LOC_2 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't read backup location 'backup_test_orig.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 67c - testing error ER_BACKUP_READ_LOC_3
+#
+# Set debug SESSION variable for ER_BACKUP_READ_LOC_3
+#
+SET SESSION debug="+d,ER_BACKUP_READ_LOC_3";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Can't read backup location 'backup_test_orig.bak'
+#
+# Test case for error ER_BACKUP_READ_LOC_3 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't read backup location 'backup_test_orig.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 67d - testing error ER_BACKUP_READ_LOC_4
+#
+# Set debug SESSION variable for ER_BACKUP_READ_LOC_4
+#
+SET SESSION debug="+d,ER_BACKUP_READ_LOC_4";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Can't read backup location 'backup_test_orig.bak'
+#
+# Test case for error ER_BACKUP_READ_LOC_4 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't read backup location 'backup_test_orig.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Create a backup compressed image file for some use cases.
+#
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak' WITH COMPRESSION;
+backup_id
+#
+#
+# Test case 67e - testing error ER_BACKUP_READ_LOC_5
+#
+# Set debug SESSION variable for ER_BACKUP_READ_LOC_5
+#
+SET SESSION debug="+d,ER_BACKUP_READ_LOC_5";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Got error 0 '(null)' from inflateInit2
+#
+# Test case for error ER_BACKUP_READ_LOC_5 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Got error 0 '(null)' from inflateInit2
+#		####	Can't read backup location 'backup_test_orig.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 67f - testing error ER_BACKUP_READ_LOC_6
+#
+# Set debug SESSION variable for ER_BACKUP_READ_LOC_6
+#
+SET SESSION debug="+d,ER_BACKUP_READ_LOC_6";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Can't read backup location 'backup_test_orig.bak'
+#
+# Test case for error ER_BACKUP_READ_LOC_6 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't read backup location 'backup_test_orig.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Recreate a backup image file for use with restores.
+#
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak';
+backup_id
+#
+#
+# Test case 67g - testing error ER_BACKUP_READ_LOC_7
+#
+# Set debug SESSION variable for ER_BACKUP_READ_LOC_7
+#
+SET SESSION debug="+d,ER_BACKUP_READ_LOC_7";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Can't read backup location 'backup_test_orig.bak'
+#
+# Test case for error ER_BACKUP_READ_LOC_7 PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Can't read backup location 'backup_test_orig.bak'
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 68 - testing error ER_BACKUP_PREPARE_DRIVER
+#
+# Set debug SESSION variable for ER_BACKUP_PREPARE_DRIVER
+#
+SET SESSION debug="+d,ER_BACKUP_PREPARE_DRIVER";
+#
+# Execute backup
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+ERROR HY000: Default backup driver can't prepare for synchronization
+#
+# Test case for error ER_BACKUP_PREPARE_DRIVER PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Default backup driver can't prepare for synchronization
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running backup - should not fail.
+#
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 69 - testing error ER_BACKUP_UNEXPECTED_DATA
+#
+# Set debug SESSION variable for ER_BACKUP_UNEXPECTED_DATA
+#
+SET SESSION debug="+d,ER_BACKUP_UNEXPECTED_DATA";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Backup image contains no tables, but table data was found in it
+#
+# Test case for error ER_BACKUP_UNEXPECTED_DATA PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup image contains no tables, but table data was found in it
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Test case 70 - testing error ER_BACKUP_WRONG_TABLE_BE
+#
+# Set debug SESSION variable for ER_BACKUP_WRONG_TABLE_BE
+#
+SET SESSION debug="+d,ER_BACKUP_WRONG_TABLE_BE";
+#
+# Execute restore
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+ERROR HY000: Backup image specifies wrong backup engine #1 for one of the tables
+#
+# Test case for error ER_BACKUP_WRONG_TABLE_BE PASSED.
+#
+#
+# Show warning/error from progress and history log
+# if they exist.
+#
+SELECT * FROM mysql.backup_progress WHERE error_num <> 0;
+backup_id	object	error_num	notes
+#		####	Backup image specifies wrong backup engine #1 for one of the tables
+PURGE BACKUP LOGS;
+#
+# Turn off debug SESSION.
+#
+SET SESSION debug="-d";
+#
+# Now demonstrate that the command will work without the
+# debug session tag.
+#
+# Running restore - should not fail.
+#
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
+backup_id
+#
+#
+# Done.
+#
+#
+# Cleanup
+#
+DROP DATABASE backup_test;
+DROP USER 'joe'@'user';

=== modified file 'mysql-test/suite/backup/r/backup_logs.result'
--- a/mysql-test/suite/backup/r/backup_logs.result	2009-08-04 20:12:18 +0000
+++ b/mysql-test/suite/backup/r/backup_logs.result	2009-08-09 21:33:03 +0000
@@ -456,6 +456,28 @@ backup_id	507
 notes	cancel
 backup_id	507
 notes	error
+#
+# Test case - testing error ER_BACKUP_LOGPATH_INVALID
+#
+SET @old_var = @@global.backup_progress_log_file;
+SET @@global.backup_progress_log_file= '/something/not/valid/again';
+ERROR HY000: The path specified for the backup_progress_log_file is invalid.
+SET @@global.backup_progress_log_file= DEFAULT;
+#
+# Test case - testing error ER_BACKUP_LOGPATH_INVALID
+#
+SET @old_var = @@global.backup_history_log_file;
+SET @@global.backup_history_log_file= '/something/not/valid/again';
+ERROR HY000: The path specified for the backup_history_log_file is invalid.
+SET @@global.backup_history_log_file= DEFAULT;
+SET @@global.backup_progress_log_file= DEFAULT;
+#
+# Test case - testing error ER_BACKUP_LOGPATHS
+#
+SET @old_var = @@global.backup_history_log_file;
+SET @@global.backup_history_log_file= @@global.backup_progress_log_file;
+ERROR HY000: The log names for backup_history and backup_progress must be unique.
+SET @@global.backup_history_log_file= DEFAULT;
 SET @@global.log_backup_output = 'TABLE';
 DROP USER 'tom'@'localhost';
 SET DEBUG_SYNC= 'reset';

=== modified file 'mysql-test/suite/backup/r/backup_security.result'
--- a/mysql-test/suite/backup/r/backup_security.result	2009-07-15 19:19:14 +0000
+++ b/mysql-test/suite/backup/r/backup_security.result	2009-08-09 21:33:03 +0000
@@ -1,24 +1,24 @@
 DROP DATABASE IF EXISTS backup_test;
 DROP DATABASE IF EXISTS backup_test_alt;
 #
+# Use the basic data setup in backup_test database.
+#
+#
 # Create database and data to test.
 #
 CREATE DATABASE backup_test;
 CREATE TABLE backup_test.t1 (a char(30)) ENGINE=MEMORY;
-INSERT INTO backup_test.t1 VALUES ("01 Test #1 - privilege");
-INSERT INTO backup_test.t1 VALUES ("02 Test #1 - privilege");
-INSERT INTO backup_test.t1 VALUES ("03 Test #1 - privilege");
-INSERT INTO backup_test.t1 VALUES ("04 Test #1 - privilege");
-INSERT INTO backup_test.t1 VALUES ("05 Test #1 - privilege");
-INSERT INTO backup_test.t1 VALUES ("06 Test #1 - privilege");
-INSERT INTO backup_test.t1 VALUES ("07 Test #1 - privilege");
-CREATE TABLE backup_test.t2 (a char(30)) ENGINE=MEMORY;
-INSERT INTO backup_test.t2 VALUES ("01 Test #2 - privilege");
-INSERT INTO backup_test.t2 VALUES ("02 Test #2 - privilege");
-INSERT INTO backup_test.t2 VALUES ("03 Test #2 - privilege");
-CREATE DATABASE backup_test_alt;
-CREATE TABLE backup_test_alt.t1 (a char(30)) ENGINE=MEMORY;
-INSERT INTO backup_test_alt.t1 VALUES ("01 Test #2 - privilege");
+INSERT INTO backup_test.t1 VALUES ("01 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("02 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("03 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("04 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("05 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("06 Test Basic database example");
+INSERT INTO backup_test.t1 VALUES ("07 Test Basic database example");
+CREATE TABLE backup_test.t2 (a char(30)) ENGINE=MYISAM;
+INSERT INTO backup_test.t2 VALUES ("11 Test Basic database example");
+INSERT INTO backup_test.t2 VALUES ("12 Test Basic database example");
+INSERT INTO backup_test.t2 VALUES ("13 Test Basic database example");
 #
 # Now create more database objects for test.
 #
@@ -31,6 +31,13 @@ CREATE VIEW backup_test.v1 as SELECT * F
 CREATE EVENT backup_test.e1 ON SCHEDULE EVERY 1 YEAR DO
 DELETE FROM backup_test.t1 WHERE a = "not there";
 #
+# Now we need some privileges
+#
+GRANT ALL ON backup_test.* TO 'joe'@'user';
+CREATE DATABASE backup_test_alt;
+CREATE TABLE backup_test_alt.t1 (a char(30)) ENGINE=MEMORY;
+INSERT INTO backup_test_alt.t1 VALUES ("01 Test #2 - privilege");
+#
 # Create users.
 #
 CREATE USER 'bup_no_priv'@'localhost';
@@ -1118,5 +1125,6 @@ DROP USER 'bup_some_priv'@'localhost';
 DROP USER 'bup_select_priv'@'localhost';
 DROP USER 'bup_full_priv'@'localhost';
 DROP USER 'bup_other_priv'@'localhost';
+DROP USER 'joe'@'user';
 DROP DATABASE backup_test;
 FLUSH PRIVILEGES;

=== added file 'mysql-test/suite/backup/t/backup_errors_debug_1.test'
--- a/mysql-test/suite/backup/t/backup_errors_debug_1.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_errors_debug_1.test	2009-08-20 19:53:25 +0000
@@ -0,0 +1,313 @@
+#
+# This test includes tests for error messages not covered by the
+# other dedicated tests. The test cases for this test include
+# cases that use one of the following methods:
+#
+#   a) debug insertion - forcing an error to signal using
+#      DBUG_EXECUTE_IF()
+#   b) error detection insertion - forcing the error conditions
+#      to be true using DBUG_EXECUTE_IF()
+#   c) direct error generation - a test case can be made to 
+#      manifest the error using only SQL and backup commands
+#
+# The test cases are executing using an include file that 
+# encapsulates the mechanism for trapping and executing the test
+# case. The mechanism used requires setting the SESSION string to
+# the name of the error message which matches a call to 
+# DBUG_EXECUTE_IF() in the source code.
+#
+# This test file is part 1 of 3.
+#
+# Part 1 of 3 : covers test cases 01 - 23.
+# Part 2 of 3 : covers test cases 24 - 48.
+# Part 3 of 3 : covers test cases 49 - 70.
+#
+# The errors to be tested are:
+#
+# Debug Insertion
+# ---------------
+#  1. ER_BACKUP_BINLOG
+#     Note: Test cannot be run due to flaw in error handling. 
+#     See BUG#46574. Test case must be added when bug is fixed.
+#  2. ER_BACKUP_CANT_RESTORE_DB
+#  3. ER_BACKUP_CANT_RESTORE_EVENT
+#  4. ER_BACKUP_CANT_RESTORE_PRIV
+#  5. ER_BACKUP_CANT_RESTORE_SROUT
+#  6. ER_BACKUP_CANT_RESTORE_TS 
+#  7. ER_BACKUP_GET_META_EVENT
+#  8. ER_BACKUP_GET_META_PRIV
+#  9. ER_BACKUP_GET_META_SROUT
+# 10. ER_BACKUP_GET_META_TABLE
+# 11. ER_BACKUP_GET_META_TS
+#
+# Error Condition Insertion
+# -------------------------
+# 12. ER_BACKUP_INIT_BACKUP_DRIVER
+# 13. ER_BACKUP_INIT_RESTORE_DRIVER
+# 14. ER_BACKUP_LOG_WRITE_ERROR
+# 15. ER_BACKUP_FAILED_TO_INIT_COMPRESSION
+# 16. ER_BACKUP_OPEN_RD
+# 17. ER_BACKUP_OPEN_WR
+# 18. ER_RESTORE_CANNOT_START_SLAVE 
+#     Note: This case is in rpl_backup_errors_debug test.
+# 19. ER_BACKUP_NOTHING_TO_BACKUP
+# 20. ER_BACKUP_BACKUP
+# 21. ER_BACKUP_BACKUP_PREPARE
+# 22. ER_BACKUP_CANT_FIND_SE
+# 23. ER_BACKUP_CAT_ENUM
+#
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source suite/backup/include/error_name_to_number.inc
+
+let $MYSQLD_BACKUPDIR= `select @@backupdir`;
+
+disable_query_log;
+call mtr.add_suppression("Backup:");
+call mtr.add_suppression("Restore:");
+enable_query_log;
+
+connect (conn_root,localhost,root,,);
+
+--disable_warnings
+DROP DATABASE IF EXISTS backup_test;
+--enable_warnings
+
+--echo #
+--echo # Use the basic data setup in backup_test database.
+--echo #
+--source suite/backup/include/basic_data.inc
+
+--echo #
+--echo # Create a backup image file for use with restores.
+--echo #
+--replace_column 1 #
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak';
+
+PURGE BACKUP LOGS;
+
+--echo #
+--echo # Begin test cases.
+--echo #
+
+#
+# Set options to defaults
+#
+LET $suppress = OFF;
+LET $compress = OFF;
+
+#
+# Notice: Test case 1 disabled. See BUG#46574.
+#
+# Test for error ER_BACKUP_BINLOG.
+LET $caseno = 1;
+LET $errno = $ER_BACKUP_BINLOG;
+LET $errname = ER_BACKUP_BINLOG;
+LET $operation = BACKUP;
+#--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CANT_RESTORE_DB.
+LET $caseno = 2;
+LET $errno = $ER_BACKUP_CANT_RESTORE_DB;
+LET $errname = ER_BACKUP_CANT_RESTORE_DB;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CANT_RESTORE_EVENT.
+LET $caseno = 3a;
+LET $errno = $ER_BACKUP_CANT_RESTORE_EVENT;
+LET $errname = ER_BACKUP_CANT_RESTORE_EVENT_1;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CANT_RESTORE_EVENT.
+LET $caseno = 3b;
+LET $errno = $ER_BACKUP_CANT_RESTORE_EVENT;
+LET $errname = ER_BACKUP_CANT_RESTORE_EVENT_2;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CANT_RESTORE_PRIV.
+LET $caseno = 4;
+LET $errno = $ER_BACKUP_CANT_RESTORE_PRIV;
+LET $errname = ER_BACKUP_CANT_RESTORE_PRIV;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CANT_RESTORE_SROUT.
+LET $caseno = 5a;
+LET $errno = $ER_BACKUP_CANT_RESTORE_SROUT;
+LET $errname = ER_BACKUP_CANT_RESTORE_SROUT_P;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CANT_RESTORE_SROUT.
+LET $caseno = 5b;
+LET $errno = $ER_BACKUP_CANT_RESTORE_SROUT;
+LET $errname = ER_BACKUP_CANT_RESTORE_SROUT_F;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CANT_RESTORE_TS.
+LET $caseno = 6;
+LET $errno = $ER_BACKUP_CANT_RESTORE_TS;
+LET $errname = ER_BACKUP_CANT_RESTORE_TS;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_GET_META_EVENT.
+LET $caseno = 7;
+LET $errno = $ER_BACKUP_GET_META_EVENT;
+LET $errname = ER_BACKUP_GET_META_EVENT;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_GET_META_PRIV.
+LET $caseno = 8;
+LET $errno = $ER_BACKUP_GET_META_PRIV;
+LET $errname = ER_BACKUP_GET_META_PRIV;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_GET_META_SROUT.
+LET $caseno = 9a;
+LET $errno = $ER_BACKUP_GET_META_SROUT;
+LET $errname = ER_BACKUP_GET_META_SROUT_P;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_GET_META_SROUT.
+LET $caseno = 9b;
+LET $errno = $ER_BACKUP_GET_META_SROUT;
+LET $errname = ER_BACKUP_GET_META_SROUT_F;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_GET_META_TABLE.
+LET $caseno = 10;
+LET $errno = $ER_BACKUP_GET_META_TABLE;
+LET $errname = ER_BACKUP_GET_META_TABLE;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_GET_META_TS.
+LET $caseno = 11;
+LET $errno = $ER_BACKUP_GET_META_TS;
+LET $errname = ER_BACKUP_GET_META_TS;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_INIT_BACKUP_DRIVER.
+LET $caseno = 12;
+LET $errno = $ER_BACKUP_INIT_BACKUP_DRIVER;
+LET $errname = ER_BACKUP_INIT_BACKUP_DRIVER;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_INIT_RESTORE_DRIVER.
+LET $caseno = 13;
+LET $errno = $ER_BACKUP_INIT_RESTORE_DRIVER;
+LET $errname = ER_BACKUP_INIT_RESTORE_DRIVER;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LOG_WRITE_ERROR.
+LET $caseno = 14a;
+# This error is a warning only. Operation will succeed.
+LET $errno = 0;
+LET $errname = ER_BACKUP_LOG_WRITE_ERROR_H;
+LET $operation = BACKUP;
+LET $suppress = ON;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LOG_WRITE_ERROR.
+LET $caseno = 14b;
+# This error is a warning only. Operation will succeed.
+LET $errno = 0;
+LET $errname = ER_BACKUP_LOG_WRITE_ERROR_P;
+LET $operation = BACKUP;
+LET $suppress = ON;
+--source suite/backup/include/test_for_error.inc
+LET $suppress = OFF;
+
+# Test for error ER_BACKUP_FAILED_TO_INIT_COMPRESSION.
+LET $caseno = 15;
+LET $errno = $ER_BACKUP_FAILED_TO_INIT_COMPRESSION;
+LET $errname = ER_BACKUP_FAILED_TO_INIT_COMPRESSION;
+LET $operation = BACKUP;
+LET $compress = ON;
+--source suite/backup/include/test_for_error.inc
+LET $compress = OFF;
+
+# Test for error ER_BACKUP_OPEN_RD.
+LET $caseno = 16;
+LET $errno = $ER_BACKUP_OPEN_RD;
+LET $errname = ER_BACKUP_OPEN_RD;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_OPEN_WR.
+LET $caseno = 17;
+LET $errno = $ER_BACKUP_OPEN_WR;
+LET $errname = ER_BACKUP_OPEN_WR;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_NOTHING_TO_BACKUP.
+LET $caseno = 19;
+LET $errno = $ER_BACKUP_NOTHING_TO_BACKUP;
+LET $errname = ER_BACKUP_NOTHING_TO_BACKUP;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_BACKUP.
+LET $caseno = 20;
+LET $errno = $ER_BACKUP_BACKUP;
+LET $errname = ER_BACKUP_BACKUP;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_BACKUP_PREPARE.
+LET $caseno = 21a;
+LET $errno = $ER_BACKUP_BACKUP_PREPARE;
+LET $errname = ER_BACKUP_BACKUP_PREPARE_1;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_BACKUP_PREPARE.
+LET $caseno = 21b;
+LET $errno = $ER_BACKUP_BACKUP_PREPARE;
+LET $errname = ER_BACKUP_BACKUP_PREPARE_2;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_BACKUP_PREPARE.
+LET $caseno = 21c;
+LET $errno = $ER_BACKUP_BACKUP_PREPARE;
+LET $errname = ER_BACKUP_BACKUP_PREPARE_3;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CANT_FIND_SE.
+LET $caseno = 22;
+LET $errno = $ER_BACKUP_CANT_FIND_SE;
+LET $errname = ER_BACKUP_CANT_FIND_SE;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CAT_ENUM.
+LET $caseno = 23;
+LET $errno = $ER_BACKUP_CAT_ENUM;
+LET $errname = ER_BACKUP_CAT_ENUM;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+--echo #
+--echo # Cleanup
+--echo #
+
+DROP DATABASE backup_test;
+DROP USER 'joe'@'user';
+
+remove_file $MYSQLD_BACKUPDIR/backup_test_orig.bak;

=== added file 'mysql-test/suite/backup/t/backup_errors_debug_2.test'
--- a/mysql-test/suite/backup/t/backup_errors_debug_2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_errors_debug_2.test	2009-08-20 19:53:25 +0000
@@ -0,0 +1,363 @@
+#
+# This test includes tests for error messages not covered by the
+# other dedicated tests. The test cases for this test include
+# cases that use one of the following methods:
+#
+#   a) debug insertion - forcing an error to signal using
+#      DBUG_EXECUTE_IF()
+#   b) error detection insertion - forcing the error conditions
+#      to be true using DBUG_EXECUTE_IF()
+#   c) direct error generation - a test case can be made to 
+#      manifest the error using only SQL and backup commands
+#
+# The test cases are executing using an include file that 
+# encapsulates the mechanism for trapping and executing the test
+# case. The mechanism used requires setting the SESSION string to
+# the name of the error message which matches a call to 
+# DBUG_EXECUTE_IF() in the source code.
+#
+# This test file is part 2 of 3.
+#
+# Part 1 of 3 : covers test cases 01 - 23.
+# Part 2 of 3 : covers test cases 24 - 48.
+# Part 3 of 3 : covers test cases 49 - 70.
+#
+# The errors to be tested are:
+#
+# Debug Insertion
+# ---------------
+# 24. ER_BACKUP_CATALOG_ADD_EVENT
+# 25. ER_BACKUP_CATALOG_ADD_PRIV
+# 26. ER_BACKUP_CATALOG_ADD_SROUT
+# 27. ER_BACKUP_CATALOG_ADD_TABLE
+# 28. ER_BACKUP_CATALOG_ADD_TRIGGER
+# 29. ER_BACKUP_CATALOG_ADD_TS
+#
+# Error Condition Insertion
+# -------------------------
+# 30. ER_BACKUP_CLOSE
+# 31. ER_BACKUP_CONTEXT_CREATE
+#     Test case disabled -- see BUG#46588 
+# 32. ER_BACKUP_CONTEXT_REMOVE
+# 33. ER_BACKUP_CREATE_BACKUP_DRIVER
+# 34. ER_BACKUP_CREATE_BE
+# 35. ER_BACKUP_CREATE_RESTORE_DRIVER
+# 36. ER_BACKUP_CREATE_VP
+# 37. ER_BACKUP_INTERRUPTED
+# 38. ER_BACKUP_LIST_DB_EVENTS
+# 39. ER_BACKUP_LIST_DB_PRIV
+# 40. ER_BACKUP_LIST_DB_SROUT
+# 41. ER_BACKUP_LIST_DB_TABLES
+# 42. ER_BACKUP_LIST_DB_TRIGGERS
+# 43. ER_BACKUP_LIST_DB_VIEWS
+# 44. ER_BACKUP_LIST_DBS
+# 45. ER_BACKUP_LOGS_DELETED
+#     Note: This test case is in backup_logs because it is a console message
+#     and not an error message. Listed here to record the fact that it is 
+#     included in the test suite.
+# 46. ER_BACKUP_LOGS_TRUNCATED
+#     Note: This test case is in backup_logs because it is a console message
+#     and not an error message. Listed here to record the fact that it is 
+#     included in the test suite.
+# 47. ER_BACKUP_NO_BACKUP_DRIVER
+# 48. ER_BACKUP_NO_NATIVE_BE
+#
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source suite/backup/include/error_name_to_number.inc
+
+let $MYSQLD_BACKUPDIR= `select @@backupdir`;
+
+disable_query_log;
+call mtr.add_suppression("Backup:");
+call mtr.add_suppression("Restore:");
+enable_query_log;
+
+connect (conn_root,localhost,root,,);
+
+--disable_warnings
+DROP DATABASE IF EXISTS backup_test;
+--enable_warnings
+
+--echo #
+--echo # Use the basic data setup in backup_test database.
+--echo #
+--source suite/backup/include/basic_data.inc
+
+--echo #
+--echo # Create a backup image file for use with restores.
+--echo #
+--replace_column 1 #
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak';
+
+PURGE BACKUP LOGS;
+
+--echo #
+--echo # Begin test cases.
+--echo #
+
+#
+# Set options to defaults
+#
+LET $suppress = OFF;
+LET $compress = OFF;
+
+# Test for error ER_BACKUP_CATALOG_ADD_EVENT.
+LET $caseno = 24;
+LET $errno = $ER_BACKUP_CATALOG_ADD_EVENT;
+LET $errname = ER_BACKUP_CATALOG_ADD_EVENT;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CATALOG_ADD_PRIV.
+LET $caseno = 2;
+LET $errno = $ER_BACKUP_CATALOG_ADD_PRIV;
+LET $errname = ER_BACKUP_CATALOG_ADD_PRIV;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CATALOG_ADD_SROUT.
+LET $caseno = 26a;
+LET $errno = $ER_BACKUP_CATALOG_ADD_SROUT;
+LET $errname = ER_BACKUP_CATALOG_ADD_SROUT_F;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CATALOG_ADD_SROUT.
+LET $caseno = 26b;
+LET $errno = $ER_BACKUP_CATALOG_ADD_SROUT;
+LET $errname = ER_BACKUP_CATALOG_ADD_SROUT_P;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CATALOG_ADD_TABLE.
+LET $caseno = 27;
+LET $errno = $ER_BACKUP_CATALOG_ADD_TABLE;
+LET $errname = ER_BACKUP_CATALOG_ADD_TABLE;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CATALOG_ADD_TRIGGER.
+LET $caseno = 28;
+LET $errno = $ER_BACKUP_CATALOG_ADD_TRIGGER;
+LET $errname = ER_BACKUP_CATALOG_ADD_TRIGGER;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CATALOG_ADD_TS.
+LET $caseno = 29;
+LET $errno = $ER_BACKUP_CATALOG_ADD_TS;
+LET $errname = ER_BACKUP_CATALOG_ADD_TS;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+#
+# Test case 30 must be run once for backup and once for restore.
+#
+# Test for error ER_BACKUP_CLOSE.
+LET $caseno = 30a;
+LET $errno = $ER_BACKUP_CLOSE;
+LET $errname = ER_BACKUP_CLOSE_1;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CLOSE.
+LET $caseno = 30b;
+LET $errno = $ER_BACKUP_CLOSE;
+LET $errname = ER_BACKUP_CLOSE_2;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+#
+# Test case 31 must be run once for backup and once for restore.
+#
+# Test case disabled due to BUG#46588
+#
+# Test for error ER_BACKUP_CONTEXT_CREATE.
+LET $caseno = 31a;
+LET $errno = $ER_BACKUP_CONTEXT_CREATE;
+LET $errname = ER_BACKUP_CONTEXT_CREATE;
+LET $operation = BACKUP;
+#--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CONTEXT_CREATE.
+LET $caseno = 31b;
+LET $errno = $ER_BACKUP_CONTEXT_CREATE;
+LET $errname = ER_BACKUP_CONTEXT_CREATE;
+LET $operation = RESTORE;
+#--source suite/backup/include/test_for_error.inc
+
+#
+# Test case 32 must be run once for backup and once for restore.
+#
+# Test for error ER_BACKUP_CONTEXT_REMOVE.
+LET $caseno = 32a;
+LET $errno = $ER_BACKUP_CONTEXT_REMOVE;
+LET $errname = ER_BACKUP_CONTEXT_REMOVE;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CONTEXT_REMOVE.
+LET $caseno = 32b;
+LET $errno = $ER_BACKUP_CONTEXT_REMOVE;
+LET $errname = ER_BACKUP_CONTEXT_REMOVE;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CREATE_BACKUP_DRIVER.
+LET $caseno = 33;
+LET $errno = $ER_BACKUP_CREATE_BACKUP_DRIVER;
+LET $errname = ER_BACKUP_CREATE_BACKUP_DRIVER;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CREATE_BE.
+LET $caseno = 34;
+# This error is a warning only. Operation will succeed.
+LET $errno = 0;
+LET $errname = ER_BACKUP_CREATE_BE;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CREATE_RESTORE_DRIVER.
+LET $caseno = 35;
+LET $errno = $ER_BACKUP_CREATE_RESTORE_DRIVER;
+LET $errname = ER_BACKUP_CREATE_RESTORE_DRIVER;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_CREATE_VP.
+LET $caseno = 36;
+LET $errno = $ER_BACKUP_CREATE_VP;
+LET $errname = ER_BACKUP_CREATE_VP;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+#
+# Note: The error ER_BACKUP_CONTEXT_CREATE masks ER_BACKUP_INTERRUPTED
+#
+# Test for error ER_BACKUP_INTERRUPTED.
+LET $caseno = 37;
+LET $errno = $ER_BACKUP_CONTEXT_CREATE;
+LET $errname = ER_BACKUP_INTERRUPTED;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LIST_DB_EVENTS.
+LET $caseno = 38;
+LET $errno = $ER_BACKUP_LIST_DB_EVENTS;
+LET $errname = ER_BACKUP_LIST_DB_EVENTS;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LIST_DB_PRIV.
+LET $caseno = 39;
+LET $errno = $ER_BACKUP_LIST_DB_PRIV;
+LET $errname = ER_BACKUP_LIST_DB_PRIV;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LIST_DB_SROUT.
+LET $caseno = 40a;
+LET $errno = $ER_BACKUP_LIST_DB_SROUT;
+LET $errname = ER_BACKUP_LIST_DB_SROUT_F;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LIST_DB_SROUT.
+LET $caseno = 40b;
+LET $errno = $ER_BACKUP_LIST_DB_SROUT;
+LET $errname = ER_BACKUP_LIST_DB_SROUT_P;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LIST_DB_TABLES.
+LET $caseno = 41;
+LET $errno = $ER_BACKUP_LIST_DB_TABLES;
+LET $errname = ER_BACKUP_LIST_DB_TABLES;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LIST_DB_TRIGGERS.
+LET $caseno = 42;
+LET $errno = $ER_BACKUP_LIST_DB_TRIGGERS;
+LET $errname = ER_BACKUP_LIST_DB_TRIGGERS;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LIST_DB_VIEWS.
+LET $caseno = 43;
+LET $errno = $ER_BACKUP_LIST_DB_VIEWS;
+LET $errname = ER_BACKUP_LIST_DB_VIEWS;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LIST_DBS.
+# 
+# Note: This is a special case that requires executiuon of the
+#       BACKUP DATABASE * command. Thus, this is given its own test case
+#       execution.
+#
+--echo #
+--echo # Test case 44 - testing error ER_BACKUP_LIST_DBS
+--echo #
+--echo # Set debug SESSION variable for ER_BACKUP_LIST_DBS
+--echo #
+eval SET SESSION debug="+d,ER_BACKUP_LIST_DBS";
+
+--echo #
+--echo # Execute backup
+--echo #
+--disable_abort_on_error
+--replace_column 1 #
+--error ER_BACKUP_LIST_DBS
+BACKUP DATABASE * TO 'backup_test_err.bak';
+
+--replace_column 2 ####
+SHOW ERRORS;
+--replace_column 2 ####
+SHOW WARNINGS;
+
+--echo #
+--echo # Turn off debug SESSION.
+--echo #
+SET SESSION debug="-d";
+
+--echo #
+--echo # Now demonstrate that the command will work without the
+--echo # debug session tag.
+--echo #
+--echo # Running backup - should not fail.
+--echo #
+--replace_column 1 #
+BACKUP DATABASE backup_test TO 'backup_test_err.bak';
+
+remove_file $MYSQLD_BACKUPDIR/backup_test_err.bak;
+
+--echo #
+--echo # Done.
+--echo #
+
+# Test for error ER_BACKUP_NO_BACKUP_DRIVER.
+LET $caseno = 47;
+LET $errno = $ER_BACKUP_NO_BACKUP_DRIVER;
+LET $errname = ER_BACKUP_NO_BACKUP_DRIVER;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_NO_NATIVE_BE.
+LET $caseno = 48;
+LET $errno = $ER_BACKUP_NO_NATIVE_BE;
+LET $errname = ER_BACKUP_NO_NATIVE_BE;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+--echo #
+--echo # Cleanup
+--echo #
+
+DROP DATABASE backup_test;
+DROP USER 'joe'@'user';
+
+remove_file $MYSQLD_BACKUPDIR/backup_test_orig.bak;

=== added file 'mysql-test/suite/backup/t/backup_errors_debug_3.test'
--- a/mysql-test/suite/backup/t/backup_errors_debug_3.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_errors_debug_3.test	2009-08-20 19:53:25 +0000
@@ -0,0 +1,374 @@
+#
+# This test includes tests for error messages not covered by the
+# other dedicated tests. The test cases for this test include
+# cases that use one of the following methods:
+#
+#   a) debug insertion - forcing an error to signal using
+#      DBUG_EXECUTE_IF()
+#   b) error detection insertion - forcing the error conditions
+#      to be true using DBUG_EXECUTE_IF()
+#   c) direct error generation - a test case can be made to 
+#      manifest the error using only SQL and backup commands
+#
+# The test cases are executing using an include file that 
+# encapsulates the mechanism for trapping and executing the test
+# case. The mechanism used requires setting the SESSION string to
+# the name of the error message which matches a call to 
+# DBUG_EXECUTE_IF() in the source code.
+#
+# This test file is part 3 of 3.
+#
+# Part 1 of 3 : covers test cases 01 - 23.
+# Part 2 of 3 : covers test cases 24 - 48.
+# Part 3 of 3 : covers test cases 49 - 70.
+#
+# The errors to be tested are:
+#
+# Error Condition Insertion
+# -------------------------
+# 49. ER_BACKUP_RESTORE
+# 50. ER_BACKUP_RESTORE_PREPARE
+# 51. ER_BACKUP_RESTORE_START
+#     Note: This test case is in backup_logs because it is a console message
+#     and not an error message. Listed here to record the fact that it is 
+#     included in the test suite.
+# 52. ER_BACKUP_SEND_DATA_RETRY
+# 53. ER_BACKUP_SEND_REPLY
+# 54. ER_BACKUP_STOP_BACKUP_DRIVER
+# 55. ER_BACKUP_STOP_RESTORE_DRIVERS
+# 56. ER_BACKUP_TOO_MANY_IMAGES
+# 57. ER_BACKUP_UNKNOWN_BE
+# 58. ER_BACKUP_UNKNOWN_OBJECT
+# 59. ER_BACKUP_UNKNOWN_OBJECT_TYPE
+# 60. ER_BACKUP_UNLOCK_DRIVER
+# 61. ER_BACKUP_WRITE_DATA
+# 62. ER_BACKUP_WRITE_HEADER
+# 63. ER_BACKUP_WRITE_SUMMARY
+# 64. ER_BACKUP_BAD_MAGIC
+# 65. ER_BACKUP_GET_BUF
+# 66. ER_BACKUP_LOGGER_INIT
+# 67. ER_BACKUP_READ_LOC
+# 68. ER_BACKUP_PREPARE_DRIVER
+#
+# Debug Insertion
+# ---------------
+# 69. ER_BACKUP_UNEXPECTED_DATA
+# 70. ER_BACKUP_WRONG_TABLE_BE
+#
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source suite/backup/include/error_name_to_number.inc
+
+let $MYSQLD_BACKUPDIR= `select @@backupdir`;
+
+disable_query_log;
+call mtr.add_suppression("Backup:");
+call mtr.add_suppression("Restore:");
+enable_query_log;
+
+connect (conn_root,localhost,root,,);
+
+--disable_warnings
+DROP DATABASE IF EXISTS backup_test;
+--enable_warnings
+
+--echo #
+--echo # Use the basic data setup in backup_test database.
+--echo #
+--source suite/backup/include/basic_data.inc
+
+--echo #
+--echo # Create a backup image file for use with restores.
+--echo #
+--replace_column 1 #
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak';
+
+PURGE BACKUP LOGS;
+
+--echo #
+--echo # Begin test cases.
+--echo #
+
+#
+# Set options to defaults
+#
+LET $suppress = OFF;
+LET $compress = OFF;
+
+# Test for error ER_BACKUP_RESTORE.
+LET $caseno = 49a;
+LET $errno = $ER_BACKUP_RESTORE;
+LET $errname = ER_BACKUP_RESTORE_1;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_RESTORE.
+LET $caseno = 49b;
+LET $errno = $ER_BACKUP_RESTORE;
+LET $errname = ER_BACKUP_RESTORE_2;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_RESTORE_PREPARE.
+LET $caseno = 50a;
+LET $errno = $ER_BACKUP_RESTORE_PREPARE;
+LET $errname = ER_BACKUP_RESTORE_PREPARE_1;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_RESTORE_PREPARE.
+LET $caseno = 50b;
+LET $errno = $ER_BACKUP_RESTORE_PREPARE;
+LET $errname = ER_BACKUP_RESTORE_PREPARE_2;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_SEND_DATA_RETRY.
+LET $caseno = 52;
+LET $errno = $ER_BACKUP_SEND_DATA_RETRY;
+LET $errname = ER_BACKUP_SEND_DATA_RETRY;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_SEND_REPLY.
+LET $caseno = 53a;
+LET $errno = $ER_BACKUP_SEND_REPLY;
+LET $errname = ER_BACKUP_SEND_REPLY_1;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_SEND_REPLY.
+LET $caseno = 53b;
+LET $errno = $ER_BACKUP_SEND_REPLY;
+LET $errname = ER_BACKUP_SEND_REPLY_2;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_SEND_REPLY.
+LET $caseno = 53c;
+LET $errno = $ER_BACKUP_SEND_REPLY;
+LET $errname = ER_BACKUP_SEND_REPLY_1;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_SEND_REPLY.
+LET $caseno = 53d;
+LET $errno = $ER_BACKUP_SEND_REPLY;
+LET $errname = ER_BACKUP_SEND_REPLY_2;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_STOP_BACKUP_DRIVER.
+LET $caseno = 54;
+LET $errno = $ER_BACKUP_STOP_BACKUP_DRIVER;
+LET $errname = ER_BACKUP_STOP_BACKUP_DRIVER;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_STOP_RESTORE_DRIVERS.
+LET $caseno = 55;
+LET $errno = $ER_BACKUP_STOP_RESTORE_DRIVERS;
+LET $errname = ER_BACKUP_STOP_RESTORE_DRIVERS;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_TOO_MANY_IMAGES.
+LET $caseno = 56;
+LET $errno = $ER_BACKUP_TOO_MANY_IMAGES;
+LET $errname = ER_BACKUP_TOO_MANY_IMAGES;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_UNKNOWN_BE.
+LET $caseno = 57;
+LET $errno = $ER_BACKUP_UNKNOWN_BE;
+LET $errname = ER_BACKUP_UNKNOWN_BE;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_UNKNOWN_OBJECT.
+LET $caseno = 58;
+LET $errno = $ER_BACKUP_UNKNOWN_OBJECT;
+LET $errname = ER_BACKUP_UNKNOWN_OBJECT;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_UNKNOWN_OBJECT_TYPE.
+LET $caseno = 59;
+LET $errno = $ER_BACKUP_UNKNOWN_OBJECT_TYPE;
+LET $errname = ER_BACKUP_UNKNOWN_OBJECT_TYPE;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_UNLOCK_DRIVER.
+LET $caseno = 60;
+LET $errno = $ER_BACKUP_UNLOCK_DRIVER;
+LET $errname = ER_BACKUP_UNLOCK_DRIVER;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_WRITE_DATA.
+LET $caseno = 61;
+LET $errno = $ER_BACKUP_WRITE_DATA;
+LET $errname = ER_BACKUP_WRITE_DATA;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_WRITE_HEADER.
+LET $caseno = 62a;
+LET $errno = $ER_BACKUP_WRITE_HEADER;
+LET $errname = ER_BACKUP_WRITE_HEADER_1;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_WRITE_HEADER.
+LET $caseno = 62b;
+LET $errno = $ER_BACKUP_WRITE_HEADER;
+LET $errname = ER_BACKUP_WRITE_HEADER_2;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_WRITE_SUMMARY.
+LET $caseno = 63;
+LET $errno = $ER_BACKUP_WRITE_SUMMARY;
+LET $errname = ER_BACKUP_WRITE_SUMMARY;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_BAD_MAGIC.
+LET $caseno = 64;
+LET $errno = $ER_BACKUP_BAD_MAGIC;
+LET $errname = ER_BACKUP_BAD_MAGIC;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_GET_BUF.
+LET $caseno = 65;
+LET $errno = $ER_BACKUP_GET_BUF;
+LET $errname = ER_BACKUP_GET_BUF;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+#
+# Note: The ERROR ER_BACKUP_LOGGER_INIT is masked by the 
+#       ER_BACKUP_BACKUP_PREPARE (case 67a) and
+#       ER_BACKUP_RESTORE_PREPARE (case 67b) error handling.
+#
+# Test for error ER_BACKUP_LOGGER_INIT.
+LET $caseno = 66a;
+LET $errno = $ER_BACKUP_BACKUP_PREPARE;
+LET $errname = ER_BACKUP_LOGGER_INIT_1;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_LOGGER_INIT.
+LET $caseno = 66b;
+LET $errno = $ER_BACKUP_RESTORE_PREPARE;
+LET $errname = ER_BACKUP_LOGGER_INIT_2;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_READ_LOC.
+LET $caseno = 67a;
+LET $errno = $ER_BACKUP_READ_LOC;
+LET $errname = ER_BACKUP_READ_LOC_1;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_READ_LOC.
+LET $caseno = 67b;
+LET $errno = $ER_BACKUP_READ_LOC;
+LET $errname = ER_BACKUP_READ_LOC_2;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_READ_LOC.
+LET $caseno = 67c;
+LET $errno = $ER_BACKUP_READ_LOC;
+LET $errname = ER_BACKUP_READ_LOC_3;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_READ_LOC.
+LET $caseno = 67d;
+LET $errno = $ER_BACKUP_READ_LOC;
+LET $errname = ER_BACKUP_READ_LOC_4;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+LET $compress = ON;
+
+remove_file $MYSQLD_BACKUPDIR/backup_test_orig.bak;
+
+--echo #
+--echo # Create a backup compressed image file for some use cases.
+--echo #
+--replace_column 1 #
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak' WITH COMPRESSION;
+
+#
+# Note: The error ER_GET_ERRMSG masks ER_BACKUP_READ_LOC during
+#       restore of a compressed image and failure in inflate
+#       methods.
+#
+# Test for error ER_BACKUP_READ_LOC.
+LET $caseno = 67e;
+LET $errno = $ER_GET_ERRMSG;
+LET $errname = ER_BACKUP_READ_LOC_5;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_READ_LOC.
+LET $caseno = 67f;
+LET $errno = $ER_BACKUP_READ_LOC;
+LET $errname = ER_BACKUP_READ_LOC_6;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+LET $compress = OFF;
+
+remove_file $MYSQLD_BACKUPDIR/backup_test_orig.bak;
+
+--echo #
+--echo # Recreate a backup image file for use with restores.
+--echo #
+--replace_column 1 #
+BACKUP DATABASE backup_test TO 'backup_test_orig.bak';
+
+# Test for error ER_BACKUP_READ_LOC.
+LET $caseno = 67g;
+LET $errno = $ER_BACKUP_READ_LOC;
+LET $errname = ER_BACKUP_READ_LOC_7;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_PREPARE_DRIVER.
+LET $caseno = 68;
+LET $errno = $ER_BACKUP_PREPARE_DRIVER;
+LET $errname = ER_BACKUP_PREPARE_DRIVER;
+LET $operation = BACKUP;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_UNEXPECTED_DATA.
+LET $caseno = 69;
+LET $errno = $ER_BACKUP_UNEXPECTED_DATA;
+LET $errname = ER_BACKUP_UNEXPECTED_DATA;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+# Test for error ER_BACKUP_WRONG_TABLE_BE.
+LET $caseno = 70;
+LET $errno = $ER_BACKUP_WRONG_TABLE_BE;
+LET $errname = ER_BACKUP_WRONG_TABLE_BE;
+LET $operation = RESTORE;
+--source suite/backup/include/test_for_error.inc
+
+--echo #
+--echo # Cleanup
+--echo #
+
+DROP DATABASE backup_test;
+DROP USER 'joe'@'user';
+
+remove_file $MYSQLD_BACKUPDIR/backup_test_orig.bak;

=== modified file 'mysql-test/suite/backup/t/backup_logs.test'
--- a/mysql-test/suite/backup/t/backup_logs.test	2009-08-04 20:12:18 +0000
+++ b/mysql-test/suite/backup/t/backup_logs.test	2009-08-09 21:33:03 +0000
@@ -616,6 +616,41 @@ eval SET debug= '$debug';
 --echo Show error state.
 --query_vertical SELECT backup_id, notes FROM mysql.backup_progress WHERE backup_id = 507
 
+--echo #
+--echo # Test case - testing error ER_BACKUP_LOGPATH_INVALID
+--echo #
+
+SET @old_var = @@global.backup_progress_log_file;
+
+--error ER_BACKUP_LOGPATH_INVALID
+SET @@global.backup_progress_log_file= '/something/not/valid/again';
+
+SET @@global.backup_progress_log_file= DEFAULT;
+
+--echo #
+--echo # Test case - testing error ER_BACKUP_LOGPATH_INVALID
+--echo #
+
+SET @old_var = @@global.backup_history_log_file;
+
+--error ER_BACKUP_LOGPATH_INVALID
+SET @@global.backup_history_log_file= '/something/not/valid/again';
+
+SET @@global.backup_history_log_file= DEFAULT;
+
+SET @@global.backup_progress_log_file= DEFAULT;
+
+--echo #
+--echo # Test case - testing error ER_BACKUP_LOGPATHS
+--echo #
+
+SET @old_var = @@global.backup_history_log_file;
+
+--error ER_BACKUP_LOGPATHS
+SET @@global.backup_history_log_file= @@global.backup_progress_log_file;
+
+SET @@global.backup_history_log_file= DEFAULT;
+
 #
 # Cleanup.
 #

=== modified file 'mysql-test/suite/backup/t/backup_security.test'
--- a/mysql-test/suite/backup/t/backup_security.test	2009-07-15 14:18:59 +0000
+++ b/mysql-test/suite/backup/t/backup_security.test	2009-08-09 21:33:03 +0000
@@ -30,44 +30,15 @@ DROP DATABASE IF EXISTS backup_test_alt;
 --enable_warnings
 
 --echo #
---echo # Create database and data to test.
+--echo # Use the basic data setup in backup_test database.
 --echo #
-CREATE DATABASE backup_test;
-CREATE TABLE backup_test.t1 (a char(30)) ENGINE=MEMORY;
-INSERT INTO backup_test.t1 VALUES ("01 Test #1 - privilege"); 
-INSERT INTO backup_test.t1 VALUES ("02 Test #1 - privilege"); 
-INSERT INTO backup_test.t1 VALUES ("03 Test #1 - privilege"); 
-INSERT INTO backup_test.t1 VALUES ("04 Test #1 - privilege"); 
-INSERT INTO backup_test.t1 VALUES ("05 Test #1 - privilege"); 
-INSERT INTO backup_test.t1 VALUES ("06 Test #1 - privilege"); 
-INSERT INTO backup_test.t1 VALUES ("07 Test #1 - privilege"); 
-
-CREATE TABLE backup_test.t2 (a char(30)) ENGINE=MEMORY;
-INSERT INTO backup_test.t2 VALUES ("01 Test #2 - privilege"); 
-INSERT INTO backup_test.t2 VALUES ("02 Test #2 - privilege"); 
-INSERT INTO backup_test.t2 VALUES ("03 Test #2 - privilege"); 
+--source suite/backup/include/basic_data.inc
 
 CREATE DATABASE backup_test_alt;
 CREATE TABLE backup_test_alt.t1 (a char(30)) ENGINE=MEMORY;
 INSERT INTO backup_test_alt.t1 VALUES ("01 Test #2 - privilege"); 
 
 --echo #
---echo # Now create more database objects for test.
---echo #
-CREATE PROCEDURE backup_test.p1(p1 CHAR(20))
-  INSERT INTO backup_test.t1 VALUES ("50");
-
-CREATE TRIGGER backup_test.trg AFTER INSERT ON backup_test.t1 FOR EACH ROW
- INSERT INTO backup_test.t1 VALUES('Test objects count');
-
-CREATE FUNCTION backup_test.f1() RETURNS INT RETURN (SELECT 1);
-
-CREATE VIEW backup_test.v1 as SELECT * FROM backup_test.t1;
-
-CREATE EVENT backup_test.e1 ON SCHEDULE EVERY 1 YEAR DO
-  DELETE FROM backup_test.t1 WHERE a = "not there";
-
---echo #
 --echo # Create users.
 --echo #
 CREATE USER 'bup_no_priv'@'localhost';
@@ -1008,6 +979,7 @@ DROP USER 'bup_some_priv'@'localhost';
 DROP USER 'bup_select_priv'@'localhost';
 DROP USER 'bup_full_priv'@'localhost';
 DROP USER 'bup_other_priv'@'localhost';
+DROP USER 'joe'@'user';
 
 DROP DATABASE backup_test;
 FLUSH PRIVILEGES;

=== modified file 'sql/backup/backup_info.cc'
--- a/sql/backup/backup_info.cc	2009-07-15 19:19:14 +0000
+++ b/sql/backup/backup_info.cc	2009-08-09 21:33:03 +0000
@@ -242,6 +242,9 @@ Backup_info::find_backup_engine(const ba
     }
   }
 
+  // Error code insertion for ER_BACKUP_NO_BACKUP_DRIVER.
+  DBUG_EXECUTE_IF("ER_BACKUP_NO_BACKUP_DRIVER", snap= 0;);
+
   if (!snap)
     m_log.report_error(ER_BACKUP_NO_BACKUP_DRIVER,tbl.describe(buf));
   
@@ -760,6 +763,9 @@ int Backup_info::add_all_dbs()
 
   Obj_iterator *dbit= get_databases(m_thd);
   
+  // Error code insertion for ER_BACKUP_LIST_DBS.
+  DBUG_EXECUTE_IF("ER_BACKUP_LIST_DBS", dbit= 0;);
+
   if (!dbit)
   {
     m_log.report_error(ER_BACKUP_LIST_DBS);
@@ -847,6 +853,9 @@ int Backup_info::add_db_items(Db &db)
 
   Obj_iterator *it= get_db_tables(m_thd, &db.name());
 
+  // Error code insertion for ER_BACKUP_LIST_DB_TABLES.
+  DBUG_EXECUTE_IF("ER_BACKUP_LIST_DB_TABLES", it= 0;);
+
   if (!it)
   {
     m_log.report_error(ER_BACKUP_LIST_DB_TABLES, db.name().ptr());
@@ -894,6 +903,9 @@ int Backup_info::add_db_items(Db &db)
   delete it;  
   it= get_db_stored_procedures(m_thd, &db.name());
   
+  // Error code insertion for ER_BACKUP_LIST_DB_SROUT.
+  DBUG_EXECUTE_IF("ER_BACKUP_LIST_DB_SROUT_P", it= 0;);
+
   if (!it)
   {
     m_log.report_error(ER_BACKUP_LIST_DB_SROUT, db.name().ptr());
@@ -906,6 +918,9 @@ int Backup_info::add_db_items(Db &db)
   delete it;
   it= get_db_stored_functions(m_thd, &db.name());
 
+  // Error code insertion for ER_BACKUP_LIST_DB_SROUT.
+  DBUG_EXECUTE_IF("ER_BACKUP_LIST_DB_SROUT_F", it= 0;);
+
   if (!it)
   {
     m_log.report_error(ER_BACKUP_LIST_DB_SROUT, db.name().ptr());
@@ -918,6 +933,9 @@ int Backup_info::add_db_items(Db &db)
   delete it;
   it= get_db_views(m_thd, &db.name());
 
+  // Error code insertion for ER_BACKUP_LIST_DB_VIEWS.
+  DBUG_EXECUTE_IF("ER_BACKUP_LIST_DB_VIEWS", it= 0;);
+
   if (!it)
   {
     m_log.report_error(ER_BACKUP_LIST_DB_VIEWS, db.name().ptr());
@@ -930,6 +948,9 @@ int Backup_info::add_db_items(Db &db)
   delete it;
   it= get_db_events(m_thd, &db.name());
 
+  // Error code insertion for ER_BACKUP_LIST_DB_EVENTS.
+  DBUG_EXECUTE_IF("ER_BACKUP_LIST_DB_EVENTS", it= 0;);
+
   if (!it)
   {
     m_log.report_error(ER_BACKUP_LIST_DB_EVENTS, db.name().ptr());
@@ -942,6 +963,9 @@ int Backup_info::add_db_items(Db &db)
   delete it;
   it= get_db_triggers(m_thd, &db.name());
 
+  // Error code insertion for ER_BACKUP_LIST_DB_TRIGGERS.
+  DBUG_EXECUTE_IF("ER_BACKUP_LIST_DB_TRIGGERS", it= 0;);
+
   if (!it)
   {
     m_log.report_error(ER_BACKUP_LIST_DB_TRIGGERS, db.name().ptr());
@@ -954,6 +978,9 @@ int Backup_info::add_db_items(Db &db)
   delete it;
   it= get_all_db_grants(m_thd, &db.name());
 
+  // Error code insertion for ER_BACKUP_LIST_DB_PRIV.
+  DBUG_EXECUTE_IF("ER_BACKUP_LIST_DB_PRIV", it= 0;);
+
   if (!it)
   {
     m_log.report_error(ER_BACKUP_LIST_DB_PRIV, db.name().ptr());
@@ -1031,6 +1058,9 @@ backup::Image_info::Table* Backup_info::
   
   tbl= Image_info::add_table(dbi, t.name(), *snap, pos);
   
+  // Error code insertion for ER_BACKUP_CATALOG_ADD_TABLE.
+  DBUG_EXECUTE_IF("ER_BACKUP_CATALOG_ADD_TABLE", tbl= 0;);
+
   if (!tbl)
   {
     m_log.report_error(ER_BACKUP_CATALOG_ADD_TABLE, 
@@ -1211,6 +1241,39 @@ Backup_info::add_db_object(Db &db, const
 
   int res= get_dep_node(db.name(), *obj->get_name(), type, n);
   
+  /*
+    Debug insertion for errors. Here we setup the error to correspond 
+    with the debug SESSION tag specified in the test.
+
+    Note: Error code insertion won't work here as we need to generate
+          the specific error message for each test case.
+
+    Note: ER_BACKUP_CATALOG_ADD_TABLE is detected elsewhere.
+
+  */
+  ::String str;
+  switch (type) {
+  case BSTREAM_IT_DB:     str.append("ER_BACKUP_CATALOG_ADD_DB"); break;
+  case BSTREAM_IT_VIEW:   str.append("ER_BACKUP_CATALOG_ADD_VIEW"); break;
+  case BSTREAM_IT_SPROC:  str.append("ER_BACKUP_CATALOG_ADD_SROUT_P"); break;
+  case BSTREAM_IT_SFUNC:  str.append("ER_BACKUP_CATALOG_ADD_SROUT_F"); break;
+  case BSTREAM_IT_EVENT:  str.append("ER_BACKUP_CATALOG_ADD_EVENT"); break;
+  case BSTREAM_IT_TRIGGER: str.append("ER_BACKUP_CATALOG_ADD_TRIGGER"); break;
+  case BSTREAM_IT_PRIVILEGE: str.append("ER_BACKUP_CATALOG_ADD_PRIV"); break;
+  default: break;
+  }
+  if (str.ptr())
+  {
+    DBUG_EXECUTE_IF(str.ptr(),
+      m_log.report_error(error, db.name().ptr(), obj->get_name()->ptr());
+      return NULL;);
+  }
+  // Tablespace is a special case since Falcon is disabled.
+  DBUG_EXECUTE_IF("ER_BACKUP_CATALOG_ADD_TS",
+    m_log.report_error(ER_BACKUP_CATALOG_ADD_TS, 
+      "Debug insertion test");
+    return NULL;);
+
   if (res == get_dep_node_res::ERROR)
   {
     m_log.report_error(error, db.name().ptr(), obj->get_name()->ptr());

=== modified file 'sql/backup/be_native.h'
--- a/sql/backup/be_native.h	2008-12-18 21:46:36 +0000
+++ b/sql/backup/be_native.h	2009-08-09 21:33:03 +0000
@@ -96,6 +96,9 @@ int Native_snapshot::init(Logger &log, c
 
   result_t ret= m_hton->get_backup_engine(const_cast<handlerton*>(m_hton), m_be);
 
+  // Error code insertion for ER_BACKUP_CREATE_BE.
+  DBUG_EXECUTE_IF("ER_BACKUP_CREATE_BE", m_be->free(); m_be= 0;);
+
   if (ret != OK || !m_be)
   {
     if (m_be)

=== modified file 'sql/backup/data_backup.cc'
--- a/sql/backup/data_backup.cc	2009-05-21 13:17:37 +0000
+++ b/sql/backup/data_backup.cc	2009-08-20 19:53:25 +0000
@@ -470,6 +470,11 @@ int save_vp_info(Backup_info &info)
   */
   if (mysql_bin_log.is_open())
   {
+
+    DBUG_EXECUTE_IF("ER_BACKUP_BINLOG",
+      info.m_log.report_error(ER_BACKUP_BINLOG);
+      return TRUE;);
+
     if (mysql_bin_log.get_current_log(&binlog_start_pos))
     {
       info.m_log.report_error(ER_BACKUP_BINLOG);
@@ -566,7 +571,12 @@ int write_table_data(THD* thd, Backup_in
       log.report_error(ER_OUT_OF_RESOURCES);
       goto error;
     }
-    if (log.report_killed() || !p->is_valid())
+    int res= !p->is_valid();
+
+    // Error code insertion for ER_BACKUP_CREATE_BACKUP_DRIVER.
+    DBUG_EXECUTE_IF("ER_BACKUP_CREATE_BACKUP_DRIVER", res= 1;);
+
+    if (log.report_killed() || res)
     {
       log.report_error(ER_BACKUP_CREATE_BACKUP_DRIVER,p->m_name);
       delete p;
@@ -1180,7 +1190,12 @@ int Backup_pump::begin()
   state= backup_state::INIT;
   DBUG_PRINT("backup_data",(" %s enters INIT state", m_name));
 
-  if (ERROR == m_drv->begin(m_bw.buf_size))
+  result_t res= m_drv->begin(m_bw.buf_size);
+
+  // Error code insertion for ER_BACKUP_INIT_BACKUP_DRIVER.
+  DBUG_EXECUTE_IF("ER_BACKUP_INIT_BACKUP_DRIVER", res= ERROR;);
+
+  if (res == ERROR)
   {
     state= backup_state::ERROR;
     if (m_log)
@@ -1199,7 +1214,14 @@ int Backup_pump::end()
   {
     DBUG_PRINT("backup_data",(" shutting down %s", m_name));
 
-    if (ERROR == m_drv->end())
+    int res= m_drv->end();
+
+    // Error code insertion for ER_BACKUP_STOP_BACKUP_DRIVER.
+    DBUG_EXECUTE_IF("ER_BACKUP_STOP_BACKUP_DRIVER", 
+      res= ERROR;
+      m_name= "Default";);
+
+    if (res == ERROR)
     {
       state= backup_state::ERROR;
       if (m_log)
@@ -1219,6 +1241,9 @@ int Backup_pump::prepare()
 {
   result_t res= m_drv->prelock();
 
+  // Error code insertion
+  DBUG_EXECUTE_IF("ER_BACKUP_PREPARE_DRIVER", res= ERROR; m_name= "Default";);
+
   switch (res) {
 
   case READY:
@@ -1247,7 +1272,13 @@ int Backup_pump::prepare()
 int Backup_pump::lock()
 {
   DBUG_PRINT("backup_data",(" locking %s", m_name));
-  if (ERROR == m_drv->lock())
+
+  int res= m_drv->lock();
+
+  // Error code insertion for ER_BACKUP_CREATE_VP.
+  DBUG_EXECUTE_IF("ER_BACKUP_CREATE_VP", res= ERROR; m_name= "Default";);
+
+  if (res == ERROR)
   {
     state= backup_state::ERROR;
     if (m_log)
@@ -1264,7 +1295,13 @@ int Backup_pump::unlock()
 {
   DBUG_PRINT("backup_data",(" unlocking %s, goes to FINISHING state", m_name));
   state= backup_state::FINISHING;
-  if (ERROR == m_drv->unlock())
+  
+  int res= m_drv->unlock();
+
+  // Error condition insertion for ER_BACKUP_UNLOCK_DRIVER 
+  DBUG_EXECUTE_IF("ER_BACKUP_UNLOCK_DRIVER", res= ERROR; m_name= "Default";);
+
+  if (res == ERROR)
   {
     state= backup_state::ERROR;
     if (m_log)
@@ -1350,7 +1387,12 @@ int Backup_pump::pump(size_t *howmuch)
        */
 
       if (!m_buf_head)
-        switch (m_bw.get_buf(m_buf)) {
+      {
+        backup::Block_writer::result_t buf_err= m_bw.get_buf(m_buf);
+ 
+        // Error condition insertion for ER_BACKUP_GET_BUF.
+        DBUG_EXECUTE_IF("ER_BACKUP_GET_BUF", buf_err= Block_writer::ERROR;);
+        switch (buf_err) {
 
         case Block_writer::OK:
           m_buf_retries= 0;
@@ -1368,7 +1410,7 @@ int Backup_pump::pump(size_t *howmuch)
           state= backup_state::ERROR;
           return ERROR;
         }
-
+      }
       DBUG_ASSERT(m_buf_head);
 
       result_t res= m_drv->get_data(m_buf);
@@ -1428,7 +1470,14 @@ int Backup_pump::pump(size_t *howmuch)
         && state != backup_state::ERROR
         && state != backup_state::DONE)
     {
-      switch (m_bw.write_buf(m_buf)) {
+      backup::Block_writer::result_t res= m_bw.write_buf(m_buf);
+
+      // Error condition insertion for ER_BACKUP_WRITE_DATA 
+      DBUG_EXECUTE_IF("ER_BACKUP_WRITE_DATA", 
+        res=Block_writer::ERROR;
+        m_name= "Default";);
+
+      switch (res) {
 
       case Block_writer::OK:
 
@@ -1491,6 +1540,12 @@ int restore_table_data(THD *thd, Restore
     function. However, we must call bstream_rd_data_chunk() which will absorb
     the 0x00 byte signalling end of (the empty) table data chunk sequence.
   */ 
+
+  // Debug insertion for ER_BACKUP_UNEXPECTED_DATA.
+  DBUG_EXECUTE_IF("ER_BACKUP_UNEXPECTED_DATA", 
+       info.m_log.report_error(ER_BACKUP_UNEXPECTED_DATA);
+       DBUG_RETURN(ERROR););
+
   if (info.snap_count() == 0 || info.table_count() == 0) // nothing to restore
   {
     int res= bstream_rd_data_chunk(&s, &chunk_info);
@@ -1520,7 +1575,12 @@ int restore_table_data(THD *thd, Restore
    */   
   String bad_drivers;
 
-  if (info.snap_count() > MAX_SNAP_COUNT)
+  int count= info.snap_count();
+
+  // Error code insertion for ER_BACKUP_TOO_MANY_IMAGES.
+  DBUG_EXECUTE_IF("ER_BACKUP_TOO_MANY_IMAGES", count= MAX_SNAP_COUNT + 1;);
+
+  if (count > MAX_SNAP_COUNT)
   {
     log.report_error(ER_BACKUP_TOO_MANY_IMAGES,
                      info.snap_count(), MAX_SNAP_COUNT);
@@ -1544,6 +1604,14 @@ int restore_table_data(THD *thd, Restore
     res= snap->get_restore_driver(drv[n]);
     if (log.report_killed())
       goto error;
+
+    // Error code insertion for ER_BACKUP_CREATE_RESTORE_DRIVER.
+    DBUG_EXECUTE_IF("ER_BACKUP_CREATE_RESTORE_DRIVER", 
+      // Only process the first driver (0) for debug test
+      active[1]= 0; 
+      drv[1]= 0;
+      res= backup::ERROR;);
+
     if (res == backup::ERROR)
     {
       log.report_error(ER_BACKUP_CREATE_RESTORE_DRIVER, snap->name());
@@ -1558,6 +1626,10 @@ int restore_table_data(THD *thd, Restore
     res= drv[n]->begin(0);
     if (log.report_killed())
       goto error;
+
+    // Error code insertion for ER_BACKUP_INIT_RESTORE_DRIVER.
+    DBUG_EXECUTE_IF("ER_BACKUP_INIT_RESTORE_DRIVER", res= backup::ERROR;);
+
     if (res == backup::ERROR)
     {
       log.report_error(ER_BACKUP_INIT_RESTORE_DRIVER, info.m_snap[n]->name());
@@ -1683,6 +1755,11 @@ int restore_table_data(THD *thd, Restore
         case backup::PROCESSING:
         case backup::BUSY:
         default:
+        {
+          // Error code insertion for ER_BACKUP_SEND_DATA_RETRY.
+          DBUG_EXECUTE_IF("ER_BACKUP_SEND_DATA_RETRY", 
+            repeats= (MAX_REPEATS + 1););
+
           if( repeats > MAX_REPEATS )
           {
             log.report_error(ER_BACKUP_SEND_DATA_RETRY, repeats, snap->name());
@@ -1691,6 +1768,7 @@ int restore_table_data(THD *thd, Restore
           repeats++;
           break;
         }
+        }
 
       default:
         break;
@@ -1777,7 +1855,15 @@ finish:  
     This is why we must supply explicit log_level::ERROR to report_error() as
     otherwise the method will report interruption instead of an error.
   */
-  if (!bad_drivers.is_empty())
+
+  int result= !bad_drivers.is_empty();
+
+  // Error code insertion for ER_BACKUP_STOP_RESTORE_DRIVERS.
+  DBUG_EXECUTE_IF("ER_BACKUP_STOP_RESTORE_DRIVERS", 
+    result= 1;
+    state= ERROR;);
+
+  if (result)
     log.report_error(log_level::ERROR, 
                      ER_BACKUP_STOP_RESTORE_DRIVERS, bad_drivers.c_ptr());
 

=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc	2009-08-11 11:09:31 +0000
+++ b/sql/backup/kernel.cc	2009-08-20 19:53:25 +0000
@@ -153,7 +153,12 @@ execute_backup_command(THD *thd, 
 
   Backup_restore_ctx context(thd); // reports errors
   
-  if (!context.is_valid())
+  res= !context.is_valid();
+
+  // Error code insertion for ER_BACKUP_CONTEXT_CREATE.
+  DBUG_EXECUTE_IF("ER_BACKUP_CONTEXT_CREATE", res= 1;);
+
+  if (res)
     DBUG_RETURN(send_error(context, ER_BACKUP_CONTEXT_CREATE));
 
   switch (lex->sql_command) {
@@ -168,6 +173,9 @@ execute_backup_command(THD *thd, 
                                                   lex->backup_compression);
                                                               // reports errors
 
+    // Error condition insertion for ER_BACKUP_BACKUP_PREPARE.
+    DBUG_EXECUTE_IF("ER_BACKUP_BACKUP_PREPARE_1", info= 0;);
+
     if (!info || !info->is_valid())
       DBUG_RETURN(send_error(context, ER_BACKUP_BACKUP_PREPARE));
 
@@ -187,10 +195,18 @@ execute_backup_command(THD *thd, 
 
     DBUG_EXECUTE_IF("kill_backup", thd->killed= THD::KILL_QUERY;); 
 
+    // Error condition insertion for ER_BACKUP_BACKUP_PREPARE.
+    DBUG_EXECUTE_IF("ER_BACKUP_BACKUP_PREPARE_2", res= 1;);
+
     if (res || !info->is_valid())
       DBUG_RETURN(send_error(context, ER_BACKUP_BACKUP_PREPARE));
 
-    if (info->db_count() == 0)
+    int count= info->db_count();
+
+    // Error condition insertion for ER_BACKUP_NOTHING_TO_BACKUP.
+    DBUG_EXECUTE_IF("ER_BACKUP_NOTHING_TO_BACKUP", count= 0;);
+
+    if (count == 0)
     {
       context.report_error(ER_BACKUP_NOTHING_TO_BACKUP);
       DBUG_RETURN(send_error(context, ER_BACKUP_NOTHING_TO_BACKUP));
@@ -202,6 +218,7 @@ execute_backup_command(THD *thd, 
     res= context.do_backup();
  
     DEBUG_SYNC(thd, "after_do_backup");
+    DBUG_EXECUTE_IF("ER_BACKUP_BACKUP", res= 1;);
     if (res)
       DBUG_RETURN(send_error(context, ER_BACKUP_BACKUP));
 
@@ -215,6 +232,9 @@ execute_backup_command(THD *thd, 
     Restore_info *info= context.prepare_for_restore(backupdir, lex->backup_dir, 
                                                     thd->query, skip_gap_event);
     
+    // Error code insertion for ER_BACKUP_RESTORE_PREPARE.
+    DBUG_EXECUTE_IF("ER_BACKUP_RESTORE_PREPARE_2", info= 0;);
+
     if (!info || !info->is_valid())
       DBUG_RETURN(send_error(context, ER_BACKUP_RESTORE_PREPARE));
     
@@ -226,6 +246,9 @@ execute_backup_command(THD *thd, 
 
     DEBUG_SYNC(thd, "restore_before_end");
 
+    // Error code insertion for ER_BACKUP_RESTORE.
+    DBUG_EXECUTE_IF("ER_BACKUP_RESTORE_1", res= 1;);
+
     if (res)
       DBUG_RETURN(send_error(context, ER_BACKUP_RESTORE));
     
@@ -244,6 +267,9 @@ execute_backup_command(THD *thd, 
   res= context.close();
   DEBUG_SYNC(thd, "backup_restore_done");
 
+  // Error code insertion for ER_BACKUP_CONTEXT_REMOVE.
+  DBUG_EXECUTE_IF("ER_BACKUP_CONTEXT_REMOVE", res= 1;);
+
   if (res)
     DBUG_RETURN(send_error(context, ER_BACKUP_CONTEXT_REMOVE));
 
@@ -323,15 +349,28 @@ int send_reply(Backup_restore_ctx &conte
   */
   protocol->prepare_for_resend();               // Never errors
   llstr(context.op_id(), buf);                  // Never errors
-  if (protocol->store(buf, system_charset_info))
+
+  int res= protocol->store(buf, system_charset_info);
+  
+  // Error code insertion for ER_BACKUP_SEND_REPLY.
+  DBUG_EXECUTE_IF("ER_BACKUP_SEND_REPLY_1", res= 1;);
+ 
+  if (res)
   {
     goto err;
   }
-  if (protocol->write())
+
+  res= protocol->write();
+  
+  // Error code insertion for ER_BACKUP_SEND_REPLY.
+  DBUG_EXECUTE_IF("ER_BACKUP_SEND_REPLY_2", res= 1;);
+  
+  if (res)
   {
     goto err;
   }
   my_eof(context.thd());                        // Never errors
+
   DBUG_RETURN(0);
 
  err:
@@ -661,6 +700,10 @@ Backup_restore_ctx::prepare_for_backup(S
   */ 
   DEBUG_SYNC(m_thd, "before_backup_logger_init");
   int ret= Logger::init(BACKUP, query);  // Logs errors   
+
+  // Error condition insertion for ER_BACKUP_LOGGER_INIT.
+  DBUG_EXECUTE_IF("ER_BACKUP_LOGGER_INIT_1", ret= 1;);
+
   if (ret || is_killed())
   {
     fatal_error(report_killed() ? ER_QUERY_INTERRUPTED : ER_BACKUP_LOGGER_INIT);
@@ -696,6 +739,9 @@ Backup_restore_ctx::prepare_for_backup(S
   DEBUG_SYNC(m_thd, "before_backup_stream_open");
   int my_open_status= s->open();
 
+  // Error code insertion for ER_BACKUP_READ_LOC.
+  DBUG_EXECUTE_IF("ER_BACKUP_READ_LOC_1", my_open_status= ER_BACKUP_READ_LOC;);
+  
   /*
     Set state to PREPARED_FOR_BACKUP in case output file was opened successfuly.
     It is important to set the state here, because this ensures that the file
@@ -726,7 +772,13 @@ Backup_restore_ctx::prepare_for_backup(S
     fatal_error(report_error(ER_OUT_OF_RESOURCES));
     return NULL;
   }
-  if (!info->is_valid())
+
+  bool res= info->is_valid();
+
+  // Error condition insertion for ER_BACKUP_BACKUP_PREPARE.
+  DBUG_EXECUTE_IF("ER_BACKUP_BACKUP_PREPARE_3", res= 0;);
+
+  if (!res)
   {
     // Error has been logged by Backup_info constructor
     fatal_error(ER_BACKUP_BACKUP_PREPARE);
@@ -785,6 +837,10 @@ Backup_restore_ctx::prepare_for_restore(
   */ 
   DEBUG_SYNC(m_thd, "before_restore_logger_init");
   int ret= Logger::init(RESTORE, query);  // Logs errors
+
+  // Error condition insertion for ER_BACKUP_LOGGER_INIT.
+  DBUG_EXECUTE_IF("ER_BACKUP_LOGGER_INIT_2", ret= 1;);
+
   if (ret || is_killed())
   {
     fatal_error(ER_BACKUP_LOGGER_INIT);
@@ -831,6 +887,10 @@ Backup_restore_ctx::prepare_for_restore(
   
   DEBUG_SYNC(m_thd, "before_restore_stream_open");
   int my_open_status= s->open();
+
+  // Error code insertion for ER_BACKUP_READ_LOC.
+  DBUG_EXECUTE_IF("ER_BACKUP_READ_LOC_2", my_open_status= ER_BACKUP_READ_LOC;);
+
   if (my_open_status != 0 || is_killed())
   {
     if (report_killed())
@@ -853,7 +913,13 @@ Backup_restore_ctx::prepare_for_restore(
     fatal_error(report_error(ER_OUT_OF_RESOURCES));
     return NULL;
   }
-  if (!info->is_valid())
+
+  int res= !info->is_valid();
+
+  // Error code insertion for ER_BACKUP_RESTORE_PREPARE.
+  DBUG_EXECUTE_IF("ER_BACKUP_RESTORE_PREPARE_1", res= 1;);
+
+  if (res)
   {
     // Errors are logged by Restore_info constructor. 
     fatal_error(ER_BACKUP_RESTORE_PREPARE); 
@@ -1068,6 +1134,8 @@ void Backup_restore_ctx::unlock_tables()
  */ 
 int Backup_restore_ctx::close()
 {
+  int res= 0;
+
   if (m_state == CLOSED)
     return 0;
 
@@ -1082,8 +1150,13 @@ int Backup_restore_ctx::close()
 
   using namespace backup;
 
+  res= m_catalog ? !m_catalog->is_valid() : TRUE;
+
+  // Error code insertion for ER_BACKUP_RESTORE.
+  DBUG_EXECUTE_IF("ER_BACKUP_RESTORE_2", res= 1;);
+
   // Move context to error state if the catalog became corrupted.
-  if (m_catalog && !m_catalog->is_valid())
+  if (res)
     fatal_error(m_type == BACKUP ? ER_BACKUP_BACKUP : ER_BACKUP_RESTORE);
 
   if (m_catalog && !m_catalog->get_end_time())
@@ -1158,6 +1231,7 @@ int Backup_restore_ctx::close()
     else
     {
       int ret= m_stream->close(); // reports errors
+
       if (ret != BSTREAM_OK)
         fatal_error(ER_BACKUP_CLOSE);
     }
@@ -1220,6 +1294,10 @@ int Backup_restore_ctx::do_backup()
   DEBUG_SYNC(m_thd, "backup_before_write_preamble");
 
   ret= write_preamble(info, s);  // Can Log errors via callback functions.
+
+  // Error condition insertion for ER_BACKUP_WRITE_HEADER.
+  DBUG_EXECUTE_IF("ER_BACKUP_WRITE_HEADER_1", ret= 1;);
+ 
   if (ret || is_killed())
   {
     if (report_killed())
@@ -1245,6 +1323,10 @@ int Backup_restore_ctx::do_backup()
 
   DEBUG_SYNC(m_thd, "before_backup_summary");
   ret= write_summary(info, s);  
+
+  // Error condition insertion for ER_BACKUP_WRITE_SUMMARY.
+  DBUG_EXECUTE_IF("ER_BACKUP_WRITE_SUMMARY", ret= 1;);
+
   if (ret || is_killed())
     DBUG_RETURN(fatal_error(report_error(ER_BACKUP_WRITE_SUMMARY)));
 
@@ -1349,6 +1431,9 @@ int Backup_restore_ctx::restore_triggers
     while ((ev= it++))
     {
       int ret= ev->m_obj_ptr->create(m_thd); 
+
+      DBUG_EXECUTE_IF("ER_BACKUP_CANT_RESTORE_EVENT_1", ret= 1;);
+
       if (ret || is_killed())
       {
         fatal_error(report_error(ER_BACKUP_CANT_RESTORE_EVENT,ev->describe(buf)));
@@ -1707,6 +1792,9 @@ int bcat_reset(st_bstream_image_header *
 
     DBUG_PRINT("restore",("Creating info for snapshot no. %d", n));
 
+    // Error code insertion for ER_BACKUP_UNKNOWN_BE.
+    DBUG_EXECUTE_IF("ER_BACKUP_UNKNOWN_BE", snap->type= BI_UNKNOWN;);
+
     switch (snap->type) {
 
     case BI_NATIVE:
@@ -1715,13 +1803,21 @@ int bcat_reset(st_bstream_image_header *
       storage_engine_ref se= get_se_by_name(name_lex);
       handlerton *hton= se_hton(se);
 
+      // Error condition insertion for ER_BACKUP_CANT_FIND_SE.
+      DBUG_EXECUTE_IF("ER_BACKUP_CANT_FIND_SE", se= 0;);
+
       if (!se || !hton)
       {
         log.report_error(ER_BACKUP_CANT_FIND_SE, name_lex.str);
         return BSTREAM_ERROR;
       }
 
-      if (!hton->get_backup_engine)
+      int res= !hton->get_backup_engine;
+
+      // Error code insertion for ER_BACKUP_NO_NATIVE_BE.
+      DBUG_EXECUTE_IF("ER_BACKUP_NO_NATIVE_BE", res= 1;);
+
+      if (res)
       {
         log.report_error(ER_BACKUP_NO_NATIVE_BE, name_lex.str);
         return BSTREAM_ERROR;
@@ -1829,6 +1925,12 @@ int bcat_add_item(st_bstream_image_heade
 
     Snapshot_info *snap= info->m_snap[it->snap_num];
 
+    // Debug insertion for ER_BACKUP_WRONG_TABLE_BE.
+    // We must use debug insertion to avoid assertion
+    DBUG_EXECUTE_IF("ER_BACKUP_WRONG_TABLE_BE", 
+      log.report_error(ER_BACKUP_WRONG_TABLE_BE, it->snap_num + 1);
+      return BSTREAM_ERROR;);
+
     if (!snap)
     {
       /* 
@@ -1945,6 +2047,9 @@ void* bcat_iterator_get(st_bstream_image
   {
     Iterator *it= info->get_perdb();
   
+    // Error condition insertion for ER_BACKUP_CAT_ENUM.
+    DBUG_EXECUTE_IF("ER_BACKUP_CAT_ENUM", it= 0;);
+
     if (!it)
     {
       log.report_error(ER_BACKUP_CAT_ENUM);
@@ -2041,6 +2146,9 @@ void* bcat_db_iterator_get(st_bstream_im
   backup::Logger &log= info->m_log;
   Backup_info::Db *db = info->get_db(dbi->base.pos);
 
+  // Error code insertion for ER_BACKUP_UNKNOWN_OBJECT.
+  DBUG_EXECUTE_IF("ER_BACKUP_UNKNOWN_OBJECT", db= 0;);
+
   if (!db)
   {
     log.report_error(ER_BACKUP_UNKNOWN_OBJECT);
@@ -2114,6 +2222,10 @@ int bcat_create_item(st_bstream_image_he
   if (log.report_killed())
     return BSTREAM_ERROR;
 
+  // Error code insertion for ER_BACKUP_UNKNOWN_OBJECT_TYPE.
+  DBUG_EXECUTE_IF("ER_BACKUP_UNKNOWN_OBJECT_TYPE", 
+    item->type= BSTREAM_IT_LAST;);
+
   switch (item->type) {
   
   case BSTREAM_IT_DB:     create_err= ER_BACKUP_CANT_RESTORE_DB; break;
@@ -2158,6 +2270,46 @@ int bcat_create_item(st_bstream_image_he
   Image_info::Obj::describe_buf buf;
   const char *desc= obj->describe(buf);
 
+  /*
+    Debug insertion for errors. Here we setup the error to correspond 
+    with the debug SESSION tag specified in the test.
+
+    Note: Error code insertion won't work here as we need to generate
+          the specific error message for each test case.
+  */
+  ::String str;
+  switch (item->type) {
+  case BSTREAM_IT_DB: str.append("ER_BACKUP_CANT_RESTORE_DB"); break;
+  case BSTREAM_IT_TABLE: str.append("ER_BACKUP_CANT_RESTORE_TABLE"); break;
+  case BSTREAM_IT_VIEW: str.append("ER_BACKUP_CANT_RESTORE_VIEW"); break;
+  case BSTREAM_IT_SPROC: str.append("ER_BACKUP_CANT_RESTORE_SROUT_P"); break;
+  case BSTREAM_IT_SFUNC: str.append("ER_BACKUP_CANT_RESTORE_SROUT_F"); break;
+  case BSTREAM_IT_EVENT: str.append("ER_BACKUP_CANT_RESTORE_EVENT_2"); break;
+  case BSTREAM_IT_TRIGGER: str.append("ER_BACKUP_CANT_RESTORE_TRIGGER"); break;
+  default: break;
+  }
+  if (str.ptr())
+  {
+    DBUG_EXECUTE_IF(str.ptr(),
+      log.report_error(create_err, desc);
+      return BSTREAM_ERROR;);
+  }
+  // Tablespace is a special case since Falcon is disabled.
+  DBUG_EXECUTE_IF("ER_BACKUP_CANT_RESTORE_TS",
+    log.report_error(ER_BACKUP_CANT_RESTORE_TS, 
+      "Debug insertion test");
+    return BSTREAM_ERROR;);
+
+  /*
+     Grants are a special case because of the way the message is generated --
+     it produces a non-deterministic error string. Note that a real error
+     would be deterministic.
+  */
+  DBUG_EXECUTE_IF("ER_BACKUP_CANT_RESTORE_PRIV",
+    log.report_error(ER_BACKUP_CANT_RESTORE_PRIV, 
+      "Debug insertion test");
+    return BSTREAM_ERROR;);
+
   if (!sobj)
   {
     log.report_error(create_err, desc);
@@ -2298,6 +2450,47 @@ int bcat_get_item_create_query(st_bstrea
   ::String *buf= &(info->serialization_buf);
   buf->length(0);
 
+  /*
+    Debug insertion for errors. Here we setup the error to correspond 
+    with the debug SESSION tag specified in the test.
+
+    Note: Error code insertion won't work here as we need to generate
+          the specific error message for each test case.
+  */
+  ::String str;
+  switch (item->type) {
+  case BSTREAM_IT_DB:     str.append("ER_BACKUP_GET_META_DB"); break;
+  case BSTREAM_IT_TABLE:  str.append("ER_BACKUP_GET_META_TABLE"); break;
+  case BSTREAM_IT_VIEW:   str.append("ER_BACKUP_GET_META_VIEW"); break;
+  case BSTREAM_IT_SPROC:  str.append("ER_BACKUP_GET_META_SROUT_P"); break;
+  case BSTREAM_IT_SFUNC:  str.append("ER_BACKUP_GET_META_SROUT_F"); break;
+  case BSTREAM_IT_EVENT:  str.append("ER_BACKUP_GET_META_EVENT"); break;
+  case BSTREAM_IT_TRIGGER: str.append("ER_BACKUP_GET_META_TRIGGER"); break;
+  default: break;
+  }
+  if (str.ptr())
+  {
+    DBUG_EXECUTE_IF(str.ptr(),
+      Image_info::Obj::describe_buf dbuf;
+      log.report_error(meta_err, obj->describe(dbuf));
+      return BSTREAM_ERROR;);
+  }
+  // Tablespace is a special case since Falcon is disabled.
+  DBUG_EXECUTE_IF("ER_BACKUP_GET_META_TS",
+    log.report_error(ER_BACKUP_GET_META_TS, 
+      "Debug insertion test");
+    return BSTREAM_ERROR;);
+
+  /*
+     Grants are a special case because of the way the message is generated --
+     it produces a non-deterministic error string. Note that a real error
+     would be deterministic.
+  */
+  DBUG_EXECUTE_IF("ER_BACKUP_GET_META_PRIV",
+    log.report_error(ER_BACKUP_GET_META_PRIV, 
+      "Debug insertion test");
+    return BSTREAM_ERROR;);
+
   if (obj->m_obj_ptr->serialize(info->m_thd, buf))
   {
     Image_info::Obj::describe_buf dbuf;

=== modified file 'sql/backup/logger.cc'
--- a/sql/backup/logger.cc	2009-03-16 14:38:05 +0000
+++ b/sql/backup/logger.cc	2009-08-09 21:33:03 +0000
@@ -239,6 +239,8 @@ bool Logger::push_errors(bool flag)
  */ 
 bool Logger::report_killed()
 {
+  // Error code insertion for ER_BACKUP_INTERRUPTED.
+  DBUG_EXECUTE_IF("ER_BACKUP_INTERRUPTED", goto debug_error;);
 
   if (!m_thd->killed)
     return FALSE;
@@ -252,6 +254,8 @@ bool Logger::report_killed()
   if (m_state == CREATED || m_state == READY)
     return TRUE;
 
+debug_error:
+
   // log_error() does not push messages on the server's error stack.
   log_error(backup::log_level::INFO, ER_BACKUP_INTERRUPTED);  
 

=== modified file 'sql/backup/stream.cc'
--- a/sql/backup/stream.cc	2009-08-11 11:09:31 +0000
+++ b/sql/backup/stream.cc	2009-08-20 19:53:25 +0000
@@ -408,6 +408,9 @@ bool Output_stream::init()
   // write magic bytes and format version
   int len= write_magic_and_version();
 
+  // Error condition insertion for ER_BACKUP_WRITE_HEADER.
+  DBUG_EXECUTE_IF("ER_BACKUP_WRITE_HEADER_2", len= 0;);
+ 
   if (len <= 0)
   {
     m_log.report_error(ER_BACKUP_WRITE_HEADER);
@@ -422,7 +425,13 @@ bool Output_stream::init()
     an ASSERT and do an explicit cast from size_t.
   */
   DBUG_ASSERT(m_block_size <= ~((unsigned long)0));
-  if (BSTREAM_OK != bstream_open_wr(this, (unsigned long)m_block_size, len))
+
+  int res= bstream_open_wr(this, (unsigned long)m_block_size, len);
+
+  // Error code insertion for ER_BACKUP_OPEN_WR.
+  DBUG_EXECUTE_IF("ER_BACKUP_OPEN_WR", res= BSTREAM_ERROR;);
+
+  if (res != BSTREAM_OK)
   {
     m_log.report_error(ER_BACKUP_OPEN_WR);
     return FALSE;
@@ -473,9 +482,15 @@ int Output_stream::open()
     zstream.msg= 0;
     zstream.next_out= zbuf;
     zstream.avail_out= ZBUF_SIZE;
-    if ((zerr= deflateInit2(&zstream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
+
+    ret= (zerr= deflateInit2(&zstream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
                             MAX_WBITS + 16, MAX_MEM_LEVEL,
-                            Z_DEFAULT_STRATEGY) != Z_OK))
+                            Z_DEFAULT_STRATEGY) != Z_OK);
+
+    // Error code insertion for ER_BACKUP_FAILED_TO_INIT_COMPRESSION.
+    DBUG_EXECUTE_IF("ER_BACKUP_FAILED_TO_INIT_COMPRESSION", ret= 1;);
+
+    if (ret)
     {
       m_log.report_error(ER_BACKUP_FAILED_TO_INIT_COMPRESSION,
                          zerr, zstream.msg);
@@ -544,6 +559,9 @@ int Output_stream::close()
 #endif
   ret =  Stream::close();
 
+  // Error code insertion for ER_BACKUP_CLOSE.
+  DBUG_EXECUTE_IF("ER_BACKUP_CLOSE_1", ret= 1;);
+  
   if (ret)
     m_log.report_error(log_level::ERROR, ER_BACKUP_CLOSE);
 
@@ -634,6 +652,9 @@ bool Input_stream::init()
 {
   int len= check_magic_and_version();
 
+  // Error condition insertion for ER_BACKUP_BAD_MAGIC.
+  DBUG_EXECUTE_IF("ER_BACKUP_BAD_MAGIC", len= 0;);
+
   if (len <= 0)
   {
     m_log.report_error(ER_BACKUP_BAD_MAGIC);
@@ -642,7 +663,12 @@ bool Input_stream::init()
 
   bytes= 0;
 
-  if (BSTREAM_OK != bstream_open_rd(this, len))
+  int res= bstream_open_rd(this, len);
+
+  // Error code insertion for ER_BACKUP_OPEN_RD.
+  DBUG_EXECUTE_IF("ER_BACKUP_OPEN_RD", res= BSTREAM_ERROR;);
+
+  if (res != BSTREAM_OK)
   {
     m_log.report_error(ER_BACKUP_OPEN_RD);
     return FALSE;
@@ -675,11 +701,19 @@ int Input_stream::open()
 
   int ret= Stream::open();
 
+  // Error code insertion for ER_BACKUP_READ_LOC.
+  DBUG_EXECUTE_IF("ER_BACKUP_READ_LOC_3", ret= -1;);
+
   if (ret != 0)
     return ret == -1 ? ER_BACKUP_READ_LOC : ret;
 
-  if (my_read(m_fd, m_header_buf, sizeof(m_header_buf),
-              MY_NABP /* error if not all bytes read */ ))
+  ret= my_read(m_fd, m_header_buf, sizeof(m_header_buf),
+              MY_NABP /* error if not all bytes read */ );
+
+  // Error code insertion for ER_BACKUP_READ_LOC.
+  DBUG_EXECUTE_IF("ER_BACKUP_READ_LOC_4", ret= 1;);
+
+  if (ret)
     return ER_BACKUP_READ_LOC;
 
 #ifdef HAVE_COMPRESS
@@ -699,7 +733,13 @@ int Input_stream::open()
     zstream.next_in= zbuf;
     zstream.avail_in= 10;
     memcpy(zbuf, m_header_buf, 10);
-    if ((zerr= inflateInit2(&zstream, MAX_WBITS + 16)) != Z_OK)
+
+    ret= ((zerr= inflateInit2(&zstream, MAX_WBITS + 16)) != Z_OK);
+
+    // Error code insertion for ER_BACKUP_READ_LOC.
+    DBUG_EXECUTE_IF("ER_BACKUP_READ_LOC_5", ret= 1;);
+
+    if (ret)
     {
       m_log.report_error(ER_GET_ERRMSG, zerr, zstream.msg, "inflateInit2");
       my_free(zbuf, MYF(0));
@@ -708,13 +748,24 @@ int Input_stream::open()
     m_with_compression= true;
     blob.begin= m_header_buf;
     blob.end= m_header_buf + 10;
-    if (stream_read((fd_stream*) this, &blob, blob) != BSTREAM_OK ||
-        blob.begin != blob.end)
+
+    ret= (stream_read((fd_stream*) this, &blob, blob) != BSTREAM_OK ||
+           blob.begin != blob.end);
+
+    // Error code insertion for ER_BACKUP_READ_LOC.
+    DBUG_EXECUTE_IF("ER_BACKUP_READ_LOC_6", ret= 1;);
+
+    if (ret)
       return ER_BACKUP_READ_LOC;
   }
 #endif
 
-  if (!init())
+  ret= !init();
+
+  // Error code insertion for ER_BACKUP_READ_LOC.
+  DBUG_EXECUTE_IF("ER_BACKUP_READ_LOC_7", ret= 1;);
+
+  if (ret)
     return ER_BACKUP_READ_LOC;
 
   return 0;
@@ -754,6 +805,9 @@ int Input_stream::close()
   if (Stream::close())
     ret= BSTREAM_ERROR;
 
+  // Error code insertion for ER_BACKUP_CLOSE.
+  DBUG_EXECUTE_IF("ER_BACKUP_CLOSE_2", ret= 1;);
+  
   if (ret)
     m_log.report_error(log_level::ERROR, ER_BACKUP_CLOSE);
 

=== modified file 'sql/backup/stream_v1.h'
--- a/sql/backup/stream_v1.h	2009-08-03 07:59:51 +0000
+++ b/sql/backup/stream_v1.h	2009-08-20 19:53:25 +0000
@@ -119,7 +119,8 @@ enum enum_bstream_snapshot_type {
   BI_NATIVE,  /**< created by native backup driver of a storage engine */
   BI_DEFAULT, /**< created by built-in blocking backup driver */
   BI_CS,      /**< created by built-in driver using consistent read transaction */
-  BI_NODATA   /**< created by built-in nodata backup driver */
+  BI_NODATA,  /**< created by built-in nodata backup driver */
+  BI_UNKNOWN  /**< error condition used for testing error handling */
 };
 
 /** Describes table data snapshot. */

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2009-07-21 14:57:51 +0000
+++ b/sql/log.cc	2009-08-09 21:33:03 +0000
@@ -1028,6 +1028,9 @@ bool Log_to_csv_event_handler::
 
   result= FALSE;
 
+  // Error code insertion for ER_BACKUP_LOG_WRITE_ERROR.
+  DBUG_EXECUTE_IF("ER_BACKUP_LOG_WRITE_ERROR_H", result= TRUE;);
+
 err:
   if (result && !thd->killed)
     push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -1168,6 +1171,9 @@ bool Log_to_csv_event_handler::
 
   result= FALSE;
 
+  // Error code insertion for ER_BACKUP_LOG_WRITE_ERROR.
+  DBUG_EXECUTE_IF("ER_BACKUP_LOG_WRITE_ERROR_P", result= TRUE;);
+
 err:
   if (result && !thd->killed)
     push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2009-08-04 20:12:18 +0000
+++ b/sql/set_var.cc	2009-08-09 21:33:03 +0000
@@ -2676,7 +2676,7 @@ err:
        "backup_history_log_file") == 0) ||
       (my_strcasecmp(system_charset_info, var->var->name,
        "backup_progress_log_file") == 0))
-    my_error(ER_BACKUP_LOGPATH_INVALID, MYF(0), var->var->name, path); 
+    my_error(ER_BACKUP_LOGPATH_INVALID, MYF(0), var->var->name); 
   else
     my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name, 
              res ? log_file_str : "NULL");

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2009-08-05 15:13:12 +0000
+++ b/sql/share/errmsg-utf8.txt	2009-08-09 21:33:03 +0000
@@ -6455,7 +6455,7 @@ ER_BACKUP_GRANT_WRONG_DB
 ER_BACKUP_LOGPATHS
   eng "The log names for backup_history and backup_progress must be unique."
 ER_BACKUP_LOGPATH_INVALID
-  eng "The path specified for the %-.64s is invalid. ref: %-.64s"
+  eng "The path specified for the %-.64s is invalid."
 ER_BACKUP_SEND_REPLY
         eng "Failed to send reply to client after successful %-.64s operation"
         nor "Feil ved sending av svar til klient etter %-.64s"

=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt	2009-08-05 15:13:12 +0000
+++ b/sql/share/errmsg.txt	2009-08-09 21:33:03 +0000
@@ -6455,7 +6455,7 @@ ER_BACKUP_GRANT_WRONG_DB
 ER_BACKUP_LOGPATHS
   eng "The log names for backup_history and backup_progress must be unique."
 ER_BACKUP_LOGPATH_INVALID
-  eng "The path specified for the %-.64s is invalid. ref: %-.64s"
+  eng "The path specified for the %-.64s is invalid."
 ER_BACKUP_SEND_REPLY
         eng "Failed to send reply to client after successful %-.64s operation"
         nor "Feil ved sending av svar til klient etter %-.64s"


Attachment: [text/bzr-bundle] bzr/charles.bell@sun.com-20090820195325-g12euza2c6b7o4af.bundle
Thread
bzr commit into mysql-6.0-backup branch (charles.bell:2862) WL#4722Chuck Bell20 Aug