List:Commits« Previous MessageNext Message »
From:cbell Date:November 23 2007 1:28pm
Subject:bk commit into 6.0 tree (cbell:1.2660) WL#4062
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of cbell. When cbell does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-11-23 08:27:51-05:00, cbell@mysql_cab_desk. +13 -0
  WL#4062 : Online Backup: Metadata freeze
  
  This patch implements the first iteration of the metadata freeze (hence
  DDL blocker) for the online backup project. It uses a normal pthread
  condition variable loop to block all DDL operations while a backup is
  running and another to block a backup if any DDL operations are running.
  
  Note: This patch requires the patch for WL#4120.

  mysql-test/include/backup_ddl_create_data.inc@stripped, 2007-11-23 08:27:43-05:00, cbell@mysql_cab_desk. +30 -0
    WL#4062 : Online Backup: Metadata freeze
    
    New include file for test. This creates test data.
    

  mysql-test/include/backup_ddl_create_data.inc@stripped, 2007-11-23 08:27:43-05:00, cbell@mysql_cab_desk. +0 -0

  mysql-test/r/backup_ddl_blocker.result@stripped, 2007-11-23 08:27:44-05:00, cbell@mysql_cab_desk. +984 -0
    WL#4062 : Online Backup: Metadata freeze
    
    New result file.
    

  mysql-test/r/backup_ddl_blocker.result@stripped, 2007-11-23 08:27:44-05:00, cbell@mysql_cab_desk. +0 -0

  mysql-test/t/backup_ddl_blocker.test@stripped, 2007-11-23 08:27:45-05:00, cbell@mysql_cab_desk. +1736 -0
    WL#4062 : Online Backup: Metadata freeze
    
    This adds a test for the DDL blocker.
    

  mysql-test/t/backup_ddl_blocker.test@stripped, 2007-11-23 08:27:45-05:00, cbell@mysql_cab_desk. +0 -0

  sql/CMakeLists.txt@stripped, 2007-11-23 08:27:32-05:00, cbell@mysql_cab_desk. +1 -0
    WL#4062 : Online Backup: Metadata freeze
    
    Added new source file.

  sql/Makefile.am@stripped, 2007-11-23 08:27:33-05:00, cbell@mysql_cab_desk. +2 -2
    WL#4062 : Online Backup: Metadata freeze
    
    Added new source file.

  sql/backup/meta_backup.cc@stripped, 2007-11-23 08:27:39-05:00, cbell@mysql_cab_desk. +16 -0
    WL#4062 : Online Backup: Metadata freeze
    
    This patch adds a boolean for bypassing the ddl blocker for those
    DDLs that execute during restore. This is a temporary solution
    until the permanent DDL blocker is established.

  sql/backup/sql_backup.cc@stripped, 2007-11-23 08:27:40-05:00, cbell@mysql_cab_desk. +44 -5
    WL#4062 : Online Backup: Metadata freeze
    
    This patch adds the methods for checking if DDL operations are running. If there are, 
    the backup process is blocked until the DDL operations are complete.

  sql/ddl_blocker.cc@stripped, 2007-11-23 08:27:41-05:00, cbell@mysql_cab_desk. +145 -0
    WL#4062 : Online Backup: Metadata freeze
    
    This patch adds the methods for the DDL blocker to a new file.
    

  sql/ddl_blocker.cc@stripped, 2007-11-23 08:27:41-05:00, cbell@mysql_cab_desk. +0 -0

  sql/ddl_blocker.h@stripped, 2007-11-23 08:27:42-05:00, cbell@mysql_cab_desk. +49 -0
    WL#4062 : Online Backup: Metadata freeze
    
    This patch adds the method declarations for the DDL blocker to a new file.
    

  sql/ddl_blocker.h@stripped, 2007-11-23 08:27:42-05:00, cbell@mysql_cab_desk. +0 -0

  sql/mysqld.cc@stripped, 2007-11-23 08:27:34-05:00, cbell@mysql_cab_desk. +18 -0
    WL#4062 : Online Backup: Metadata freeze
    
    This patch adds the mutex and condition variables for the DDL blocker.

  sql/sql_class.cc@stripped, 2007-11-23 08:27:36-05:00, cbell@mysql_cab_desk. +8 -1
    WL#4062 : Online Backup: Metadata freeze
    
    This patch adds a boolean for bypassing the ddl blocker for those
    DDLs that execute during restore. This is a temporary solution
    until the permanent DDL blocker is established.

  sql/sql_class.h@stripped, 2007-11-23 08:27:37-05:00, cbell@mysql_cab_desk. +8 -0
    WL#4062 : Online Backup: Metadata freeze
    
    This patch adds a boolean for bypassing the ddl blocker for those
    DDLs that execute during restore. This is a temporary solution
    until the permanent DDL blocker is established.

  sql/sql_parse.cc@stripped, 2007-11-23 08:27:38-05:00, cbell@mysql_cab_desk. +31 -2
    WL#4062 : Online Backup: Metadata freeze
    
    This patch adds the methods for checking the DDL blocker and blocking DDL operations
    while the backup process is running.

diff -Nrup a/mysql-test/include/backup_ddl_create_data.inc b/mysql-test/include/backup_ddl_create_data.inc
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/include/backup_ddl_create_data.inc	2007-11-23 08:27:43 -05:00
@@ -0,0 +1,30 @@
+--disable_warnings
+DROP DATABASE IF EXISTS bup_ddl_blocker;
+--enable_warnings
+
+CREATE DATABASE bup_ddl_blocker;
+
+# Create transaction tables and load them with data.
+--echo con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MYISAM;
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t4 (col_a CHAR(40)) ENGINE=MYISAM;
+
+--echo con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+
+INSERT INTO bup_ddl_blocker.t2 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("03 Some data to test");
+
+INSERT INTO bup_ddl_blocker.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("03 Some data to test");
+
+INSERT INTO bup_ddl_blocker.t4 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("03 Some data to test");
+
diff -Nrup a/mysql-test/r/backup_ddl_blocker.result b/mysql-test/r/backup_ddl_blocker.result
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/r/backup_ddl_blocker.result	2007-11-23 08:27:44 -05:00
@@ -0,0 +1,984 @@
+
+Starting Test 1 - Backup
+
+DROP DATABASE IF EXISTS bup_ddl_blocker;
+CREATE DATABASE bup_ddl_blocker;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MYISAM;
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t4 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("03 Some data to test");
+DROP TABLE bup_ddl_blocker.t1, bup_ddl_blocker.t3;
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+con3: Get a DDL going and stop in the middle
+ALTER TABLE bup_ddl_blocker.t2 ADD COLUMN col_b int;
+con1: Backing up database -- will block with lock
+BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+ALTER TABLE bup_ddl_blocker.t4 ADD COLUMN col_b int;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+con3: Completing DDL
+con4: Completing DDL
+con5: Completing DDL
+Backup Summary
+ header     =       36 bytes
+ meta-data  =      316 bytes
+ data       =      162 bytes
+              --------------
+ total             514 bytes
+
+Verifying Test 1 results for backup.
+
+con1: Showing columns after updates and backup
+DESCRIBE bup_ddl_blocker.t1;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+DESCRIBE bup_ddl_blocker.t2;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+col_b	int(11)	YES		NULL	
+DESCRIBE bup_ddl_blocker.t3;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+DESCRIBE bup_ddl_blocker.t4;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+col_b	int(11)	YES		NULL	
+con1: Dropping the database tables
+DROP TABLE bup_ddl_blocker.t1, bup_ddl_blocker.t2,
+bup_ddl_blocker.t3, bup_ddl_blocker.t4;
+con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+Restore Summary
+ header     =       36 bytes
+ meta-data  =      316 bytes
+ data       =      162 bytes
+              --------------
+ total             514 bytes
+con1: Showing columns that were backed up
+con1: Table t3 should not be in restored data.
+con1: Table t4 should not have new column in restored data.
+DESCRIBE bup_ddl_blocker.t1;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+DESCRIBE bup_ddl_blocker.t2;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+col_b	int(11)	YES		NULL	
+DESCRIBE bup_ddl_blocker.t3;
+ERROR 42S02: Table 'bup_ddl_blocker.t3' doesn't exist
+DESCRIBE bup_ddl_blocker.t4;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+
+Starting Test 1 - Restore
+
+DROP DATABASE IF EXISTS bup_ddl_blocker;
+CREATE DATABASE bup_ddl_blocker;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MYISAM;
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t4 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("03 Some data to test");
+DROP TABLE bup_ddl_blocker.t1, bup_ddl_blocker.t3;
+BACKUP DATABASE bup_ddl_blocker to 'bup_ddl_blocker_orig.bak';
+Backup Summary
+ header     =       29 bytes
+ meta-data  =      190 bytes
+ data       =      162 bytes
+              --------------
+ total             381 bytes
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+con3: Get a DDL going and stop in the middle
+ALTER TABLE bup_ddl_blocker.t2 ADD COLUMN col_b int;
+con1: Restoring database -- will block with lock
+RESTORE FROM "bup_ddl_blocker_orig.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+ALTER TABLE bup_ddl_blocker.t4 ADD COLUMN col_b int;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+con3: Completing DDL
+con4: Completing DDL
+con5: Completing DDL
+Restore Summary
+ header     =       29 bytes
+ meta-data  =      190 bytes
+ data       =      162 bytes
+              --------------
+ total             381 bytes
+
+Verifying Test 1 results for restore.
+
+con1: Table t1 should not be in restored data.
+con1: Table t2 should not have new column in restored data.
+con1: Table t3 should be in restored data.
+con1: Table t4 should have new column in restored data.
+DESCRIBE bup_ddl_blocker.t1;
+ERROR 42S02: Table 'bup_ddl_blocker.t1' doesn't exist
+DESCRIBE bup_ddl_blocker.t2;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+DESCRIBE bup_ddl_blocker.t3;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+DESCRIBE bup_ddl_blocker.t4;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+col_b	int(11)	YES		NULL	
+
+Starting Test 2 - Backup
+
+DROP DATABASE IF EXISTS bup_ddl_blocker;
+CREATE DATABASE bup_ddl_blocker;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MYISAM;
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t4 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("03 Some data to test");
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+RENAME TABLE bup_ddl_blocker.t1 TO bup_ddl_blocker.t01;
+con3: Get a DDL going and stop in the middle
+REPAIR TABLE bup_ddl_blocker.t2;
+con1: Backing up database -- will block with lock
+BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+RENAME TABLE bup_ddl_blocker.t3 TO bup_ddl_blocker.t03;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+REPAIR TABLE bup_ddl_blocker.t4;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+con3: Completing DDL
+Table	Op	Msg_type	Msg_text
+bup_ddl_blocker.t2	repair	status	OK
+con4: Completing DDL
+con5: Completing DDL
+Table	Op	Msg_type	Msg_text
+bup_ddl_blocker.t4	repair	status	OK
+Backup Summary
+ header     =       41 bytes
+ meta-data  =      379 bytes
+ data       =      324 bytes
+              --------------
+ total             744 bytes
+
+Verifying Test 2 results for backup.
+
+con1: Showing columns after updates and backup
+use bup_ddl_blocker;
+SHOW TABLES;
+Tables_in_bup_ddl_blocker
+t01
+t03
+t2
+t4
+con1: Dropping the database tables
+DROP TABLE bup_ddl_blocker.t01, bup_ddl_blocker.t2,
+bup_ddl_blocker.t03, bup_ddl_blocker.t4;
+con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+Restore Summary
+ header     =       41 bytes
+ meta-data  =      379 bytes
+ data       =      324 bytes
+              --------------
+ total             744 bytes
+con1: Showing columns that were backed up
+con1: Table t01 should be in restore
+con1: Table t03 should not be in restore
+use bup_ddl_blocker;
+SHOW TABLES;
+Tables_in_bup_ddl_blocker
+t01
+t2
+t3
+t4
+
+Starting Test 2 - Restore
+
+DROP DATABASE IF EXISTS bup_ddl_blocker;
+CREATE DATABASE bup_ddl_blocker;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MYISAM;
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t4 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("03 Some data to test");
+BACKUP DATABASE bup_ddl_blocker to 'bup_ddl_blocker_orig.bak';
+Backup Summary
+ header     =       40 bytes
+ meta-data  =      378 bytes
+ data       =      324 bytes
+              --------------
+ total             742 bytes
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+RENAME TABLE bup_ddl_blocker.t1 TO bup_ddl_blocker.t01;
+con3: Get a DDL going and stop in the middle
+REPAIR TABLE bup_ddl_blocker.t2;
+con1: Restoring database -- will block with lock
+RESTORE FROM "bup_ddl_blocker_orig.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+RENAME TABLE bup_ddl_blocker.t3 TO bup_ddl_blocker.t03;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+REPAIR TABLE bup_ddl_blocker.t4;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+con3: Completing DDL
+Table	Op	Msg_type	Msg_text
+bup_ddl_blocker.t2	repair	status	OK
+con4: Completing DDL
+con5: Completing DDL
+Table	Op	Msg_type	Msg_text
+bup_ddl_blocker.t4	repair	status	OK
+Restore Summary
+ header     =       40 bytes
+ meta-data  =      378 bytes
+ data       =      324 bytes
+              --------------
+ total             742 bytes
+
+Verifying Test 2 results for restore.
+
+con1: Table t01 should not be in restored data.
+use bup_ddl_blocker;
+SHOW TABLES;
+Tables_in_bup_ddl_blocker
+t03
+t1
+t2
+t4
+
+Starting Test 3 - Backup
+
+DROP DATABASE IF EXISTS bup_ddl_blocker;
+CREATE DATABASE bup_ddl_blocker;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MYISAM;
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t4 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("03 Some data to test");
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+OPTIMIZE TABLE bup_ddl_blocker.t1;
+con3: Get a DDL going and stop in the middle
+DROP TABLE bup_ddl_blocker.t2;
+con1: Backing up database -- will block with lock
+BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+OPTIMIZE TABLE bup_ddl_blocker.t3;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+DROP TABLE bup_ddl_blocker.t4;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+Table	Op	Msg_type	Msg_text
+bup_ddl_blocker.t1	optimize	status	OK
+con3: Completing DDL
+con4: Completing DDL
+Table	Op	Msg_type	Msg_text
+bup_ddl_blocker.t3	optimize	status	OK
+con5: Completing DDL
+Backup Summary
+ header     =       36 bytes
+ meta-data  =      284 bytes
+ data       =      243 bytes
+              --------------
+ total             563 bytes
+
+Verifying Test 3 results for backup.
+
+con1: Showing columns after updates and backup
+use bup_ddl_blocker;
+SHOW TABLES;
+Tables_in_bup_ddl_blocker
+t1
+t3
+con1: Dropping the database tables
+DROP TABLE bup_ddl_blocker.t1, bup_ddl_blocker.t3;
+con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+Restore Summary
+ header     =       36 bytes
+ meta-data  =      284 bytes
+ data       =      243 bytes
+              --------------
+ total             563 bytes
+con1: Showing columns that were backed up
+con1: Table t2 should not be in restore
+use bup_ddl_blocker;
+SHOW TABLES;
+Tables_in_bup_ddl_blocker
+t1
+t3
+t4
+
+Starting Test 3 - Restore
+
+DROP DATABASE IF EXISTS bup_ddl_blocker;
+CREATE DATABASE bup_ddl_blocker;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t2 (col_a CHAR(40)) ENGINE=MYISAM;
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker.t4 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t2 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t4 VALUES ("03 Some data to test");
+BACKUP DATABASE bup_ddl_blocker to 'bup_ddl_blocker_orig.bak';
+Backup Summary
+ header     =       40 bytes
+ meta-data  =      378 bytes
+ data       =      324 bytes
+              --------------
+ total             742 bytes
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+OPTIMIZE TABLE bup_ddl_blocker.t1;
+con3: Get a DDL going and stop in the middle
+DROP TABLE bup_ddl_blocker.t2;
+con1: Restoring database -- will block with lock
+RESTORE FROM "bup_ddl_blocker_orig.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+OPTIMIZE TABLE bup_ddl_blocker.t3;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+DROP TABLE bup_ddl_blocker.t4;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+Table	Op	Msg_type	Msg_text
+bup_ddl_blocker.t1	optimize	status	OK
+con3: Completing DDL
+con4: Completing DDL
+Table	Op	Msg_type	Msg_text
+bup_ddl_blocker.t3	optimize	status	OK
+con5: Completing DDL
+Restore Summary
+ header     =       40 bytes
+ meta-data  =      378 bytes
+ data       =      324 bytes
+              --------------
+ total             742 bytes
+
+Verifying Test 3 results for restore.
+
+con1: Table t4 should not be in restored data.
+use bup_ddl_blocker;
+SHOW TABLES;
+Tables_in_bup_ddl_blocker
+t1
+t2
+t3
+
+Starting Test 4 - Backup
+
+DROP DATABASE IF EXISTS bup_ddl_blocker_1;
+DROP DATABASE IF EXISTS bup_ddl_blocker_2;
+DROP DATABASE IF EXISTS bup_ddl_blocker_3;
+DROP DATABASE IF EXISTS bup_ddl_blocker_4;
+con1: Creating databases
+CREATE DATABASE bup_ddl_blocker_2;
+CREATE DATABASE bup_ddl_blocker_4;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker_2.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker_4.t1 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("03 Some data to test");
+con1: Show that the new data doesn't exist before backup.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_2
+bup_ddl_blocker_4
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+CREATE DATABASE bup_ddl_blocker_1;
+con3: Get a DDL going and stop in the middle
+DROP DATABASE bup_ddl_blocker_2;
+con1: Backing up database -- will block with lock
+BACKUP DATABASE * TO "bup_ddl_blocker.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+CREATE DATABASE bup_ddl_blocker_3;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+DROP DATABASE bup_ddl_blocker_4;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+con3: Completing DDL
+con4: Completing DDL
+con5: Completing DDL
+Backup Summary
+ header     =       81 bytes
+ meta-data  =      384 bytes
+ data       =      324 bytes
+              --------------
+ total             789 bytes
+
+Verifying Test 4 results for backup.
+
+con1: Showing databases after updates and backup
+con1: bup_ddl_blocker_2 and bup_ddl_blocker_4 are not present
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_1
+bup_ddl_blocker_3
+con1: Dropping the database tables
+DROP DATABASE bup_ddl_blocker_1;
+DROP DATABASE bup_ddl_blocker_3;
+con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+Restore Summary
+ header     =       81 bytes
+ meta-data  =      384 bytes
+ data       =      324 bytes
+              --------------
+ total             789 bytes
+con1: Showing databases that were backed up
+con1: bup_ddl_blocker_2 and bup_ddl_blocker_3 are not present
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_1
+bup_ddl_blocker_4
+con1: Cleanup
+DROP DATABASE bup_ddl_blocker_1;
+DROP DATABASE bup_ddl_blocker_4;
+
+Starting Test 4 - Restore
+
+DROP DATABASE IF EXISTS bup_ddl_blocker_1;
+DROP DATABASE IF EXISTS bup_ddl_blocker_2;
+DROP DATABASE IF EXISTS bup_ddl_blocker_3;
+DROP DATABASE IF EXISTS bup_ddl_blocker_4;
+con1: Creating databases
+CREATE DATABASE bup_ddl_blocker_2;
+CREATE DATABASE bup_ddl_blocker_4;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker_2.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker_4.t1 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("03 Some data to test");
+con1: Show that the new data doesn't exist before backup.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_2
+bup_ddl_blocker_4
+BACKUP DATABASE bup_ddl_blocker_2, bup_ddl_blocker_4 to 'bup_ddl_blocker_orig.bak';
+Backup Summary
+ header     =       52 bytes
+ meta-data  =      192 bytes
+ data       =      162 bytes
+              --------------
+ total             406 bytes
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+CREATE DATABASE bup_ddl_blocker_1;
+con3: Get a DDL going and stop in the middle
+DROP DATABASE bup_ddl_blocker_2;
+con1: Restoring database -- will block with lock
+RESTORE FROM "bup_ddl_blocker_orig.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+CREATE DATABASE bup_ddl_blocker_3;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+DROP DATABASE bup_ddl_blocker_4;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+con3: Completing DDL
+con4: Completing DDL
+con5: Completing DDL
+Restore Summary
+ header     =       52 bytes
+ meta-data  =      192 bytes
+ data       =      162 bytes
+              --------------
+ total             406 bytes
+
+Verifying Test 4 results for restore.
+
+con1: Database bup_ddl_blocker_4 should not be in restored data.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_1
+bup_ddl_blocker_2
+bup_ddl_blocker_3
+
+Starting Test 5 - Backup
+
+DROP DATABASE IF EXISTS bup_ddl_blocker_1;
+DROP DATABASE IF EXISTS bup_ddl_blocker_2;
+DROP DATABASE IF EXISTS bup_ddl_blocker_3;
+DROP DATABASE IF EXISTS bup_ddl_blocker_4;
+con1: Creating databases
+CREATE DATABASE bup_ddl_blocker_2 CHARACTER SET latin1;
+CREATE DATABASE bup_ddl_blocker_4 CHARACTER SET latin1;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker_2.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker_4.t1 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("03 Some data to test");
+con1: Show that the new data doesn't exist before backup.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_2
+bup_ddl_blocker_4
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+TRUNCATE TABLE bup_ddl_blocker_2.t1;
+con3: Get a DDL going and stop in the middle
+ALTER DATABASE bup_ddl_blocker_2 CHARACTER SET latin2;
+con1: Backing up database -- will block with lock
+BACKUP DATABASE * TO "bup_ddl_blocker.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+TRUNCATE TABLE bup_ddl_blocker_4.t1;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+ALTER DATABASE bup_ddl_blocker_4 CHARACTER SET latin2;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+con3: Completing DDL
+con4: Completing DDL
+con5: Completing DDL
+Backup Summary
+ header     =       85 bytes
+ meta-data  =      478 bytes
+ data       =      324 bytes
+              --------------
+ total             887 bytes
+
+Verifying Test 5 results for backup.
+
+con1: Showing databases after updates and backup
+con1: bup_ddl_blocker_2.t1 has been truncated.
+con1: bup_ddl_blocker_1 and bup_ddl_blocker_3 are renamed 
+con1: bup_ddl_blocker_4.t1 has been truncated.
+con1: bup_ddl_blocker_2 and bup_ddl_blocker_4 have had their charset changed. 
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_2
+bup_ddl_blocker_4
+SHOW CREATE DATABASE bup_ddl_blocker_2;
+Database	Create Database
+bup_ddl_blocker_2	CREATE DATABASE `bup_ddl_blocker_2` /*!40100 DEFAULT CHARACTER SET latin2 */
+SHOW CREATE DATABASE bup_ddl_blocker_4;
+Database	Create Database
+bup_ddl_blocker_4	CREATE DATABASE `bup_ddl_blocker_4` /*!40100 DEFAULT CHARACTER SET latin2 */
+SELECT * FROM bup_ddl_blocker_2.t1;
+col_a
+SELECT * FROM bup_ddl_blocker_4.t1;
+col_a
+con1: Dropping the database tables
+DROP DATABASE bup_ddl_blocker_2;
+DROP DATABASE bup_ddl_blocker_4;
+con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+Restore Summary
+ header     =       85 bytes
+ meta-data  =      478 bytes
+ data       =      324 bytes
+              --------------
+ total             887 bytes
+con1: Showing databases that were backed up
+con1: bup_ddl_blocker_1 has been renamed and
+con1: bup_ddl_blocker_2.t1 has been truncated.
+con1: bup_ddl_blocker_4 has not had its character set changed. 
+con1: bup_ddl_blocker_4.t1 has not been truncated.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_2
+bup_ddl_blocker_4
+SHOW CREATE DATABASE bup_ddl_blocker_2;
+Database	Create Database
+bup_ddl_blocker_2	CREATE DATABASE `bup_ddl_blocker_2` /*!40100 DEFAULT CHARACTER SET latin1 */
+SHOW CREATE DATABASE bup_ddl_blocker_4;
+Database	Create Database
+bup_ddl_blocker_4	CREATE DATABASE `bup_ddl_blocker_4` /*!40100 DEFAULT CHARACTER SET latin1 */
+SELECT * FROM bup_ddl_blocker_2.t1;
+col_a
+SELECT * FROM bup_ddl_blocker_4.t1;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+con1: Cleanup
+DROP DATABASE bup_ddl_blocker_2;
+DROP DATABASE bup_ddl_blocker_4;
+
+Starting Test 5 - Restore
+
+DROP DATABASE IF EXISTS bup_ddl_blocker_1;
+DROP DATABASE IF EXISTS bup_ddl_blocker_2;
+DROP DATABASE IF EXISTS bup_ddl_blocker_3;
+DROP DATABASE IF EXISTS bup_ddl_blocker_4;
+con1: Creating databases
+CREATE DATABASE bup_ddl_blocker_2 CHARACTER SET latin1;
+CREATE DATABASE bup_ddl_blocker_4 CHARACTER SET latin1;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker_2.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker_4.t1 (col_a CHAR(40)) ENGINE=MYISAM;
+con1: Loading data
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("03 Some data to test");
+con1: Show that the new data doesn't exist before backup.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_2
+bup_ddl_blocker_4
+BACKUP DATABASE bup_ddl_blocker_2, bup_ddl_blocker_4
+to 'bup_ddl_blocker_orig.bak';
+Backup Summary
+ header     =       52 bytes
+ meta-data  =      192 bytes
+ data       =      162 bytes
+              --------------
+ total             406 bytes
+con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+get_lock("DDL_in_progress", 0)
+1
+con2: Get a DDL going and stop in the middle
+TRUNCATE TABLE bup_ddl_blocker_2.t1;
+con3: Get a DDL going and stop in the middle
+ALTER DATABASE bup_ddl_blocker_2 CHARACTER SET latin2;
+con1: Restoring database -- will block with lock
+RESTORE FROM "bup_ddl_blocker_orig.bak";
+con6: Checking locks
+con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+get_lock("DDL_blocked", 0)
+1
+con6: Checking locks
+con4: Try a DDL but it is blocked by backup -- will not be in backup
+TRUNCATE TABLE bup_ddl_blocker_4.t1;
+con5: Try a DDL but it is blocked by backup -- will not be in backup
+ALTER DATABASE bup_ddl_blocker_4 CHARACTER SET latin2;
+con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+release_lock("DDL_blocked")
+1
+con2: Completing DDL
+con3: Completing DDL
+con4: Completing DDL
+con5: Completing DDL
+Restore Summary
+ header     =       52 bytes
+ meta-data  =      192 bytes
+ data       =      162 bytes
+              --------------
+ total             406 bytes
+
+Verifying Test 5 results for restore.
+
+con1: bup_ddl_blocker_4 has had its character set changed. 
+con1: bup_ddl_blocker_2.t1 has not been truncated.
+con1: bup_ddl_blocker_4.t1 has been truncated.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+Database (bup_ddl_blocker_%)
+bup_ddl_blocker_2
+bup_ddl_blocker_4
+SHOW CREATE DATABASE bup_ddl_blocker_2;
+Database	Create Database
+bup_ddl_blocker_2	CREATE DATABASE `bup_ddl_blocker_2` /*!40100 DEFAULT CHARACTER SET latin1 */
+SHOW CREATE DATABASE bup_ddl_blocker_4;
+Database	Create Database
+bup_ddl_blocker_4	CREATE DATABASE `bup_ddl_blocker_4` /*!40100 DEFAULT CHARACTER SET latin2 */
+SELECT * FROM bup_ddl_blocker_2.t1;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+SELECT * FROM bup_ddl_blocker_4.t1;
+col_a
+con1: Cleanup
+DROP DATABASE bup_ddl_blocker_2;
+DROP DATABASE bup_ddl_blocker_4;
+
+Starting Test 6
+
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS bup_ddl_blocker.t1, bup_ddl_blocker.t3;
+con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE test.t2 (col_a CHAR(40)) ENGINE=MYISAM;
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=MEMORY;
+con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+INSERT INTO test.t2 VALUES ("01 Some data to test");
+INSERT INTO test.t2 VALUES ("02 Some data to test");
+INSERT INTO test.t2 VALUES ("03 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("03 Some data to test");
+con1: Show that the new data doesn't exist before backup.
+SELECT * FROM bup_ddl_blocker.t1;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+SELECT * FROM test.t2;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+SELECT * FROM bup_ddl_blocker.t3;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+con5: Getting lock on DDL in progress.
+SELECT get_lock("DDL_not_blocked", 0);
+get_lock("DDL_not_blocked", 0)
+1
+con2: Get a DDL going and stop in the middle
+ALTER TABLE bup_ddl_blocker.t1 ADD COLUMN col_b int;
+con3: Get a DDL going and stop in the middle
+ALTER TABLE test.t2 ADD COLUMN col_b int;
+con4: Get a DDL going and stop in the middle
+ALTER TABLE bup_ddl_blocker.t3 ADD COLUMN col_b int;
+con5: Checking locks
+con5: Releasing lock
+SELECT release_lock("DDL_not_blocked");
+release_lock("DDL_not_blocked")
+1
+con2: Completing DDL
+con3: Completing DDL
+con4: Completing DDL
+con1: Showing columns after updates and backup
+DESCRIBE bup_ddl_blocker.t1;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+col_b	int(11)	YES		NULL	
+DESCRIBE test.t2;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+col_b	int(11)	YES		NULL	
+DESCRIBE bup_ddl_blocker.t3;
+Field	Type	Null	Key	Default	Extra
+col_a	char(40)	YES		NULL	
+col_b	int(11)	YES		NULL	
+
+Verifying Test 6 results:
+
+T1 should have the changes after backup - count(*) = 2
+SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'bup_ddl_blocker';
+count(*)
+2
+T2 should the changes after backup - count(*) = 2
+SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_NAME = 't2' AND TABLE_SCHEMA = 'test';
+count(*)
+2
+T3 should not have the changes after backup - count(*) = 2
+SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_NAME = 't3' AND TABLE_SCHEMA = 'bup_ddl_blocker';
+count(*)
+2
+DROP TABLE test.t2;
+con1: Cleanup
+DROP DATABASE bup_ddl_blocker;
diff -Nrup a/mysql-test/t/backup_ddl_blocker.test b/mysql-test/t/backup_ddl_blocker.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/backup_ddl_blocker.test	2007-11-23 08:27:45 -05:00
@@ -0,0 +1,1736 @@
+#
+# This test is for the DDL blocker
+# The goals of the test should be to ensure the following assumptions for
+# the behaviour of the DDL blocker hold true.
+#
+# a) DDL that are running are allowed to complete and backup blocks
+# b) backup blocks all DDL even if not part of backup
+# c) DDL operations do not block each other
+#
+# The results of the backup should show (based on statements above):
+#
+# a) Test result for this assumption: Included in backup
+# b) Test result for this assumption: Not included in backup
+#
+# The test shall run two sets of data definition statements. 
+#
+# 1) test DDL in progress that block backup and while the backup in progress
+#    check that DDLs that start after the backup are blocked
+# 2) DDL do not block each other
+#
+# These set of DDL statements to test include the following. The DDL 
+# statements shall be run in sets with each set a separate test. These tests
+# will show the assumptions above to be true.
+#
+# Test  DDL Tested
+# ----  ------------------
+#  1    CREATE TABLE
+#  1    ALTER TABLE
+#  2    RENAME TABLE
+#  2    REPAIR TABLE
+#  3    OPTIMIZE TABLE
+#  3    DROP TABLE
+#  4    CREATE DATABASE
+#  4    DROP DATABASE
+#  5    ALTER DATABASE
+#  5    TRUNCATE TABLE
+#  6    DDL statements do not block each other
+#
+# The tests shall be run once for backup and again for restore.
+#
+# TODO : Add a native driver to the test when one becomes available
+#
+
+--source include/have_innodb.inc
+--source include/have_debug.inc
+
+#
+# Connections used in this test
+#
+# con1       used to create data, load data, and run the backup 
+# con2-con5  used for DDL statements: 2 before backup and 2 during backup
+# con6       used for setting and releasing breakpoints
+#
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connect (con3,localhost,root,,);
+connect (con4,localhost,root,,);
+connect (con5,localhost,root,,);
+connect (con6,localhost,root,,);
+
+connection con1;
+
+#
+# Backup test sequence diagram (not UML)
+#
+# The included test files follow this pattern of execution
+# for backup or restore operations.
+#
+# Four DDL statements and a backup command are specified.
+# The first two DDL statements are run as "in progress" when
+# the backup starts. The other two DDL statements are run
+# when the backup or restore is already running. Tests results
+# show the realization of the assumptions above.
+#
+#     con1      con2     con3     con4     con6
+#    (setup)     |        |        |        |        |
+#       |        |        |        |        |        |
+#       |        |        |        |        | lock("DDL_in_progress");
+#       |   statememt 1   |        |        |        |
+#       |        |   statement 2   |        |        |
+#       |        |        |        |        |  <wait for locks>
+# BACKUP/RESTORE |        |        |        |        |
+#       |        |        |        |        | lock("DDL_blocked");
+#       |        |        |        |        | <wait for locks>
+#       |      <...>    <...>      |        |        |
+#       |        |        |   statement 3   |        |
+#       |        |        |        |   statement 4   |
+#       |        |        |        |        | <wait for DDL blocker>
+#       |        |        |        |        |  <release locks>
+#     <...>      |        |      <...>    <...>      |
+#   (results)    |        |        |        |        |
+#
+# Note: The resume of the commands is indicated with <...> and
+#       may occur in any order.
+#
+
+
+##############################################################
+--echo 
+--echo Starting Test 1 - Backup
+--echo 
+##############################################################
+
+# Create data for this test and tailor it to the test.
+--source include/backup_ddl_create_data.inc
+DROP TABLE bup_ddl_blocker.t1, bup_ddl_blocker.t3;
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send ALTER TABLE bup_ddl_blocker.t2 ADD COLUMN col_b int;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Backing up database -- will block with lock
+send BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t1%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER TABLE bup_ddl_blocker.t2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send ALTER TABLE bup_ddl_blocker.t4 ADD COLUMN col_b int;
+
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t3%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER TABLE bup_ddl_blocker.t4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+##############################################################
+--echo
+--echo Verifying Test 1 results for backup.
+--echo
+##############################################################
+
+# Show that all changes got applied.
+--echo con1: Showing columns after updates and backup
+DESCRIBE bup_ddl_blocker.t1;
+DESCRIBE bup_ddl_blocker.t2;
+DESCRIBE bup_ddl_blocker.t3;
+DESCRIBE bup_ddl_blocker.t4;
+
+--echo con1: Dropping the database tables
+DROP TABLE bup_ddl_blocker.t1, bup_ddl_blocker.t2,
+           bup_ddl_blocker.t3, bup_ddl_blocker.t4;
+
+--echo con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+
+--echo con1: Showing columns that were backed up
+
+--echo con1: Table t3 should not be in restored data.
+--echo con1: Table t4 should not have new column in restored data.
+DESCRIBE bup_ddl_blocker.t1;
+DESCRIBE bup_ddl_blocker.t2;
+--error 1146
+DESCRIBE bup_ddl_blocker.t3;
+DESCRIBE bup_ddl_blocker.t4;
+
+
+
+##############################################################
+--echo 
+--echo Starting Test 1 - Restore
+--echo 
+##############################################################
+
+# Create data for this test and tailor it to the test.
+--source include/backup_ddl_create_data.inc
+DROP TABLE bup_ddl_blocker.t1, bup_ddl_blocker.t3;
+
+# Get a backup to work with.
+BACKUP DATABASE bup_ddl_blocker to 'bup_ddl_blocker_orig.bak';
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send ALTER TABLE bup_ddl_blocker.t2 ADD COLUMN col_b int;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Restoring database -- will block with lock
+send RESTORE FROM "bup_ddl_blocker_orig.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t1%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER TABLE bup_ddl_blocker.t2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send ALTER TABLE bup_ddl_blocker.t4 ADD COLUMN col_b int;
+
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t3%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER TABLE bup_ddl_blocker.t4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+--echo
+--echo Verifying Test 1 results for restore.
+--echo
+
+--echo con1: Table t1 should not be in restored data.
+--echo con1: Table t2 should not have new column in restored data.
+--echo con1: Table t3 should be in restored data.
+--echo con1: Table t4 should have new column in restored data.
+--error 1146
+DESCRIBE bup_ddl_blocker.t1;
+DESCRIBE bup_ddl_blocker.t2;
+DESCRIBE bup_ddl_blocker.t3;
+DESCRIBE bup_ddl_blocker.t4;
+
+
+
+##############################################################
+--echo 
+--echo Starting Test 2 - Backup
+--echo 
+##############################################################
+
+# Create data for this test and tailor it to the test.
+--source include/backup_ddl_create_data.inc
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send RENAME TABLE bup_ddl_blocker.t1 TO bup_ddl_blocker.t01;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send REPAIR TABLE bup_ddl_blocker.t2;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Backing up database -- will block with lock
+send BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RENAME TABLE bup_ddl_blocker.t1%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "REPAIR TABLE bup_ddl_blocker.t2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send RENAME TABLE bup_ddl_blocker.t3 TO bup_ddl_blocker.t03;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send REPAIR TABLE bup_ddl_blocker.t4;
+
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RENAME TABLE bup_ddl_blocker.t3%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "REPAIR TABLE bup_ddl_blocker.t4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+##############################################################
+--echo
+--echo Verifying Test 2 results for backup.
+--echo
+##############################################################
+
+# Show that all changes got applied.
+--echo con1: Showing columns after updates and backup
+use bup_ddl_blocker;
+SHOW TABLES;
+
+--echo con1: Dropping the database tables
+DROP TABLE bup_ddl_blocker.t01, bup_ddl_blocker.t2,
+           bup_ddl_blocker.t03, bup_ddl_blocker.t4;
+
+--echo con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+
+--echo con1: Showing columns that were backed up
+--echo con1: Table t01 should be in restore
+--echo con1: Table t03 should not be in restore
+use bup_ddl_blocker;
+SHOW TABLES;
+
+
+
+##############################################################
+--echo 
+--echo Starting Test 2 - Restore
+--echo 
+##############################################################
+
+# Create data for this test and tailor it to the test.
+--source include/backup_ddl_create_data.inc
+
+# Get a backup to work with.
+BACKUP DATABASE bup_ddl_blocker to 'bup_ddl_blocker_orig.bak';
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send RENAME TABLE bup_ddl_blocker.t1 TO bup_ddl_blocker.t01;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send REPAIR TABLE bup_ddl_blocker.t2;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Restoring database -- will block with lock
+send RESTORE FROM "bup_ddl_blocker_orig.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RENAME TABLE bup_ddl_blocker.t1%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "REPAIR TABLE bup_ddl_blocker.t2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send RENAME TABLE bup_ddl_blocker.t3 TO bup_ddl_blocker.t03;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send REPAIR TABLE bup_ddl_blocker.t4;
+
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RENAME TABLE bup_ddl_blocker.t3%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "REPAIR TABLE bup_ddl_blocker.t4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+##############################################################
+--echo
+--echo Verifying Test 2 results for restore.
+--echo
+##############################################################
+
+--echo con1: Table t01 should not be in restored data.
+use bup_ddl_blocker;
+SHOW TABLES;
+
+
+
+
+
+##############################################################
+--echo 
+--echo Starting Test 3 - Backup
+--echo 
+##############################################################
+
+# Create data for this test and tailor it to the test.
+--source include/backup_ddl_create_data.inc
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send OPTIMIZE TABLE bup_ddl_blocker.t1;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send DROP TABLE bup_ddl_blocker.t2;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Backing up database -- will block with lock
+send BACKUP DATABASE bup_ddl_blocker TO "bup_ddl_blocker.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "OPTIMIZE TABLE bup_ddl_blocker.t1%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "DROP TABLE bup_ddl_blocker.t2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send OPTIMIZE TABLE bup_ddl_blocker.t3;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send DROP TABLE bup_ddl_blocker.t4;
+
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "OPTIMIZE TABLE bup_ddl_blocker.t3%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "DROP TABLE bup_ddl_blocker.t4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+##############################################################
+--echo
+--echo Verifying Test 3 results for backup.
+--echo
+##############################################################
+
+# Show that all changes got applied.
+--echo con1: Showing columns after updates and backup
+use bup_ddl_blocker;
+SHOW TABLES;
+
+--echo con1: Dropping the database tables
+DROP TABLE bup_ddl_blocker.t1, bup_ddl_blocker.t3;
+
+--echo con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+
+--echo con1: Showing columns that were backed up
+--echo con1: Table t2 should not be in restore
+use bup_ddl_blocker;
+SHOW TABLES;
+
+
+
+##############################################################
+--echo 
+--echo Starting Test 3 - Restore
+--echo 
+##############################################################
+
+# Create data for this test and tailor it to the test.
+--source include/backup_ddl_create_data.inc
+
+# Get a backup to work with.
+BACKUP DATABASE bup_ddl_blocker to 'bup_ddl_blocker_orig.bak';
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send OPTIMIZE TABLE bup_ddl_blocker.t1;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send DROP TABLE bup_ddl_blocker.t2;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Restoring database -- will block with lock
+send RESTORE FROM "bup_ddl_blocker_orig.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "OPTIMIZE TABLE bup_ddl_blocker.t1%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "DROP TABLE bup_ddl_blocker.t2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send OPTIMIZE TABLE bup_ddl_blocker.t3;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send DROP TABLE bup_ddl_blocker.t4;
+
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "OPTIMIZE TABLE bup_ddl_blocker.t3%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "DROP TABLE bup_ddl_blocker.t4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+##############################################################
+--echo
+--echo Verifying Test 3 results for restore.
+--echo
+##############################################################
+
+--echo con1: Table t4 should not be in restored data.
+use bup_ddl_blocker;
+SHOW TABLES;
+
+
+
+
+
+##############################################################
+--echo 
+--echo Starting Test 4 - Backup
+--echo 
+##############################################################
+
+--disable_warnings
+DROP DATABASE IF EXISTS bup_ddl_blocker_1;
+DROP DATABASE IF EXISTS bup_ddl_blocker_2;
+DROP DATABASE IF EXISTS bup_ddl_blocker_3;
+DROP DATABASE IF EXISTS bup_ddl_blocker_4;
+--enable_warnings
+
+# Create databases.
+--echo con1: Creating databases
+CREATE DATABASE bup_ddl_blocker_2;
+CREATE DATABASE bup_ddl_blocker_4;
+
+# Create transaction tables and load them with data.
+--echo con1: Creating tables
+CREATE TABLE bup_ddl_blocker_2.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker_4.t1 (col_a CHAR(40)) ENGINE=MYISAM;
+
+--echo con1: Loading data
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("03 Some data to test");
+
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("03 Some data to test");
+
+--echo con1: Show that the new data doesn't exist before backup.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send CREATE DATABASE bup_ddl_blocker_1;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send DROP DATABASE bup_ddl_blocker_2;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Backing up database -- will block with lock
+send BACKUP DATABASE * TO "bup_ddl_blocker.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE DATABASE bup_ddl_blocker_1%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "DROP DATABASE bup_ddl_blocker_2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send CREATE DATABASE bup_ddl_blocker_3;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send DROP DATABASE bup_ddl_blocker_4;
+
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE DATABASE bup_ddl_blocker_3%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "DROP DATABASE bup_ddl_blocker_4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+##############################################################
+--echo
+--echo Verifying Test 4 results for backup.
+--echo
+##############################################################
+
+# Show that all changes got applied.
+--echo con1: Showing databases after updates and backup
+--echo con1: bup_ddl_blocker_2 and bup_ddl_blocker_4 are not present
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+
+--echo con1: Dropping the database tables
+DROP DATABASE bup_ddl_blocker_1;
+DROP DATABASE bup_ddl_blocker_3;
+
+--echo con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+
+--echo con1: Showing databases that were backed up
+--echo con1: bup_ddl_blocker_2 and bup_ddl_blocker_3 are not present
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+
+--echo con1: Cleanup
+DROP DATABASE bup_ddl_blocker_1;
+DROP DATABASE bup_ddl_blocker_4;
+
+
+##############################################################
+--echo 
+--echo Starting Test 4 - Restore
+--echo 
+##############################################################
+--disable_warnings
+DROP DATABASE IF EXISTS bup_ddl_blocker_1;
+DROP DATABASE IF EXISTS bup_ddl_blocker_2;
+DROP DATABASE IF EXISTS bup_ddl_blocker_3;
+DROP DATABASE IF EXISTS bup_ddl_blocker_4;
+--enable_warnings
+
+# Create databases.
+--echo con1: Creating databases
+CREATE DATABASE bup_ddl_blocker_2;
+CREATE DATABASE bup_ddl_blocker_4;
+
+# Create transaction tables and load them with data.
+--echo con1: Creating tables
+CREATE TABLE bup_ddl_blocker_2.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker_4.t1 (col_a CHAR(40)) ENGINE=MYISAM;
+
+--echo con1: Loading data
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("03 Some data to test");
+
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("03 Some data to test");
+
+--echo con1: Show that the new data doesn't exist before backup.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+
+# Get a backup to work with.
+BACKUP DATABASE bup_ddl_blocker_2, bup_ddl_blocker_4 to 'bup_ddl_blocker_orig.bak';
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send CREATE DATABASE bup_ddl_blocker_1;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send DROP DATABASE bup_ddl_blocker_2;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Restoring database -- will block with lock
+send RESTORE FROM "bup_ddl_blocker_orig.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE DATABASE bup_ddl_blocker_1%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "DROP DATABASE bup_ddl_blocker_2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send CREATE DATABASE bup_ddl_blocker_3;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send DROP DATABASE bup_ddl_blocker_4;
+
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "CREATE DATABASE bup_ddl_blocker_3%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "DROP DATABASE bup_ddl_blocker_4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+##############################################################
+--echo
+--echo Verifying Test 4 results for restore.
+--echo
+##############################################################
+
+--echo con1: Database bup_ddl_blocker_4 should not be in restored data.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+
+
+
+
+
+##############################################################
+--echo 
+--echo Starting Test 5 - Backup
+--echo 
+##############################################################
+
+--disable_warnings
+DROP DATABASE IF EXISTS bup_ddl_blocker_1;
+DROP DATABASE IF EXISTS bup_ddl_blocker_2;
+DROP DATABASE IF EXISTS bup_ddl_blocker_3;
+DROP DATABASE IF EXISTS bup_ddl_blocker_4;
+--enable_warnings
+
+# Create databases.
+--echo con1: Creating databases
+CREATE DATABASE bup_ddl_blocker_2 CHARACTER SET latin1;
+CREATE DATABASE bup_ddl_blocker_4 CHARACTER SET latin1;
+
+# Create transaction tables and load them with data.
+--echo con1: Creating tables
+CREATE TABLE bup_ddl_blocker_2.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker_4.t1 (col_a CHAR(40)) ENGINE=MYISAM;
+
+--echo con1: Loading data
+
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("03 Some data to test");
+
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("03 Some data to test");
+
+--echo con1: Show that the new data doesn't exist before backup.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send TRUNCATE TABLE bup_ddl_blocker_2.t1;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send ALTER DATABASE bup_ddl_blocker_2 CHARACTER SET latin2;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Backing up database -- will block with lock
+send BACKUP DATABASE * TO "bup_ddl_blocker.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "TRUNCATE TABLE bup_ddl_blocker_2%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER DATABASE bup_ddl_blocker_2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "BACKUP DATABASE%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send TRUNCATE TABLE bup_ddl_blocker_4.t1;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send ALTER DATABASE bup_ddl_blocker_4 CHARACTER SET latin2;
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER DATABASE bup_ddl_blocker_4%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "TRUNCATE TABLE bup_ddl_blocker_4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+##############################################################
+--echo
+--echo Verifying Test 5 results for backup.
+--echo
+##############################################################
+
+# Show that all changes got applied.
+--echo con1: Showing databases after updates and backup
+--echo con1: bup_ddl_blocker_2.t1 has been truncated.
+--echo con1: bup_ddl_blocker_1 and bup_ddl_blocker_3 are renamed 
+--echo con1: bup_ddl_blocker_4.t1 has been truncated.
+--echo con1: bup_ddl_blocker_2 and bup_ddl_blocker_4 have had their charset changed. 
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+SHOW CREATE DATABASE bup_ddl_blocker_2;
+SHOW CREATE DATABASE bup_ddl_blocker_4;
+SELECT * FROM bup_ddl_blocker_2.t1;
+SELECT * FROM bup_ddl_blocker_4.t1;
+
+--echo con1: Dropping the database tables
+DROP DATABASE bup_ddl_blocker_2;
+DROP DATABASE bup_ddl_blocker_4;
+
+--echo con1: Restoring the database
+RESTORE FROM "bup_ddl_blocker.bak";
+
+--echo con1: Showing databases that were backed up
+--echo con1: bup_ddl_blocker_1 has been renamed and
+
+#
+# NOTE: The online backup does not preserve character set information as 
+# it should. Thus, the results of this test will not show the changes
+# made with the alter database command to bup_ddl_blocker_2. This has
+# been reported as BUG#32190. 
+#
+
+--echo con1: bup_ddl_blocker_2.t1 has been truncated.
+--echo con1: bup_ddl_blocker_4 has not had its character set changed. 
+--echo con1: bup_ddl_blocker_4.t1 has not been truncated.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+SHOW CREATE DATABASE bup_ddl_blocker_2;
+SHOW CREATE DATABASE bup_ddl_blocker_4;
+SELECT * FROM bup_ddl_blocker_2.t1;
+SELECT * FROM bup_ddl_blocker_4.t1;
+
+--echo con1: Cleanup
+DROP DATABASE bup_ddl_blocker_2;
+DROP DATABASE bup_ddl_blocker_4;
+
+
+##############################################################
+--echo 
+--echo Starting Test 5 - Restore
+--echo 
+##############################################################
+
+--disable_warnings
+DROP DATABASE IF EXISTS bup_ddl_blocker_1;
+DROP DATABASE IF EXISTS bup_ddl_blocker_2;
+DROP DATABASE IF EXISTS bup_ddl_blocker_3;
+DROP DATABASE IF EXISTS bup_ddl_blocker_4;
+--enable_warnings
+
+# Create databases.
+--echo con1: Creating databases
+CREATE DATABASE bup_ddl_blocker_2 CHARACTER SET latin1;
+CREATE DATABASE bup_ddl_blocker_4 CHARACTER SET latin1;
+
+# Create transaction tables and load them with data.
+--echo con1: Creating tables
+CREATE TABLE bup_ddl_blocker_2.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_ddl_blocker_4.t1 (col_a CHAR(40)) ENGINE=MYISAM;
+
+--echo con1: Loading data
+
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_2.t1 VALUES ("03 Some data to test");
+
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker_4.t1 VALUES ("03 Some data to test");
+
+--echo con1: Show that the new data doesn't exist before backup.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+
+# Get a backup to work with.
+BACKUP DATABASE bup_ddl_blocker_2, bup_ddl_blocker_4
+                to 'bup_ddl_blocker_orig.bak';
+
+connection con6;
+
+# Set the breakpoint for DDL in progress.
+--echo con6: Getting lock on DDL in progress.
+SELECT get_lock("DDL_in_progress", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send TRUNCATE TABLE bup_ddl_blocker_2.t1;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send ALTER DATABASE bup_ddl_blocker_2 CHARACTER SET latin2;
+
+# Start the backup and allow it to break on lock.
+
+connection con1;
+
+--echo con1: Restoring database -- will block with lock
+send RESTORE FROM "bup_ddl_blocker_orig.bak";
+
+connection con6;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER DATABASE bup_ddl_blocker_2%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_in_progress"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "TRUNCATE TABLE bup_ddl_blocker_2%";
+--source include/wait_condition.inc
+
+# Now set the breakpoint for DDL blocker.
+# This releases lock on DDL_in_progress stopping all DDLs.
+--echo con6: Getting lock on DDL blocker.
+SELECT get_lock("DDL_blocked", 0);
+
+connection con6;
+
+--echo con6: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "RESTORE FROM%";
+--source include/wait_condition.inc
+
+connection con4;
+
+--echo con4: Try a DDL but it is blocked by backup -- will not be in backup
+send TRUNCATE TABLE bup_ddl_blocker_4.t1;
+
+connection con5;
+
+--echo con5: Try a DDL but it is blocked by backup -- will not be in backup
+send ALTER DATABASE bup_ddl_blocker_4 CHARACTER SET latin2;
+
+connection con6;
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "TRUNCATE TABLE bup_ddl_blocker_4%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "DDL blocker: DDL is blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER DATABASE bup_ddl_blocker_4%";
+--source include/wait_condition.inc
+
+--echo con6: Releasing lock
+SELECT release_lock("DDL_blocked");
+
+# Reconnect to connections and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+connection con5;
+--echo con5: Completing DDL
+reap;
+
+# Reconnect to con1 and let backup finish.
+
+connection con1;
+reap;
+
+##############################################################
+--echo
+--echo Verifying Test 5 results for restore.
+--echo
+##############################################################
+
+#
+# NOTE: The online backup does not preserve character set information as 
+# it should. Thus, the results of this test will not show the changes
+# made with the alter database command to bup_ddl_blocker_2. This has
+# been reported as BUG#32190. 
+#
+
+--echo con1: bup_ddl_blocker_4 has had its character set changed. 
+--echo con1: bup_ddl_blocker_2.t1 has not been truncated.
+--echo con1: bup_ddl_blocker_4.t1 has been truncated.
+SHOW DATABASES LIKE 'bup_ddl_blocker_%';
+SHOW CREATE DATABASE bup_ddl_blocker_2;
+SHOW CREATE DATABASE bup_ddl_blocker_4;
+SELECT * FROM bup_ddl_blocker_2.t1;
+SELECT * FROM bup_ddl_blocker_4.t1;
+
+--echo con1: Cleanup
+DROP DATABASE bup_ddl_blocker_2;
+DROP DATABASE bup_ddl_blocker_4;
+
+
+
+
+
+##############################################################
+--echo 
+--echo Starting Test 6
+--echo 
+##############################################################
+
+#
+# Test 6 sequence diagram (not UML)
+#
+#   con1     con2     con3     con4       con5
+#  (setup)    |        |        |          |
+#     |       |        |        |          |
+#     |   ALTER a.t1   |        |          |
+#     |       |   ALTER b.t2    |          |
+#     |       |        |    ALTER a.t3     |
+#     |       |        |        | lock("DDL_in_progress");
+#     |       |        |        |    <wait for locks>
+#     |       |        |        |    <release locks>
+#     |     <...>    <...>    <...>        |
+# (results)   |        |        |          | 
+#
+# Note: The resume of the commands is indicated with <...> and
+#       may occur in any order.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS bup_ddl_blocker.t1, bup_ddl_blocker.t3;
+--enable_warnings
+
+# Create transaction tables and load them with data.
+--echo con1: Creating tables
+CREATE TABLE bup_ddl_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE test.t2 (col_a CHAR(40)) ENGINE=MYISAM;
+CREATE TABLE bup_ddl_blocker.t3 (col_a CHAR(40)) ENGINE=MEMORY;
+
+--echo con1: Loading data
+INSERT INTO bup_ddl_blocker.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t1 VALUES ("03 Some data to test");
+
+INSERT INTO test.t2 VALUES ("01 Some data to test");
+INSERT INTO test.t2 VALUES ("02 Some data to test");
+INSERT INTO test.t2 VALUES ("03 Some data to test");
+
+INSERT INTO bup_ddl_blocker.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_ddl_blocker.t3 VALUES ("03 Some data to test");
+
+--echo con1: Show that the new data doesn't exist before backup.
+SELECT * FROM bup_ddl_blocker.t1;
+SELECT * FROM test.t2;
+SELECT * FROM bup_ddl_blocker.t3;
+
+connection con5;
+
+# Set the breakpoint for DDL in progress.
+--echo con5: Getting lock on DDL in progress.
+SELECT get_lock("DDL_not_blocked", 0);
+
+connection con2;
+
+--echo con2: Get a DDL going and stop in the middle
+send ALTER TABLE bup_ddl_blocker.t1 ADD COLUMN col_b int;
+
+connection con3;
+
+--echo con3: Get a DDL going and stop in the middle
+send ALTER TABLE test.t2 ADD COLUMN col_b int;
+
+connection con4;
+
+--echo con4: Get a DDL going and stop in the middle
+send ALTER TABLE bup_ddl_blocker.t3 ADD COLUMN col_b int;
+
+connection con5;
+
+# Wait for lock to be acquired and execution to reach breakpoint
+--echo con5: Checking locks
+let $wait_condition = SELECT state = "debug_sync_point: DDL_not_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER TABLE bup_ddl_blocker.t1%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_not_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER TABLE test.t2%";
+--source include/wait_condition.inc
+
+let $wait_condition = SELECT state = "debug_sync_point: DDL_not_blocked"
+                      FROM INFORMATION_SCHEMA.PROCESSLIST
+                      WHERE info LIKE "ALTER TABLE bup_ddl_blocker.t3%";
+--source include/wait_condition.inc
+
+--echo con5: Releasing lock
+SELECT release_lock("DDL_not_blocked");
+
+# Reconnect to con2, con3, and con4 and allow them to finish.
+
+connection con2;
+--echo con2: Completing DDL
+reap;
+
+connection con3;
+--echo con3: Completing DDL
+reap;
+
+connection con4;
+--echo con4: Completing DDL
+reap;
+
+# Reconnect to con1 and show results
+
+connection con1;
+
+# Do selects to show that all changes got applied.
+--echo con1: Showing columns after updates and backup
+DESCRIBE bup_ddl_blocker.t1;
+DESCRIBE test.t2;
+DESCRIBE bup_ddl_blocker.t3;
+
+##############################################################
+--echo
+--echo Verifying Test 6 results:
+--echo
+##############################################################
+
+--echo T1 should have the changes after backup - count(*) = 2
+SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'bup_ddl_blocker';
+
+--echo T2 should the changes after backup - count(*) = 2
+SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_NAME = 't2' AND TABLE_SCHEMA = 'test';
+
+--echo T3 should not have the changes after backup - count(*) = 2
+SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_NAME = 't3' AND TABLE_SCHEMA = 'bup_ddl_blocker';
+
+DROP TABLE test.t2;
+
+
+--echo con1: Cleanup
+DROP DATABASE bup_ddl_blocker;
+
+remove_file $MYSQLTEST_VARDIR/master-data/bup_ddl_blocker_orig.bak;
+remove_file $MYSQLTEST_VARDIR/master-data/bup_ddl_blocker.bak;
+
+
+
+
diff -Nrup a/sql/CMakeLists.txt b/sql/CMakeLists.txt
--- a/sql/CMakeLists.txt	2007-11-07 15:37:37 -05:00
+++ b/sql/CMakeLists.txt	2007-11-23 08:27:32 -05:00
@@ -76,6 +76,7 @@ ADD_EXECUTABLE(mysqld
                partition_info.cc rpl_utility.cc rpl_injector.cc sql_locale.cc
                rpl_rli.cc rpl_mi.cc sql_servers.cc
                sql_connect.cc scheduler.cc 
+               ddl_blocker.cc
                ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
                ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
                ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
diff -Nrup a/sql/Makefile.am b/sql/Makefile.am
--- a/sql/Makefile.am	2007-11-12 15:35:01 -05:00
+++ b/sql/Makefile.am	2007-11-23 08:27:33 -05:00
@@ -85,7 +85,7 @@ noinst_HEADERS =	item.h item_func.h item
 			event_data_objects.h event_scheduler.h \
 			sql_partition.h partition_info.h partition_element.h \
 			probes.h \
-			contributors.h sql_servers.h
+			contributors.h sql_servers.h ddl_blocker.h
 
 mysqld_SOURCES =	sql_lex.cc sql_handler.cc sql_partition.cc \
 			item.cc item_sum.cc item_buff.cc item_func.cc \
@@ -128,7 +128,7 @@ mysqld_SOURCES =	sql_lex.cc sql_handler.
                         event_queue.cc event_db_repository.cc events.cc \
 			sql_plugin.cc sql_binlog.cc \
 			sql_builtin.cc sql_tablespace.cc partition_info.cc \
-			sql_servers.cc
+			sql_servers.cc ddl_blocker.cc
 
 if HAVE_DTRACE
   mysqld_SOURCES += probes.d
diff -Nrup a/sql/backup/meta_backup.cc b/sql/backup/meta_backup.cc
--- a/sql/backup/meta_backup.cc	2007-11-12 15:58:18 -05:00
+++ b/sql/backup/meta_backup.cc	2007-11-23 08:27:39 -05:00
@@ -352,6 +352,14 @@ int silent_exec_query(THD *thd, String &
   thd->net.vio= 0;
   thd->net.no_send_error= 0;
 
+  /*
+    @todo The following is a work around for online backup and the DDL blocker.
+          It should be removed when the generalized solution is in place.
+          This is needed to ensure the restore (which uses DDL) is not blocked
+          when the DDL blocker is engaged.
+  */
+  thd->DDL_exception= TRUE;
+
   thd->query=         query.c_ptr();
   thd->query_length=  query.length();
 
@@ -362,6 +370,14 @@ int silent_exec_query(THD *thd, String &
 
   const char *ptr;
   ::mysql_parse(thd,thd->query,thd->query_length,&ptr);
+
+  /*
+    @todo The following is a work around for online backup and the DDL blocker.
+          It should be removed when the generalized solution is in place.
+          This is needed to ensure the restore (which uses DDL) is not blocked
+          when the DDL blocker is engaged.
+  */
+  thd->DDL_exception= FALSE;
 
   thd->net.vio= save_vio;
 
diff -Nrup a/sql/backup/sql_backup.cc b/sql/backup/sql_backup.cc
--- a/sql/backup/sql_backup.cc	2007-11-09 16:19:39 -05:00
+++ b/sql/backup/sql_backup.cc	2007-11-23 08:27:40 -05:00
@@ -30,6 +30,7 @@
 #include "debug.h"
 #include "be_default.h"
 #include "be_snapshot.h"
+#include "ddl_blocker.h"
 
 namespace backup {
 
@@ -59,6 +60,10 @@ bool test_error_flag= FALSE;
 #endif
 }
 
+extern pthread_mutex_t THR_LOCK_DDL_blocker;
+extern pthread_cond_t COND_backup_blocked;
+extern pthread_cond_t COND_DDL_blocker;
+
 /**
   Call backup kernel API to execute backup related SQL statement.
 
@@ -126,7 +131,11 @@ execute_backup_command(THD *thd, LEX *le
       {
         info.report_error(backup::log_level::INFO,ER_BACKUP_RESTORE_START);
 
-        // TODO: freeze all DDL operations here
+        /*
+          Freeze all DDL operations by turning on DDL blocker.
+        */
+        if (!block_DDL(thd))
+          DBUG_RETURN(backup::ERROR);
 
         info.save_errors();
         info.restore_all_dbs();
@@ -148,7 +157,12 @@ execute_backup_command(THD *thd, LEX *le
           send_summary(thd,info);
         }
 
-        // TODO: unfreeze DDL here
+        /*
+          Unfreeze all DDL operations by turning off DDL blocker.
+        */
+        unblock_DDL();
+        BACKUP_BREAKPOINT("DDL_unblocked");
+
       }
     } // if (!stream)
 
@@ -156,6 +170,12 @@ execute_backup_command(THD *thd, LEX *le
     
    restore_error:
 
+    /*
+      Unfreeze all DDL operations by turning off DDL blocker.
+    */
+    unblock_DDL();
+    BACKUP_BREAKPOINT("DDL_unblocked");
+
     res= res ? res : backup::ERROR;
     
    finish_restore:
@@ -177,6 +197,17 @@ execute_backup_command(THD *thd, LEX *le
     }
     else
     {
+      /*
+        Freeze all DDL operations by turning on DDL blocker.
+
+        Note: The block_ddl() call must occur before the information_schema
+              is read so that any new tables (e.g. CREATE in progress) can
+              be counted. Waiting until after this step caused backup to
+              skip new or dropped tables.
+      */
+      if (!block_DDL(thd))
+        goto backup_error;
+
       backup::Backup_info info(thd);
 
       if (check_info(thd,info))
@@ -184,8 +215,6 @@ execute_backup_command(THD *thd, LEX *le
 
       info.report_error(backup::log_level::INFO,ER_BACKUP_BACKUP_START);
 
-      // TODO: freeze all DDL operations here
-
       /*
         Save starting datetime of backup.
       */
@@ -232,13 +261,22 @@ execute_backup_command(THD *thd, LEX *le
       skr= my_time(0);
       gmtime_r(&skr, &info.end_time);
 
-      // TODO: unfreeze DDL here
+      /*
+        Unfreeze all DDL operations by turning off DDL blocker.
+      */
+      unblock_DDL();
+      BACKUP_BREAKPOINT("DDL_unblocked");
+
     } // if (!stream)
 
     goto finish_backup;
    
    backup_error:
    
+    /*
+      Unfreeze all DDL operations by turning off DDL blocker.
+    */
+    unblock_DDL();
     res= res ? res : backup::ERROR;
    
    finish_backup:
@@ -333,6 +371,7 @@ int mysql_backup(THD *thd,
 
  error:
 
+  unblock_DDL();
   DBUG_RETURN(backup::ERROR);
 }
 
diff -Nrup a/sql/ddl_blocker.cc b/sql/ddl_blocker.cc
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/sql/ddl_blocker.cc	2007-11-23 08:27:41 -05:00
@@ -0,0 +1,145 @@
+/* Copyright (C) 2004-2007 MySQL AB
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful, 
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+*/
+
+/**
+   @file
+
+   @brief Contains methods to implement a basic DDL blocker.
+
+   This file contains methods that allow DDL statements to register and 
+   another process (such as backup) to check to see if there are any DDL
+   statements running and block or exit if so. 
+
+   It also allows a process (such as backup) to register itself to block
+   all DDL methods until the process is complete.
+  */
+
+#include "ddl_blocker.h"
+
+my_bool DDL_blocked= FALSE;   ///< Assume DDL is not blocked.
+int DDL_blocks= 0;            ///< Number of DDL operations in progress.
+
+/**
+   start_DDL()
+
+   Increments the DDL_blocks counter to indicate a DDL is in progress.
+  */
+void start_DDL()
+{
+  DBUG_ENTER("start_DDL()");
+  pthread_mutex_lock(&THR_LOCK_DDL_blocker);
+  DDL_blocks++;
+  pthread_mutex_unlock(&THR_LOCK_DDL_blocker);
+  DBUG_VOID_RETURN;
+}
+
+/**
+   end_DDL()
+
+   Decrements the DDL_blocks counter to indicate a DDL is done.
+   Signals blocked process if counter == 0.
+  */
+void end_DDL()
+{
+  DBUG_ENTER("end_DDL()");
+  pthread_mutex_lock(&THR_LOCK_DDL_blocker);
+  if (DDL_blocks > 0)
+    DDL_blocks--;
+  if (DDL_blocks == 0)
+    pthread_cond_broadcast(&COND_process_blocked);
+  pthread_mutex_unlock(&THR_LOCK_DDL_blocker);
+  DBUG_VOID_RETURN;
+}
+
+/**
+    check_ddl_blocker
+
+    Check to see if we are blocked from continuing. If so,
+    wait until the blocked process signals the condition.
+
+    @param thd The THD object from the caller.
+    @returns TRUE
+  */
+my_bool check_DDL_blocker(THD *thd)
+{
+  DBUG_ENTER("check_DDL_blocker()");
+  BACKUP_BREAKPOINT("DDL_not_blocked");
+
+  /*
+    Check the ddl blocker condition. Rest until ddl blocker is released.
+  */
+  pthread_mutex_lock(&THR_LOCK_DDL_is_blocked);
+  thd->enter_cond(&COND_DDL_blocker, &THR_LOCK_DDL_is_blocked,
+                  "DDL blocker: DDL is blocked");
+  while (DDL_blocked && !thd->DDL_exception)
+    pthread_cond_wait(&COND_DDL_blocker, &THR_LOCK_DDL_is_blocked);
+  start_DDL();
+  thd->exit_cond("DDL blocker: Ok to run DDL");
+  BACKUP_BREAKPOINT("DDL_in_progress");
+  DBUG_RETURN(TRUE);
+}
+
+/**
+   block_DDL
+
+   This method is used to block all DDL commands. It checks the counter
+   DDL_blocks and if > 0 it blocks the process until all DDL operations are
+   complete and the condition variable has been signaled. 
+
+   The method also sets the boolean DDL_blocked to TRUE to tell the DDL
+   operations that they must block until the blocking operation is complete.
+
+   @params thd THD object.
+   @returns TRUE
+  */
+my_bool block_DDL(THD *thd)
+{
+  DBUG_ENTER("block_DDL()");
+
+  BACKUP_BREAKPOINT("DDL_in_progress");
+  /*
+    Only 1 DDL blocking operation can run at a time.
+  */
+  if (DDL_blocked)
+    DBUG_RETURN(FALSE);
+  /*
+    Check the ddl blocker condition. Rest until ddl blocker is released.
+  */
+  pthread_mutex_lock(&THR_LOCK_DDL_blocker);
+  thd->enter_cond(&COND_process_blocked, &THR_LOCK_DDL_blocker,
+                  "DDL blocker: Checking block on DDL changes");
+  while (DDL_blocks != 0)
+    pthread_cond_wait(&COND_process_blocked, &THR_LOCK_DDL_blocker);
+  DDL_blocked= TRUE;
+  thd->exit_cond("DDL blocker: Ok to run operation - no DDL in progress");
+  BACKUP_BREAKPOINT("DDL_blocked");
+  DBUG_RETURN(TRUE);
+}
+
+/**
+   unblock_DDL
+
+   This method is used to unblock all DDL commands. It sets the boolean
+   DDL_blocked to FALSE to tell the DDL operations that they can proceed.
+  */
+void unblock_DDL()
+{
+  pthread_mutex_lock(&THR_LOCK_DDL_blocker);
+  DDL_blocked= FALSE;
+  pthread_cond_broadcast(&COND_DDL_blocker);
+  pthread_mutex_unlock(&THR_LOCK_DDL_blocker);
+}
+
diff -Nrup a/sql/ddl_blocker.h b/sql/ddl_blocker.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/sql/ddl_blocker.h	2007-11-23 08:27:42 -05:00
@@ -0,0 +1,49 @@
+/**
+  @file
+
+  Header file for DDL blocker code.
+ */
+#include "mysql_priv.h"
+#include "debug.h"
+
+/*
+  Mutexes and condition variables -- see mysqld.cc.
+*/
+extern pthread_mutex_t THR_LOCK_DDL_blocker; 
+extern pthread_mutex_t THR_LOCK_DDL_is_blocked; 
+extern pthread_cond_t COND_DDL_blocker;
+extern pthread_cond_t COND_process_blocked;
+
+/*
+  Increments the backup's counter to indicate a DDL is in progress.
+*/
+void start_DDL();
+
+/*
+  Decrements the backup's counter to indicate a DDL is done.
+  Signals backup process if counter == 0.
+*/
+void end_DDL();
+
+/*
+  Check to see if we are blocked from continuing. If so,
+  wait until the backup process signals the condition.
+*/
+my_bool check_DDL_blocker(THD *thd);
+
+/*
+  This method is used to block all DDL commands. It checks the counter
+  DDL_blocks and if > 0 it blocks the backup until all DDL operations are
+  complete and the condition variable has been signaled. 
+
+  The method also sets the boolean DDL_blocked to TRUE to tell the DDL
+  operations that they must block until the backup operation is complete.
+*/
+my_bool block_DDL(THD *thd);
+
+/*
+  This method is used to unblock all DDL commands. It sets the boolean
+  DDL_blocked to FALSE to tell the DDL operations that they can proceed.
+*/
+void unblock_DDL();
+
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2007-11-12 15:35:02 -05:00
+++ b/sql/mysqld.cc	2007-11-23 08:27:34 -05:00
@@ -579,6 +579,16 @@ pthread_mutex_t LOCK_mysql_create_db, LO
 		LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
 	        LOCK_global_system_variables,
 		LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
+
+/*
+  These variables are used to implement the metadata freeze "DDL blocker"
+  for online backup.
+*/
+pthread_mutex_t THR_LOCK_DDL_blocker; 
+pthread_mutex_t THR_LOCK_DDL_is_blocked; 
+pthread_cond_t COND_DDL_blocker;
+pthread_cond_t COND_process_blocked;
+
 /*
   The below lock protects access to two global server variables:
   max_prepared_stmt_count and prepared_stmt_count. These variables
@@ -1337,6 +1347,10 @@ static void clean_up_mutexes()
   (void) pthread_mutex_destroy(&LOCK_bytes_sent);
   (void) pthread_mutex_destroy(&LOCK_bytes_received);
   (void) pthread_mutex_destroy(&LOCK_user_conn);
+  (void) pthread_mutex_destroy(&THR_LOCK_DDL_blocker);
+  (void) pthread_mutex_destroy(&THR_LOCK_DDL_is_blocked);
+  (void) pthread_cond_destroy(&COND_DDL_blocker);
+  (void) pthread_cond_destroy(&COND_process_blocked);
   Events::destroy_mutexes();
 #ifdef HAVE_OPENSSL
   (void) pthread_mutex_destroy(&LOCK_des_key_file);
@@ -3089,6 +3103,10 @@ static int init_thread_environment()
   (void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
   (void) pthread_mutex_init(&LOCK_prepared_stmt_count, MY_MUTEX_INIT_FAST);
   (void) pthread_mutex_init(&LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
+  (void) pthread_mutex_init(&THR_LOCK_DDL_blocker, MY_MUTEX_INIT_FAST);
+  (void) pthread_mutex_init(&THR_LOCK_DDL_is_blocked, MY_MUTEX_INIT_FAST);
+  (void) pthread_cond_init(&COND_DDL_blocker, NULL);
+  (void) pthread_cond_init(&COND_process_blocked, NULL);
 #ifdef HAVE_OPENSSL
   (void) pthread_mutex_init(&LOCK_des_key_file,MY_MUTEX_INIT_FAST);
 #ifndef HAVE_YASSL
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2007-10-31 17:45:33 -04:00
+++ b/sql/sql_class.cc	2007-11-23 08:27:36 -05:00
@@ -375,7 +375,14 @@ THD::THD()
    bootstrap(0),
    derived_tables_processing(FALSE),
    spcont(NULL),
-   m_lip(NULL)
+   m_lip(NULL),
+  /*
+    @todo The following is a work around for online backup and the DDL blocker.
+          It should be removed when the generalized solution is in place.
+          This is needed to ensure the restore (which uses DDL) is not blocked
+          when the DDL blocker is engaged.
+  */
+   DDL_exception(FALSE)
 {
   ulong tmp;
 
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h	2007-10-31 17:45:33 -04:00
+++ b/sql/sql_class.h	2007-11-23 08:27:37 -05:00
@@ -1512,6 +1512,14 @@ public:
   bool       derived_tables_processing;
   my_bool    tablespace_op;	/* This is TRUE in DISCARD/IMPORT TABLESPACE */
 
+  /*
+    @todo The following is a work around for online backup and the DDL blocker.
+          It should be removed when the generalized solution is in place.
+          This is needed to ensure the restore (which uses DDL) is not blocked
+          when the DDL blocker is engaged.
+  */
+  my_bool DDL_exception; // Allow some DDL if there is an exception
+
   sp_rcontext *spcont;		// SP runtime context
   sp_cache   *sp_proc_cache;
   sp_cache   *sp_func_cache;
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc	2007-11-12 15:35:04 -05:00
+++ b/sql/sql_parse.cc	2007-11-23 08:27:38 -05:00
@@ -27,6 +27,8 @@
 #include "sp_cache.h"
 #include "events.h"
 #include "sql_trigger.h"
+#include "debug.h"
+#include "ddl_blocker.h"
 
 /**
   @defgroup Runtime_Environment Runtime Environment
@@ -87,7 +89,6 @@ const char *xa_state_names[]={
   "NON-EXISTING", "ACTIVE", "IDLE", "PREPARED"
 };
 
-
 static void unlock_locked_tables(THD *thd)
 {
   if (thd->locked_tables)
@@ -2162,6 +2163,7 @@ mysql_execute_command(THD *thd)
           }
         }
 
+        check_DDL_blocker(thd);
         /*
           select_create is currently not re-execution friendly and
           needs to be created for every execution of a PS/SP.
@@ -2181,6 +2183,7 @@ mysql_execute_command(THD *thd)
           res= handle_select(thd, lex, result, 0);
           delete result;
         }
+        end_DDL();
       }
       else if (!(create_info.options & HA_LEX_CREATE_TMP_TABLE))
         create_table= lex->unlink_first_table(&link_to_local);
@@ -2188,6 +2191,7 @@ mysql_execute_command(THD *thd)
     }
     else
     {
+      check_DDL_blocker(thd);
       /* So that CREATE TEMPORARY TABLE gets to binlog at commit/rollback */
       if (create_info.options & HA_LEX_CREATE_TMP_TABLE)
         thd->options|= OPTION_KEEP_LOG;
@@ -2201,6 +2205,7 @@ mysql_execute_command(THD *thd)
                                 create_table->table_name, &create_info,
                                 &alter_info, 0, 0);
       }
+      end_DDL();
       if (!res)
 	send_ok(thd);
     }
@@ -2355,6 +2360,7 @@ end_with_restore_list:
       }
 
       thd->enable_slow_log= opt_log_slow_admin_statements;
+      check_DDL_blocker(thd);
       res= mysql_alter_table(thd, select_lex->db, lex->name.str,
                              &create_info,
                              first_table,
@@ -2362,6 +2368,7 @@ end_with_restore_list:
                              select_lex->order_list.elements,
                              (ORDER *) select_lex->order_list.first,
                              lex->ignore);
+      end_DDL();
       break;
     }
   case SQLCOM_RENAME_TABLE:
@@ -2390,8 +2397,13 @@ end_with_restore_list:
         goto error;
     }
 
+      check_DDL_blocker(thd);
     if (end_active_trans(thd) || mysql_rename_tables(thd, first_table, 0))
-      goto error;
+      {
+        end_DDL();
+        goto error;
+      }
+      end_DDL();
     break;
   }
 #ifndef EMBEDDED_LIBRARY
@@ -2441,7 +2453,9 @@ end_with_restore_list:
     if (check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables, 0))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
+    check_DDL_blocker(thd);
     res= mysql_repair_table(thd, first_table, &lex->check_opt);
+    end_DDL();
     /* ! we write after unlocking the table */
     if (!res && !lex->no_write_to_binlog)
     {
@@ -2491,9 +2505,11 @@ end_with_restore_list:
     if (check_table_access(thd, SELECT_ACL | INSERT_ACL, all_tables, 0))
       goto error; /* purecov: inspected */
     thd->enable_slow_log= opt_log_slow_admin_statements;
+    check_DDL_blocker(thd);
     res= (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) ?
       mysql_recreate_table(thd, first_table) :
       mysql_optimize_table(thd, first_table, &lex->check_opt);
+    end_DDL();
     /* ! we write after unlocking the table */
     if (!res && !lex->no_write_to_binlog)
     {
@@ -2736,7 +2752,10 @@ end_with_restore_list:
       goto error;
     }
 
+    check_DDL_blocker(thd);
     res= mysql_truncate(thd, first_table, 0);
+    end_DDL();
+
     break;
   case SQLCOM_DELETE:
   {
@@ -2835,9 +2854,11 @@ end_with_restore_list:
       /* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */
       thd->options|= OPTION_KEEP_LOG;
     }
+      check_DDL_blocker(thd);
     /* DDL and binlog write order protected by LOCK_open */
     res= mysql_rm_table(thd, first_table, lex->drop_if_exists,
 			lex->drop_temporary);
+      end_DDL();
   }
   break;
   case SQLCOM_SHOW_PROCESSLIST:
@@ -3068,8 +3089,10 @@ end_with_restore_list:
     if (check_access(thd,CREATE_ACL,lex->name.str, 0, 1, 0,
                      is_schema_db(lex->name.str)))
       break;
+    check_DDL_blocker(thd);
     res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias :
                               lex->name.str), &create_info, 0);
+    end_DDL();
     break;
   }
   case SQLCOM_DROP_DB:
@@ -3109,7 +3132,9 @@ end_with_restore_list:
                  ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
       goto error;
     }
+    check_DDL_blocker(thd);
     res= mysql_rm_db(thd, lex->name.str, lex->drop_if_exists, 0);
+    end_DDL();
     break;
   }
   case SQLCOM_ALTER_DB_UPGRADE:
@@ -3150,7 +3175,9 @@ end_with_restore_list:
       goto error;
     }
 
+    check_DDL_blocker(thd);
     res= mysql_upgrade_db(thd, db);
+    end_DDL();
     if (!res)
       send_ok(thd);
     break;
@@ -3188,7 +3215,9 @@ end_with_restore_list:
                  ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
       goto error;
     }
+    check_DDL_blocker(thd);
     res= mysql_alter_db(thd, db->str, &create_info);
+    end_DDL();
     break;
   }
   case SQLCOM_SHOW_CREATE_DB:

Thread
bk commit into 6.0 tree (cbell:1.2660) WL#4062cbell23 Nov