List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:December 5 2008 10:17pm
Subject:bzr push into mysql-6.0 branch (vvaintroub:2681 to 2683)
View as plain text  
 2683 Vladislav Vaintroub	2008-12-05 [merge]
      merge
removed:
  mysql-test/suite/backup/r/backup_commit_blocker.result
  mysql-test/suite/backup/t/backup_commit_blocker.test
  mysql-test/suite/falcon/r/falcon_bug_28095_II.result
  mysql-test/suite/falcon/t/falcon_bug_28095_II-master.opt
  mysql-test/suite/falcon/t/falcon_bug_28095_II.test
added:
  mysql-test/include/restart_mysqld.inc
  mysql-test/include/wait_until_disconnected.inc
  mysql-test/suite/backup/r/backup_vp_nontx.result
  mysql-test/suite/backup/r/backup_vp_tx.result
  mysql-test/suite/backup/t/backup_nodata_driver-master.opt
  mysql-test/suite/backup/t/backup_vp_nontx.test
  mysql-test/suite/backup/t/backup_vp_tx.test
  mysql-test/suite/backup_engines/t/disabled.def
  mysql-test/suite/falcon/r/falcon_bug_30124-big.result
  mysql-test/suite/falcon/r/falcon_bug_38186.result
  mysql-test/suite/falcon/r/falcon_bug_39708.result
  mysql-test/suite/falcon/r/falcon_bug_40130.result
  mysql-test/suite/falcon/r/falcon_bug_40158.result
  mysql-test/suite/falcon/t/falcon_bug_30124-big.test
  mysql-test/suite/falcon/t/falcon_bug_38186.test
  mysql-test/suite/falcon/t/falcon_bug_39708-master.opt
  mysql-test/suite/falcon/t/falcon_bug_39708.test
  mysql-test/suite/falcon/t/falcon_bug_40130.test
  mysql-test/suite/falcon/t/falcon_bug_40158.test
  mysql-test/suite/sys_vars/t/disabled.def
renamed:
  mysql-test/suite/falcon/r/falcon_bug_28095_I.result => mysql-test/suite/falcon/r/falcon_bug_28095.result
  mysql-test/suite/falcon/t/falcon_bug_28095_I.test => mysql-test/suite/falcon/t/falcon_bug_28095.test
modified:
  client/mysqltest.c
  configure.in
  mysql-test/include/wait_until_connected_again.inc
  mysql-test/lib/mtr_report.pl
  mysql-test/r/implicit_commit.result
  mysql-test/suite/backup/r/backup.result
  mysql-test/suite/backup/r/backup_backupdir.result
  mysql-test/suite/backup/r/backup_commit_backup.result
  mysql-test/suite/backup/r/backup_commit_restore.result
  mysql-test/suite/backup/r/backup_compression.result
  mysql-test/suite/backup/r/backup_concurrent.result
  mysql-test/suite/backup/r/backup_db_grants.result
  mysql-test/suite/backup/r/backup_ddl_blocker.result
  mysql-test/suite/backup/r/backup_errors.result
  mysql-test/suite/backup/r/backup_fkey.result
  mysql-test/suite/backup/r/backup_lock_myisam.result
  mysql-test/suite/backup/r/backup_logs.result
  mysql-test/suite/backup/r/backup_logs_output.result
  mysql-test/suite/backup/r/backup_logs_purge.result
  mysql-test/suite/backup/r/backup_no_be.result
  mysql-test/suite/backup/r/backup_no_data.result
  mysql-test/suite/backup/r/backup_nodata_driver.result
  mysql-test/suite/backup/r/backup_security.result
  mysql-test/suite/backup/r/backup_snapshot.result
  mysql-test/suite/backup/r/backup_timeout.result
  mysql-test/suite/backup/t/backup.test
  mysql-test/suite/backup/t/backup_backupdir.test
  mysql-test/suite/backup/t/backup_commit_backup.test
  mysql-test/suite/backup/t/backup_commit_restore.test
  mysql-test/suite/backup/t/backup_compression.test
  mysql-test/suite/backup/t/backup_concurrent.test
  mysql-test/suite/backup/t/backup_db_grants.test
  mysql-test/suite/backup/t/backup_ddl_blocker.test
  mysql-test/suite/backup/t/backup_errors.test
  mysql-test/suite/backup/t/backup_fkey.test
  mysql-test/suite/backup/t/backup_lock_myisam.test
  mysql-test/suite/backup/t/backup_logs.test
  mysql-test/suite/backup/t/backup_logs_output-master.opt
  mysql-test/suite/backup/t/backup_logs_purge.test
  mysql-test/suite/backup/t/backup_no_be.test
  mysql-test/suite/backup/t/backup_no_data.test
  mysql-test/suite/backup/t/backup_nodata_driver.test
  mysql-test/suite/backup/t/backup_security.test
  mysql-test/suite/backup/t/backup_snapshot.test
  mysql-test/suite/backup/t/backup_timeout.test
  mysql-test/suite/backup/t/disabled.def
  mysql-test/suite/backup_engines/include/backup_ptr_commit.inc
  mysql-test/suite/backup_engines/r/backup_online_testing.result
  mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result
  mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result
  mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result
  mysql-test/suite/backup_engines/r/backup_tmp_tables.result
  mysql-test/suite/backup_engines/t/backup_online_testing.test
  mysql-test/suite/backup_engines/t/backup_tmp_tables.test
  mysql-test/suite/falcon/r/falcon_bug_30124.result
  mysql-test/suite/falcon/t/disabled.def
  mysql-test/suite/falcon/t/falcon_bug_30124.test
  mysql-test/suite/rpl/r/rpl_backup.result
  mysql-test/suite/rpl/t/rpl_backup.test
  mysql-test/t/disabled.def
  mysql-test/t/implicit_commit.test
  sql/backup/backup_info.h
  sql/backup/backup_kernel.h
  sql/backup/kernel.cc
  sql/backup/logger.h
  sql/backup/restore_info.h
  sql/backup/stream.h
  sql/backup/stream_v1.c
  sql/lex.h
  sql/mysqld.cc
  sql/share/errmsg.txt
  sql/sql_parse.cc
  sql/sql_yacc.yy
  storage/falcon/BlobReference.cpp
  storage/falcon/Cache.cpp
  storage/falcon/Cache.h
  storage/falcon/CollationCaseless.cpp
  storage/falcon/Database.cpp
  storage/falcon/DateTime.cpp
  storage/falcon/Dbb.cpp
  storage/falcon/Dbb.h
  storage/falcon/DeferredIndex.cpp
  storage/falcon/DeferredIndexWalker.cpp
  storage/falcon/EditString.cpp
  storage/falcon/EncodedDataStream.cpp
  storage/falcon/Filter.cpp
  storage/falcon/FilterSet.cpp
  storage/falcon/FsbSort.cpp
  storage/falcon/IO.cpp
  storage/falcon/Index.cpp
  storage/falcon/IndexRootPage.cpp
  storage/falcon/Log.h
  storage/falcon/MemMgr.cpp
  storage/falcon/MemMgr.h
  storage/falcon/MemoryManager.h
  storage/falcon/Record.cpp
  storage/falcon/Record.h
  storage/falcon/RecordScavenge.cpp
  storage/falcon/RecordVersion.cpp
  storage/falcon/RecordVersion.h
  storage/falcon/RecoveryObjects.cpp
  storage/falcon/RecoveryObjects.h
  storage/falcon/SRLUpdateIndex.cpp
  storage/falcon/SRLUpdateRecords.cpp
  storage/falcon/SerialLog.cpp
  storage/falcon/SerialLog.h
  storage/falcon/SerialLogControl.cpp
  storage/falcon/SerialLogFile.cpp
  storage/falcon/SerialLogRecord.cpp
  storage/falcon/SerialLogRecord.h
  storage/falcon/Serialize.cpp
  storage/falcon/StorageHandler.cpp
  storage/falcon/StorageTableShare.cpp
  storage/falcon/StorageTableShare.h
  storage/falcon/StorageVersion.h
  storage/falcon/TableSpaceManager.cpp
  storage/falcon/TableSpaceManager.h
  storage/falcon/Transaction.cpp
  storage/falcon/ha_falcon.cpp
  storage/falcon/ha_falcon.h
  storage/falcon/plug.in
  mysql-test/suite/falcon/r/falcon_bug_28095.result
  mysql-test/suite/falcon/t/falcon_bug_28095.test

 2682 Vladislav Vaintroub	2008-12-05
       correct regression in backup - win32 does not call my_thread_init() automagically anymore
modified:
  sql/backup/be_thread.cc

 2681 Vladislav Vaintroub	2008-11-24
      Cleanup pthread_self(), pthread_create(), pthread_join() implementation on Windows.
      Prior implementation is was unnecessarily complicated and even differs in embedded
      and non-embedded case.
      
      Improvements in this patch:
      * pthread_t is now the unique thread ID, instead of HANDLE returned by beginthread
      
      This simplifies pthread_self() to be just straight GetCurrentThreadId().
      prior it was much  art involved in passing the beginthread() handle from the caller
      to the TLS structure in the child thread ( did not work for the main thread of course)
      
      * remove MySQL specific my_thread_init()/my_thread_end() from pthread_create.
      No automagic is done on Unix on pthread_create(). Having the same on Windows will 
      improve portability and avoid extra #ifdef's
      
      * remove redefinition of getpid() - it was defined as GetCurrentThreadId()
modified:
  include/config-win.h
  include/my_pthread.h
  mysys/my_thr_init.c
  mysys/my_wincond.c
  mysys/my_winthread.c
  sql/mysqld.cc
  sql/sql_connect.cc
  sql/sql_insert.cc

=== modified file 'client/mysqltest.c'
--- a/client/mysqltest.c	2008-10-20 09:16:47 +0000
+++ b/client/mysqltest.c	2008-11-03 17:51:36 +0000
@@ -279,6 +279,7 @@ enum enum_commands {
   Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_DIFF_FILES,
   Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR, Q_LIST_FILES,
   Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
+  Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
 
   Q_UNKNOWN,			       /* Unknown command.   */
   Q_COMMENT,			       /* Comments, ignored. */
@@ -370,6 +371,8 @@ const char *command_names[]=
   "list_files",
   "list_files_write_file",
   "list_files_append_file",
+  "send_shutdown",
+  "shutdown_server",
 
   0
 };
@@ -3855,6 +3858,145 @@ void do_set_charset(struct st_command *c
 }
 
 
+/*
+  Run query and return one field in the result set from the
+  first row and <column>
+*/
+
+int query_get_string(MYSQL* mysql, const char* query,
+                     int column, DYNAMIC_STRING* ds)
+{
+  MYSQL_RES *res= NULL;
+  MYSQL_ROW row;
+
+  if (mysql_query(mysql, query))
+    die("'%s' failed: %d %s", query,
+        mysql_errno(mysql), mysql_error(mysql));
+  if ((res= mysql_store_result(mysql)) == NULL)
+    die("Failed to store result: %d %s",
+        mysql_errno(mysql), mysql_error(mysql));
+
+  if ((row= mysql_fetch_row(res)) == NULL)
+  {
+    mysql_free_result(res);
+    ds= 0;
+    return 1;
+  }
+  init_dynamic_string(ds, (row[column] ? row[column] : "NULL"), ~0, 32);
+  mysql_free_result(res);
+  return 0;
+}
+
+
+static int my_kill(int pid, int sig)
+{
+#ifdef __WIN__
+  HANDLE proc;
+  if ((proc= OpenProcess(PROCESS_TERMINATE, FALSE, pid)) == NULL)
+    return -1;
+  if (sig == 0)
+  {
+    CloseHandle(proc);
+    return 0;
+  }
+  (void)TerminateProcess(proc, 201);
+  CloseHandle(proc);
+  return 1;
+#else
+  return kill(pid, sig);
+#endif
+}
+
+
+
+/*
+  Shutdown the server of current connection and
+  make sure it goes away within <timeout> seconds
+
+  NOTE! Currently only works with local server
+
+  SYNOPSIS
+  do_shutdown_server()
+  command  called command
+
+  DESCRIPTION
+  shutdown [<timeout>]
+
+*/
+
+void do_shutdown_server(struct st_command *command)
+{
+  int timeout=60, pid;
+  DYNAMIC_STRING ds_pidfile_name;
+  MYSQL* mysql = &cur_con->mysql;
+  static DYNAMIC_STRING ds_timeout;
+  const struct command_arg shutdown_args[] = {
+    {"timeout", ARG_STRING, FALSE, &ds_timeout, "Timeout before killing server"}
+  };
+  DBUG_ENTER("do_shutdown_server");
+
+  check_command_args(command, command->first_argument, shutdown_args,
+                     sizeof(shutdown_args)/sizeof(struct command_arg),
+                     ' ');
+
+  if (ds_timeout.length)
+  {
+    timeout= atoi(ds_timeout.str);
+    if (timeout == 0)
+      die("Illegal argument for timeout: '%s'", ds_timeout.str);
+  }
+  dynstr_free(&ds_timeout);
+
+  /* Get the servers pid_file name and use it to read pid */
+  if (query_get_string(mysql, "SHOW VARIABLES LIKE 'pid_file'", 1,
+                       &ds_pidfile_name))
+    die("Failed to get pid_file from server");
+
+  /* Read the pid from the file */
+  {
+    int fd;
+    char buff[32];
+
+    if ((fd= my_open(ds_pidfile_name.str, O_RDONLY, MYF(0))) < 0)
+      die("Failed to open file '%s'", ds_pidfile_name.str);
+    dynstr_free(&ds_pidfile_name);
+
+    if (my_read(fd, (uchar*)&buff,
+                sizeof(buff), MYF(0)) <= 0){
+      my_close(fd, MYF(0));
+      die("pid file was empty");
+    }
+    my_close(fd, MYF(0));
+
+    pid= atoi(buff);
+    if (pid == 0)
+      die("Pidfile didn't contain a valid number");
+  }
+  DBUG_PRINT("info", ("Got pid %d", pid));
+
+  /* Tell server to shutdown if timeout > 0*/
+  if (timeout && mysql_shutdown(mysql, SHUTDOWN_DEFAULT))
+    die("mysql_shutdown failed");
+
+  /* Check that server dies */
+  while(timeout--){
+    if (my_kill(0, pid) < 0){
+      DBUG_PRINT("info", ("Process %d does not exist anymore", pid));
+      break;
+    }
+    DBUG_PRINT("info", ("Sleeping, timeout: %d", timeout));
+    my_sleep(1000000L);
+  }
+
+  /* Kill the server */
+  DBUG_PRINT("info", ("Killing server, pid: %d", pid));
+  (void)my_kill(9, pid);
+
+  DBUG_VOID_RETURN;
+
+}
+
+
 #if MYSQL_VERSION_ID >= 50000
 /* List of error names to error codes, available from 5.0 */
 typedef struct
@@ -7440,6 +7582,14 @@ int main(int argc, char **argv)
       case Q_PING:
 	(void) mysql_ping(&cur_con->mysql);
 	break;
+      case Q_SEND_SHUTDOWN:
+        handle_command_error(command,
+                             mysql_shutdown(&cur_con->mysql,
+                                            SHUTDOWN_DEFAULT));
+        break;
+      case Q_SHUTDOWN_SERVER:
+        do_shutdown_server(command);
+        break;
       case Q_EXEC:
 	do_exec(command);
 	command_executed++;

=== modified file 'configure.in'
--- a/configure.in	2008-11-11 14:46:00 +0000
+++ b/configure.in	2008-11-13 14:22:12 +0000
@@ -1800,9 +1800,6 @@ case "$with_atomic_ops" in
    *) AC_MSG_ERROR(["$with_atomic_ops" is not a valid value for --with-atomic-ops]) ;;
 esac
 
-# Check if we have the atomic_* functions on Solaris
-AC_CHECK_FUNC(atomic_cas_32, AC_DEFINE([HAVE_SOLARIS_ATOMIC], [1], [Define to 1 if Solaris support atomic functions.]))
-
 # Force static compilation to avoid linking problems/get more speed
 AC_ARG_WITH(mysqld-ldflags,
     [  --with-mysqld-ldflags   Extra linking arguments for mysqld],

=== added file 'mysql-test/include/restart_mysqld.inc'
--- a/mysql-test/include/restart_mysqld.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/restart_mysqld.inc	2008-11-13 14:55:42 +0000
@@ -0,0 +1,28 @@
+#
+# Write file to make mysql-test-run.pl expect the "crash", but don't start
+# it until it's told to
+--write_file $MYSQLTEST_VARDIR/tmp/master0.expect
+wait
+EOF
+
+# Send shutdown to the connected server and give
+# it 30 seconds to die before zapping it.
+shutdown_server 30;
+
+# Check server is gone
+--source include/wait_until_disconnected.inc
+
+# Write file to make mysql-test-run.pl start up the server again
+--append_file $MYSQLTEST_VARDIR/tmp/master0.expect
+restart
+EOF
+
+# Turn on reconnect
+--enable_reconnect
+
+# Call script that will poll the server waiting for it to be back online again
+--source include/wait_until_connected_again.inc
+
+# Turn off reconnect again
+--disable_reconnect
+

=== modified file 'mysql-test/include/wait_until_connected_again.inc'
--- a/mysql-test/include/wait_until_connected_again.inc	2008-02-06 17:04:06 +0000
+++ b/mysql-test/include/wait_until_connected_again.inc	2008-11-13 14:55:42 +0000
@@ -4,11 +4,14 @@
 # You should have done --enable_reconnect first
 --disable_result_log
 --disable_query_log
-let $counter= 5000;
-let $mysql_errno= 1;
+let $counter= 600;
+let $mysql_errno= 9999;
 while ($mysql_errno)
 {
-  --error 0,2002,2003,2006,1053
+  # Strangely enough, the server might return "Too many connections"
+  # while being shutdown, thus 1040 is an "allowed" error
+  # See BUG#36228
+  --error 0,1040,1053,2002,2003,2006,2013
   show status;
 
   dec $counter;
@@ -16,7 +19,7 @@ while ($mysql_errno)
   {
     --die Server failed to restart
   }
-  --sleep 0.1
+  --real_sleep 0.1
 }
 --enable_query_log
 --enable_result_log

=== added file 'mysql-test/include/wait_until_disconnected.inc'
--- a/mysql-test/include/wait_until_disconnected.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/wait_until_disconnected.inc	2008-11-03 17:51:36 +0000
@@ -0,0 +1,21 @@
+#
+# Include this script to wait until the connection to the
+# server has been dropped
+--disable_result_log
+--disable_query_log
+let $counter= 500;
+let $mysql_errno= 9999;
+while (!$mysql_errno)
+{
+  --error 0,1053,2002,2006
+  show status;
+
+  dec $counter;
+  if (!$counter)
+  {
+    --die Server failed to dissapear
+  }
+  --sleep 0.1
+}
+--enable_query_log
+--enable_result_log

=== modified file 'mysql-test/lib/mtr_report.pl'
--- a/mysql-test/lib/mtr_report.pl	2008-10-27 13:06:21 +0000
+++ b/mysql-test/lib/mtr_report.pl	2008-11-21 15:02:34 +0000
@@ -352,6 +352,19 @@ sub mtr_report_stats ($) {
 		  /Restore:/ or /was skipped because the user does not exist/
 		) or
                 
+		# backup_logs_output has warning because --log-backup-output option does 
+    # not have argument
+		($testname eq 'backup.backup_logs_output') and
+		(
+		  /Although a path was specified for the/
+		) or
+                
+		# backup_nodata_driver intentionally provokes an error in opening a MERGE table
+		($testname eq 'backup.backup_nodata_driver') and
+		(
+		  /Restore: Open and lock tables failed in RESTORE/
+		) or
+                
 		# The tablespace test triggers error below on purpose
 		($testname eq 'backup.backup_tablespace') and
 		(

=== modified file 'mysql-test/r/implicit_commit.result'
--- a/mysql-test/r/implicit_commit.result	2008-07-26 16:38:20 +0000
+++ b/mysql-test/r/implicit_commit.result	2008-11-20 14:03:27 +0000
@@ -1035,7 +1035,7 @@ YES
 # SQLCOM_RESTORE
 #
 INSERT INTO db1.trans (a) VALUES (1);
-restore from 'backup_db1.ba';
+restore from 'backup_db1.ba' overwrite;
 CALL db1.test_if_commit();
 IMPLICIT COMMIT
 YES

=== modified file 'mysql-test/suite/backup/r/backup.result'
--- a/mysql-test/suite/backup/r/backup.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup.result	2008-11-17 09:57:51 +0000
@@ -562,7 +562,7 @@ id	ccode
 2	bb
 4	dd
 do restore
-RESTORE FROM 'bup_delete.bak';
+RESTORE FROM 'bup_delete.bak' OVERWRITE;
 backup_id
 #
 show the data
@@ -597,7 +597,7 @@ BACKUP DATABASE bup_default TO 'bup_defa
 backup_id
 #
 Restore the database.
-RESTORE FROM 'bup_default_timestamp.bak';
+RESTORE FROM 'bup_default_timestamp.bak' OVERWRITE;
 backup_id
 #
 Show data after restore (timestamp should be same as above).

=== modified file 'mysql-test/suite/backup/r/backup_backupdir.result'
--- a/mysql-test/suite/backup/r/backup_backupdir.result	2008-10-24 15:37:11 +0000
+++ b/mysql-test/suite/backup/r/backup_backupdir.result	2008-11-17 09:57:51 +0000
@@ -15,7 +15,7 @@ backup_id
 Ensure backup image file went to the correct location
 /backup/bup_backupdir.bak
 Perform restore
-RESTORE FROM 'bup_backupdir1.bak';
+RESTORE FROM 'bup_backupdir1.bak' OVERWRITE;
 backup_id
 #
 Now do the backup and restore by specifying a path.
@@ -25,7 +25,7 @@ backup_id
 #
 Ensure backup image file went to the correct location
 Perform restore
-RESTORE FROM '../bup_backupdir2.bak';
+RESTORE FROM '../bup_backupdir2.bak' OVERWRITE;
 backup_id
 #
 Perform backup

=== modified file 'mysql-test/suite/backup/r/backup_commit_backup.result'
--- a/mysql-test/suite/backup/r/backup_commit_backup.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_commit_backup.result	2008-11-17 09:57:51 +0000
@@ -299,7 +299,7 @@ SELECT release_lock("sync");
 release_lock("sync")
 1
 Checking contents of the backup image
-RESTORE FROM 'db1.bak';
+RESTORE FROM 'db1.bak' OVERWRITE;
 backup_id
 #
 SELECT * FROM db1.t1;

=== removed file 'mysql-test/suite/backup/r/backup_commit_blocker.result'
--- a/mysql-test/suite/backup/r/backup_commit_blocker.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_commit_blocker.result	1970-01-01 00:00:00 +0000
@@ -1,469 +0,0 @@
-SET DEBUG_SYNC= 'RESET';
-DROP DATABASE IF EXISTS bup_commit_blocker;
-CREATE DATABASE bup_commit_blocker;
-
-Starting Test 1
-
-con1: Creating tables
-CREATE TABLE bup_commit_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
-CREATE TABLE bup_commit_blocker.t2 (col_a CHAR(40)) ENGINE=INNODB;
-CREATE TABLE bup_commit_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
-con1: Loading data
-INSERT INTO bup_commit_blocker.t1 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("05 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("05 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("05 Some data to test");
-con1: Show that the new data doesn't exist before backup.
-SELECT * FROM bup_commit_blocker.t1;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t2;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t3;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-con2: Get a transaction going and stop in the middle
-Assumption (a): TRX in progress is not included in backup
-BEGIN;
-UPDATE bup_commit_blocker.t1 SET col_a = "con2: CHANGED" WHERE col_a LIKE '01%';
-con3: Start a transaction and send commit after lock is taken
-Assumption (b): TRX in commit is included in backup
-BEGIN;
-INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 04 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 05 Some data to test");
-con1: Activate synchronization points for BACKUP.
-SET DEBUG_SYNC= 'before_commit_block SIGNAL bup_commit_block
-                 WAIT_FOR bup_go_read_lock';
-SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL bup_read_lock';
-SET DEBUG_SYNC= 'before_backup_data_lock WAIT_FOR commit_done';
-SET DEBUG_SYNC= 'before_backup_unblock_commit SIGNAL bup_read_locked
-                 WAIT_FOR finish';
-con1: Backing up database -- will block with lock
-BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_block';
-con3: Activate synchronization points for COMMIT.
-SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_read_locked
-                 WAIT_FOR commit_go_done';
-SET DEBUG_SYNC= 'after_commit SIGNAL commit_done WAIT_FOR finish';
-con3: Starting commit -- will block on sync point
-COMMIT;
-con5: Wait for COMMIT to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR commit_read_locked';
-con5: Let BACKUP run until the next sync point.
-SET DEBUG_SYNC= 'now SIGNAL bup_go_read_lock WAIT_FOR bup_read_lock';
-con5: Let COMMIT continue until end of statement.
-con5: The completed COMMIT implicitly wakes BACKUP.
-con5: So wait for BACKUP to reach the next synchronization point.
-SET DEBUG_SYNC= 'now SIGNAL commit_go_done WAIT_FOR bup_read_locked';
-con4: Activate synchronization point for BEGIN.
-SET DEBUG_SYNC= 'before_begin_trans SIGNAL begin_starting
-                 WAIT_FOR finish';
-con4: Starting begin -- will block on sync point
-Assumption (c): TRX not started is not included in backup
-BEGIN;
-con5: Wait for BEGIN to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR begin_starting';
-con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
-con2: Completing transaction
-DELETE FROM bup_commit_blocker.t1 WHERE col_a LIKE '02%';
-COMMIT;
-con3: Fetch COMMIT result
-con4: Fetch BEGIN result and completing transaction
-UPDATE bup_commit_blocker.t3 SET col_a = "con4: 05 CHANGED" WHERE col_a LIKE '05%';
-UPDATE bup_commit_blocker.t3 SET col_a = "con4: 06 CHANGED" WHERE col_a LIKE '06%';
-COMMIT;
-con1: Fetch BACKUP result
-backup_id
-#
-con1: Showing data after updates and backup
-SELECT * FROM bup_commit_blocker.t1;
-col_a
-con2: CHANGED
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t2;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-con3: 04 Some data to test
-con3: 05 Some data to test
-SELECT * FROM bup_commit_blocker.t3;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-con4: 05 CHANGED
-con1: Dropping the database
-DROP TABLE bup_commit_blocker.t1;
-DROP TABLE bup_commit_blocker.t2;
-DROP TABLE bup_commit_blocker.t3;
-con1: Restoring the database
-RESTORE FROM "bup_commit_blocker.bak";
-backup_id
-#
-con1: Showing the data (no new data should be here).
-SELECT * FROM bup_commit_blocker.t1;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t2;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-con3: 04 Some data to test
-con3: 05 Some data to test
-SELECT * FROM bup_commit_blocker.t3;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-
-Verifying test 1 results:
-
-T1 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t1 WHERE col_a like 'con2%';
-count(*)
-0
-T2 should have the changes after backup - count(*) = 2
-SELECT count(*) FROM bup_commit_blocker.t2 WHERE col_a like 'con3%';
-count(*)
-2
-T3 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t3 WHERE col_a like 'con4%';
-count(*)
-0
-con1: Cleanup
-DROP DATABASE bup_commit_blocker;
-SET DEBUG_SYNC= 'RESET';
-
-Starting Test 2
-
-CREATE DATABASE bup_commit_blocker;
-con1: Creating tables
-CREATE TABLE bup_commit_blocker.t5 (col_a int) ENGINE=MEMORY;
-con1: Loading data
-INSERT INTO bup_commit_blocker.t5 VALUES (10), (20), (30), (40), (50);
-con1: Show that the new data doesn't exist before backup.
-SELECT * FROM bup_commit_blocker.t5;
-col_a
-10
-20
-30
-40
-50
-con1: Activate synchronization point for BACKUP.
-SET DEBUG_SYNC= 'before_backup_data_unlock SIGNAL bup_data_unlock
-                 WAIT_FOR finish';
-con1: Backing up database -- will block with lock
-BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_data_unlock';
-con7: Show that the statement in progress has executed before backup.
-SELECT * FROM bup_commit_blocker.t5;
-col_a
-10
-20
-30
-40
-50
-con7: Activate synchronization point for UPDATE.
-SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL upd_read_lock';
-con7: Starting non-trx about to start
-Assumption (e): non-TRX not started is not included in backup
-UPDATE bup_commit_blocker.t5 SET col_a = 333 WHERE col_a = 30;
-con5: Wait for UPDATE to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR upd_read_lock';
-con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
-con7: Fetch UPDATE result
-con1: Fetch BACKUP result
-backup_id
-#
-con1: Showing data after updates and backup
-SELECT * FROM bup_commit_blocker.t5;
-col_a
-10
-20
-333
-40
-50
-con1: Dropping the database
-DROP TABLE bup_commit_blocker.t5;
-con1: Restoring the database
-RESTORE FROM "bup_commit_blocker.bak";
-backup_id
-#
-con1: Showing the data (no new data should be here).
-SELECT * FROM bup_commit_blocker.t5;
-col_a
-10
-20
-30
-40
-50
-
-Verifying test 2 results:
-
-T5 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t5 WHERE col_a = 333;
-count(*)
-0
-con1: Cleanup
-DROP DATABASE bup_commit_blocker;
-SET DEBUG_SYNC= 'RESET';
-
-Starting Test 3
-
-CREATE DATABASE bup_commit_blocker;
-con1: Creating tables
-CREATE TABLE bup_commit_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
-CREATE TABLE bup_commit_blocker.t2 (col_a CHAR(40)) ENGINE=INNODB;
-CREATE TABLE bup_commit_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
-CREATE TABLE bup_commit_blocker.t5 (col_a int) ENGINE=MEMORY;
-con1: Loading data
-INSERT INTO bup_commit_blocker.t1 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("05 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("05 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("05 Some data to test");
-INSERT INTO bup_commit_blocker.t5 VALUES (10), (20), (30), (40), (50);
-con1: Show that the new data doesn't exist before backup.
-SELECT * FROM bup_commit_blocker.t1;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t2;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t3;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t5;
-col_a
-10
-20
-30
-40
-50
-con2: Get a transaction going and stop in the middle
-Assumption (a): TRX in progress is not included in backup
-BEGIN;
-UPDATE bup_commit_blocker.t1 SET col_a = "con2: CHANGED" WHERE col_a LIKE '01%';
-con3: Start a transaction and send commit after lock is taken
-Assumption (b): TRX in commit is included in backup
-BEGIN;
-INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 04 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 05 Some data to test");
-con1: Activate synchronization points for BACKUP.
-SET DEBUG_SYNC= 'before_commit_block SIGNAL bup_commit_block
-                 WAIT_FOR bup_go_read_lock';
-SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL bup_read_lock';
-SET DEBUG_SYNC= 'before_backup_data_lock WAIT_FOR commit_done';
-SET DEBUG_SYNC= 'before_backup_unblock_commit SIGNAL bup_read_locked
-                 WAIT_FOR finish';
-con1: Backing up database -- will block with lock
-BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_block';
-con3: Activate synchronization points for COMMIT.
-SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_read_locked
-                 WAIT_FOR commit_go_done';
-SET DEBUG_SYNC= 'after_commit SIGNAL commit_done WAIT_FOR finish';
-con3: Starting commit -- will block on sync point
-COMMIT;
-con5: Wait for COMMIT to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR commit_read_locked';
-con5: Let BACKUP run until the next sync point.
-SET DEBUG_SYNC= 'now SIGNAL bup_go_read_lock WAIT_FOR bup_read_lock';
-con5: Let COMMIT continue until the sync point at its end.
-con5: The completed COMMIT implicitly wakes BACKUP.
-con5: So wait for BACKUP to reach the next synchronization point.
-SET DEBUG_SYNC= 'now SIGNAL commit_go_done WAIT_FOR bup_read_locked';
-con4: Activate synchronization point for BEGIN.
-SET DEBUG_SYNC= 'before_begin_trans SIGNAL begin_starting
-                 WAIT_FOR finish';
-con4: Starting begin -- will block with lock
-Assumption (c): TRX not started is not included in backup
-BEGIN;
-con5: Wait for BEGIN to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR begin_starting';
-con7: Show that the statement in progress has executed before backup.
-SELECT * FROM bup_commit_blocker.t5;
-col_a
-10
-20
-30
-40
-50
-con7: Activate synchronization point for DELETE.
-SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL del_read_lock';
-con7: Starting non-trx about to start -- will block with lock
-Assumption (e): non-TRX not started is not included in backup
-DELETE FROM bup_commit_blocker.t5 WHERE col_a = 50;
-con5: Wait for DELETE to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR del_read_lock';
-con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
-con2: Completing transaction
-DELETE FROM bup_commit_blocker.t2 WHERE col_a LIKE '02%';
-COMMIT;
-con3: Fetch COMMIT result
-con4: Fetch BEGIN result and completing transaction
-UPDATE bup_commit_blocker.t3 SET col_a = "con4: 05 CHANGED" WHERE col_a LIKE '05%';
-UPDATE bup_commit_blocker.t3 SET col_a = "con4: 06 CHANGED" WHERE col_a LIKE '06%';
-COMMIT;
-con7: Fetch DELETE result
-con1: Fetch BACKUP result
-backup_id
-#
-con1: Showing data after updates and backup
-SELECT * FROM bup_commit_blocker.t1;
-col_a
-con2: CHANGED
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t2;
-col_a
-01 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-con3: 04 Some data to test
-con3: 05 Some data to test
-SELECT * FROM bup_commit_blocker.t3;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-con4: 05 CHANGED
-SELECT * FROM bup_commit_blocker.t5;
-col_a
-10
-20
-30
-40
-con1: Dropping the database
-DROP TABLE bup_commit_blocker.t1;
-DROP TABLE bup_commit_blocker.t2;
-DROP TABLE bup_commit_blocker.t3;
-DROP TABLE bup_commit_blocker.t5;
-con1: Restoring the database
-RESTORE FROM "bup_commit_blocker.bak";
-backup_id
-#
-con1: Showing the data (no new data should be here).
-SELECT * FROM bup_commit_blocker.t1;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t2;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-con3: 04 Some data to test
-con3: 05 Some data to test
-SELECT * FROM bup_commit_blocker.t3;
-col_a
-01 Some data to test
-02 Some data to test
-03 Some data to test
-04 Some data to test
-05 Some data to test
-SELECT * FROM bup_commit_blocker.t5;
-col_a
-10
-20
-30
-40
-50
-
-Verifying test 3 results:
-
-T1 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t1 WHERE col_a like 'con2%';
-count(*)
-0
-T2 should have the changes after backup - count(*) = 2
-SELECT count(*) FROM bup_commit_blocker.t2 WHERE col_a like 'con3%';
-count(*)
-2
-T3 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t3 WHERE col_a like 'con4%';
-count(*)
-0
-T5 should not have the changes after backup - count(*) = 1
-SELECT count(*) FROM bup_commit_blocker.t5 WHERE col_a >= 50;
-count(*)
-1
-con1: Cleanup
-DROP DATABASE bup_commit_blocker;
-SET DEBUG_SYNC= 'RESET';

=== modified file 'mysql-test/suite/backup/r/backup_commit_restore.result'
--- a/mysql-test/suite/backup/r/backup_commit_restore.result	2008-10-23 08:13:54 +0000
+++ b/mysql-test/suite/backup/r/backup_commit_restore.result	2008-11-17 09:57:51 +0000
@@ -6,7 +6,7 @@ INSERT INTO t1 VALUES ('a1');
 BACKUP DATABASE commit_test TO '81';
 backup_id
 #
-RESTORE FROM '81';
+RESTORE FROM '81' OVERWRITE;
 backup_id
 #
 SELECT * FROM t1;
@@ -24,7 +24,7 @@ INSERT INTO t2 VALUES ('a2');
 BACKUP DATABASE commit_test TO '82';
 backup_id
 #
-RESTORE FROM '82';
+RESTORE FROM '82' OVERWRITE;
 backup_id
 #
 SELECT * FROM t1;
@@ -51,7 +51,7 @@ INSERT INTO t3 VALUES ('a3');
 BACKUP DATABASE commit_test TO '83';
 backup_id
 #
-RESTORE FROM '83';
+RESTORE FROM '83' OVERWRITE;
 backup_id
 #
 SELECT * FROM t1;
@@ -89,7 +89,7 @@ INSERT INTO t4 VALUES ('a4');
 BACKUP DATABASE commit_test TO '84';
 backup_id
 #
-RESTORE FROM '84';
+RESTORE FROM '84' OVERWRITE;
 backup_id
 #
 SELECT * FROM t1;
@@ -138,7 +138,7 @@ INSERT INTO t4 VALUES ('a5');
 BACKUP DATABASE commit_test TO '85';
 backup_id
 #
-RESTORE FROM '85';
+RESTORE FROM '85' OVERWRITE;
 backup_id
 #
 SELECT * FROM t1;
@@ -198,7 +198,7 @@ BACKUP DATABASE commit_test TO '86';
 backup_id
 #
 SET @@autocommit=0;
-RESTORE FROM '86';
+RESTORE FROM '86' OVERWRITE;
 backup_id
 #
 DROP TABLE t5;
@@ -265,7 +265,7 @@ BACKUP DATABASE commit_test TO '87';
 backup_id
 #
 SET @@autocommit=1;
-RESTORE FROM '87';
+RESTORE FROM '87' OVERWRITE;
 backup_id
 #
 SELECT * FROM t1;

=== modified file 'mysql-test/suite/backup/r/backup_compression.result'
--- a/mysql-test/suite/backup/r/backup_compression.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_compression.result	2008-11-17 09:57:51 +0000
@@ -7,13 +7,13 @@ CREATE TABLE db1.t2(a INT);
 BACKUP DATABASE db1 TO 'db2.bak.gz' WITH COMPRESSION COMPRESSION_ALGORITHM=gzip;
 backup_id
 #
-RESTORE FROM 'db1.bak.gz';
+RESTORE FROM 'db1.bak.gz' OVERWRITE;
 backup_id
 #
 SHOW TABLES FROM db1;
 Tables_in_db1
 t1
-RESTORE FROM 'db2.bak.gz';
+RESTORE FROM 'db2.bak.gz' OVERWRITE;
 backup_id
 #
 SHOW TABLES FROM db1;

=== modified file 'mysql-test/suite/backup/r/backup_concurrent.result'
--- a/mysql-test/suite/backup/r/backup_concurrent.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_concurrent.result	2008-11-17 09:57:51 +0000
@@ -49,7 +49,7 @@ Testing starting backup/restore restore 
 ---------------------------------------------------
 Starting restore
 SET DEBUG_SYNC= 'after_backup_start_restore SIGNAL running WAIT_FOR restore';
-RESTORE FROM 'backup1';
+RESTORE FROM 'backup1' OVERWRITE;
 Waiting for restore to get going
 SET DEBUG_SYNC= 'now WAIT_FOR running';
 Starting backup in another connection.  

=== modified file 'mysql-test/suite/backup/r/backup_db_grants.result'
--- a/mysql-test/suite/backup/r/backup_db_grants.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_db_grants.result	2008-11-17 09:57:51 +0000
@@ -64,7 +64,7 @@ SHOW GRANTS FOR 'bup_user3'@'%';
 Grants for bup_user3@%
 GRANT USAGE ON *.* TO 'bup_user3'@'%'
 Run Restore
-RESTORE FROM 'bup_db_grants.bak';
+RESTORE FROM 'bup_db_grants.bak' OVERWRITE;
 backup_id
 #
 SHOW TABLES FROM bup_db_grants;
@@ -96,7 +96,7 @@ FLUSH PRIVILEGES;
 CREATE USER 'bup_user1'@'%';
 CREATE USER 'bup_user1'@'nosuchhost';
 Run Restore
-RESTORE FROM 'bup_db_grants.bak';
+RESTORE FROM 'bup_db_grants.bak' OVERWRITE;
 backup_id
 #
 SHOW TABLES FROM bup_db_grants;
@@ -166,7 +166,7 @@ EXECUTE stmt3;
 Grants for â@@%
 GRANT USAGE ON *.* TO 'â@'@'%'
 Run restore.
-RESTORE FROM 'bup_db_grants.bak';
+RESTORE FROM 'bup_db_grants.bak' OVERWRITE;
 backup_id
 #
 FLUSH PRIVILEGES;

=== modified file 'mysql-test/suite/backup/r/backup_ddl_blocker.result'
--- a/mysql-test/suite/backup/r/backup_ddl_blocker.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_ddl_blocker.result	2008-11-20 14:07:23 +0000
@@ -112,7 +112,7 @@ 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 FROM "bup_ddl_blocker.bak" OVERWRITE;
 backup_id
 #
 con1: Showing columns that were backed up
@@ -173,13 +173,13 @@ con1: Activate synchronization points fo
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 con1: Restoring database -- will block with lock
-RESTORE FROM "bup_ddl_blocker_orig.bak";
+RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 con6: Wait for con1 to reach its synchronization point.
 SET DEBUG_SYNC= 'now WAIT_FOR bup_blocked';
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "CREATE TABLE bup_ddl_blocker.t1%";
 state	info
@@ -193,7 +193,7 @@ SET DEBUG_SYNC= 'now SIGNAL status_shown
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 con4: Activate synchronization point for DDL.
 SET DEBUG_SYNC= 'before_check_ddl_blocked SIGNAL con4_started
                  WAIT_FOR status_shown2';
@@ -352,7 +352,7 @@ 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 FROM "bup_ddl_blocker.bak" OVERWRITE;
 backup_id
 #
 con1: Showing columns that were backed up
@@ -407,13 +407,13 @@ con1: Activate synchronization points fo
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 con1: Restoring database -- will block with lock
-RESTORE FROM "bup_ddl_blocker_orig.bak";
+RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 con6: Wait for con1 to reach its synchronization point.
 SET DEBUG_SYNC= 'now WAIT_FOR bup_blocked';
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RENAME TABLE bup_ddl_blocker.t1%";
 state	info
@@ -427,7 +427,7 @@ SET DEBUG_SYNC= 'now SIGNAL status_shown
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 con4: Activate synchronization point for DDL.
 SET DEBUG_SYNC= 'before_check_ddl_blocked SIGNAL con4_started
                  WAIT_FOR status_shown2';
@@ -581,7 +581,7 @@ 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 FROM "bup_ddl_blocker.bak" OVERWRITE;
 backup_id
 #
 con1: Showing columns that were backed up
@@ -634,13 +634,13 @@ con1: Activate synchronization points fo
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 con1: Restoring database -- will block with lock
-RESTORE FROM "bup_ddl_blocker_orig.bak";
+RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 con6: Wait for con1 to reach its synchronization point.
 SET DEBUG_SYNC= 'now WAIT_FOR bup_blocked';
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "OPTIMIZE TABLE bup_ddl_blocker.t1%";
 state	info
@@ -654,7 +654,7 @@ SET DEBUG_SYNC= 'now SIGNAL status_shown
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 con4: Activate synchronization point for DDL.
 SET DEBUG_SYNC= 'before_check_ddl_blocked SIGNAL con4_started
                  WAIT_FOR status_shown2';
@@ -806,7 +806,7 @@ 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 FROM "bup_ddl_blocker.bak" OVERWRITE;
 backup_id
 #
 con1: Showing databases that were backed up
@@ -862,13 +862,13 @@ con1: Activate synchronization points fo
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 con1: Restoring database -- will block with lock
-RESTORE FROM "bup_ddl_blocker_orig.bak";
+RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 con6: Wait for con1 to reach its synchronization point.
 SET DEBUG_SYNC= 'now WAIT_FOR bup_blocked';
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "CREATE DATABASE bup_ddl_blocker_1%";
 state	info
@@ -882,7 +882,7 @@ SET DEBUG_SYNC= 'now SIGNAL status_shown
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 con4: Activate synchronization point for DDL.
 SET DEBUG_SYNC= 'before_check_ddl_blocked SIGNAL con4_started
                  WAIT_FOR status_shown2';
@@ -1040,7 +1040,7 @@ 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 FROM "bup_ddl_blocker.bak" OVERWRITE;
 backup_id
 #
 con1: Showing databases that were backed up
@@ -1112,13 +1112,13 @@ con1: Activate synchronization points fo
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 con1: Restoring database -- will block with lock
-RESTORE FROM "bup_ddl_blocker_orig.bak";
+RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 con6: Wait for con1 to reach its synchronization point.
 SET DEBUG_SYNC= 'now WAIT_FOR bup_blocked';
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "ALTER DATABASE bup_ddl_blocker_2%";
 state	info
@@ -1132,7 +1132,7 @@ SET DEBUG_SYNC= 'now SIGNAL status_shown
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 con4: Activate synchronization point for DDL.
 SET DEBUG_SYNC= 'before_check_ddl_blocked SIGNAL con4_started
                  WAIT_FOR status_shown2';
@@ -1335,7 +1335,7 @@ DROP DATABASE bup_ddl_blocker_2;
 DROP DATABASE bup_ddl_blocker_3;
 DROP DATABASE bup_ddl_blocker_4;
 con1: Restoring the database
-RESTORE FROM "bup_ddl_blocker.bak";
+RESTORE FROM "bup_ddl_blocker.bak" OVERWRITE;
 backup_id
 #
 con1: Showing databases that were backed up
@@ -1428,13 +1428,13 @@ con1: Activate synchronization points fo
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 con1: Restoring database -- will block with lock
-RESTORE FROM "bup_ddl_blocker_orig.bak";
+RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 con6: Wait for con1 to reach its synchronization point.
 SET DEBUG_SYNC= 'now WAIT_FOR bup_blocked';
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: before_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "CREATE INDEX 1t1col_b%";
 state	info
@@ -1448,7 +1448,7 @@ SET DEBUG_SYNC= 'now SIGNAL status_shown
 SELECT state, info FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE info LIKE "RESTORE FROM%";
 state	info
-debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak"
+debug sync point: after_block_ddl	RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE
 con4: Activate synchronization point for DDL.
 SET DEBUG_SYNC= 'before_check_ddl_blocked SIGNAL con4_started
                  WAIT_FOR status_shown2';

=== modified file 'mysql-test/suite/backup/r/backup_errors.result'
--- a/mysql-test/suite/backup/r/backup_errors.result	2008-11-05 09:41:15 +0000
+++ b/mysql-test/suite/backup/r/backup_errors.result	2008-11-17 09:57:51 +0000
@@ -135,3 +135,50 @@ SET DEBUG_SYNC= 'reset';
 DROP DATABASE db1;
 
 Done testing for Bug#38624
+
+Testing RESTORE ... OVERWRITE functionality
+See bug#34579
+
+Initialize
+CREATE DATABASE db1;
+USE db1;
+CREATE TABLE table1 (text VARCHAR(20));
+INSERT INTO table1 VALUES ('Inserted before');
+
+Backup database
+BACKUP DATABASE db1 TO 'overwrite.bak';
+backup_id
+#
+
+Insert more data and display
+INSERT INTO table1 VALUES ('Inserted after');
+SELECT * FROM table1;
+text
+Inserted before
+Inserted after
+
+Restore without OVERWRITE flag; will fail
+RESTORE FROM 'overwrite.bak';
+ERROR HY000: Database 'db1' already exists. Use OVERWRITE flag to overwrite.
+
+Restore with OVERWRITE flag; will succeed
+RESTORE FROM 'overwrite.bak' OVERWRITE;
+backup_id
+#
+
+Show that inserted value 2 is not there
+SELECT * FROM table1;
+text
+Inserted before
+DROP DATABASE db1;
+
+Restore after deleting db; will succeed
+RESTORE FROM 'overwrite.bak';
+backup_id
+#
+
+Show that inserted value 2 is not there
+SELECT * FROM table1;
+text
+Inserted before
+DROP DATABASE db1;

=== modified file 'mysql-test/suite/backup/r/backup_fkey.result'
--- a/mysql-test/suite/backup/r/backup_fkey.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_fkey.result	2008-11-17 09:57:51 +0000
@@ -43,10 +43,10 @@ SHOW VARIABLES LIKE 'foreign_key_checks%
 Variable_name	Value
 foreign_key_checks	ON
 Now restore the database.
-RESTORE FROM 'backup_fkey.bak';
+RESTORE FROM 'backup_fkey.bak' OVERWRITE;
 backup_id
 #
-RESTORE FROM 'backup_fkey_orig.bak';
+RESTORE FROM 'backup_fkey_orig.bak' OVERWRITE;
 backup_id
 #
 Show data
@@ -84,7 +84,7 @@ SHOW VARIABLES LIKE 'foreign_key_checks%
 Variable_name	Value
 foreign_key_checks	ON
 Restoring data
-RESTORE FROM 'backup_fkey.bak';
+RESTORE FROM 'backup_fkey.bak' OVERWRITE;
 backup_id
 #
 Verify foreign_key_checks = ON
@@ -97,7 +97,7 @@ SHOW VARIABLES LIKE 'foreign_key_checks%
 Variable_name	Value
 foreign_key_checks	OFF
 Restoring data
-RESTORE FROM 'backup_fkey.bak';
+RESTORE FROM 'backup_fkey.bak' OVERWRITE;
 backup_id
 #
 Verify foreign_key_checks = OFF

=== modified file 'mysql-test/suite/backup/r/backup_lock_myisam.result'
--- a/mysql-test/suite/backup/r/backup_lock_myisam.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_lock_myisam.result	2008-11-17 09:57:51 +0000
@@ -54,7 +54,7 @@ DROP DATABASE db1;
 now start the restore and while the restore is running, fire the trigger
 activate synchronization points for restore.
 SET DEBUG_SYNC= 'restore_in_progress SIGNAL wait_for_restore WAIT_FOR finish';
-RESTORE FROM 'db1.bak';
+RESTORE FROM 'db1.bak' OVERWRITE;;
 From breakpoints:
 Wait for restore to reach its synchronization point.
 SET DEBUG_SYNC= 'now WAIT_FOR wait_for_restore';
@@ -92,7 +92,7 @@ DELETE FROM db2.t2;
 now start the restore and while the restore is running, fire the trigger
 activate synchronization points for restore.
 SET DEBUG_SYNC= 'restore_in_progress SIGNAL wait_for_restore WAIT_FOR finish';
-RESTORE FROM 'db1.bak';
+RESTORE FROM 'db1.bak' OVERWRITE;;
 From breakpoints:
 Wait for restore to reach its synchronization point.
 SET DEBUG_SYNC= 'now WAIT_FOR wait_for_restore';

=== modified file 'mysql-test/suite/backup/r/backup_logs.result'
--- a/mysql-test/suite/backup/r/backup_logs.result	2008-11-07 10:40:48 +0000
+++ b/mysql-test/suite/backup/r/backup_logs.result	2008-11-17 09:57:51 +0000
@@ -137,7 +137,7 @@ SET DEBUG_SYNC= 'after_backup_log_init  
 SET DEBUG_SYNC= 'after_backup_start_restore SIGNAL running WAIT_FOR finish';
 con2: Send restore command.
 con2: Backup id = 501.
-RESTORE FROM 'backup_logs_orig.bak';
+RESTORE FROM 'backup_logs_orig.bak' OVERWRITE;
 con1: Wait for the restore to be started.
 SET DEBUG_SYNC= 'now WAIT_FOR started';
 con1: Display progress
@@ -177,7 +177,7 @@ username	root
 backup_file	#
 backup_file_path	#
 user_comment	
-command	RESTORE FROM 'backup_logs_orig.bak'
+command	RESTORE FROM 'backup_logs_orig.bak' OVERWRITE
 drivers	MyISAM, Snapshot, Default
 SELECT * FROM mysql.backup_progress WHERE backup_id = 501;
 backup_id	object	start_time	stop_time	total_bytes	progress	error_num	notes

=== modified file 'mysql-test/suite/backup/r/backup_logs_output.result'
--- a/mysql-test/suite/backup/r/backup_logs_output.result	2008-11-10 16:49:10 +0000
+++ b/mysql-test/suite/backup/r/backup_logs_output.result	2008-11-17 11:17:59 +0000
@@ -13,7 +13,7 @@ backup_progress_log	ON
 backup_progress_log_file	MYSQLTEST_VARDIR/master-data/progress.txt
 SHOW VARIABLES LIKE 'log_backup_output';
 Variable_name	Value
-log_backup_output	FILE
+log_backup_output	TABLE
 Set the backup log file names to default values.
 SET @@global.backup_history_log_file = DEFAULT;
 SET @@global.backup_progress_log_file = DEFAULT;

=== modified file 'mysql-test/suite/backup/r/backup_logs_purge.result'
--- a/mysql-test/suite/backup/r/backup_logs_purge.result	2008-10-28 14:17:05 +0000
+++ b/mysql-test/suite/backup/r/backup_logs_purge.result	2008-11-17 09:57:51 +0000
@@ -45,19 +45,19 @@ BACKUP DATABASE backup_logs to 'backup4.
 backup_id
 503
 Do restore of database
-RESTORE from 'backup1.bak';
+RESTORE from 'backup1.bak' OVERWRITE;
 backup_id
 504
 Do restore of database
-RESTORE from 'backup2.bak';
+RESTORE from 'backup2.bak' OVERWRITE;
 backup_id
 505
 Do restore of database
-RESTORE from 'backup3.bak';
+RESTORE from 'backup3.bak' OVERWRITE;
 backup_id
 506
 Do restore of database
-RESTORE from 'backup4.bak';
+RESTORE from 'backup4.bak' OVERWRITE;
 backup_id
 507
 Display results from backup logs
@@ -149,20 +149,20 @@ backup_id
 503
 SET SESSION debug="-d";
 Do restore of database
-RESTORE from 'backup1.bak';
+RESTORE from 'backup1.bak' OVERWRITE;
 backup_id
 504
 Do restore of database
-RESTORE from 'backup2.bak';
+RESTORE from 'backup2.bak' OVERWRITE;
 backup_id
 505
 Do restore of database
-RESTORE from 'backup3.bak';
+RESTORE from 'backup3.bak' OVERWRITE;
 backup_id
 506
 SET SESSION debug="+d,set_log_time";
 Do restore of database
-RESTORE from 'backup4.bak';
+RESTORE from 'backup4.bak' OVERWRITE;
 backup_id
 507
 SET SESSION debug="-d";
@@ -286,16 +286,16 @@ progress	0
 error_num	0
 notes	complete
 Now do the same test for restore.
-RESTORE FROM 'backup1.bak';
+RESTORE FROM 'backup1.bak' OVERWRITE;
 backup_id
 #
-RESTORE FROM 'backup2.bak';
+RESTORE FROM 'backup2.bak' OVERWRITE;
 backup_id
 #
-RESTORE FROM 'backup3.bak';
+RESTORE FROM 'backup3.bak' OVERWRITE;
 backup_id
 #
-RESTORE FROM 'backup4.bak';
+RESTORE FROM 'backup4.bak' OVERWRITE;
 backup_id
 #
 SELECT count(*) FROM mysql.backup_history;
@@ -306,7 +306,7 @@ count(*)
 13
 con2: Activate sync points for the backup statement.
 SET DEBUG_SYNC= 'before_restore_done SIGNAL ready WAIT_FOR proceed';
-RESTORE FROM 'backup5.bak';
+RESTORE FROM 'backup5.bak' OVERWRITE;
 con1: Wait for the backup to be ready.
 SET DEBUG_SYNC= 'now WAIT_FOR ready';
 PURGE BACKUP LOGS;
@@ -320,7 +320,7 @@ count(*)
 1
 SELECT backup_id, command FROM mysql.backup_history;
 backup_id	command
-505	RESTORE FROM 'backup5.bak'
+505	RESTORE FROM 'backup5.bak' OVERWRITE
 There should be one row in this table: the backup id from last
 restore (505). We should only see the complete progress 
 statement because all others were deleted while restore was

=== modified file 'mysql-test/suite/backup/r/backup_no_be.result'
--- a/mysql-test/suite/backup/r/backup_no_be.result	2008-10-30 10:41:48 +0000
+++ b/mysql-test/suite/backup/r/backup_no_be.result	2008-11-17 09:57:51 +0000
@@ -32,7 +32,7 @@ WHERE command LIKE 'BACKUP DATABASE db1 
 SELECT drivers FROM mysql.backup_history WHERE backup_id=@id;
 drivers
 Default
-RESTORE FROM 'db1.bak';
+RESTORE FROM 'db1.bak' OVERWRITE;
 backup_id
 #
 SHOW TABLES IN db1;

=== modified file 'mysql-test/suite/backup/r/backup_no_data.result'
--- a/mysql-test/suite/backup/r/backup_no_data.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_no_data.result	2008-11-20 14:07:23 +0000
@@ -15,7 +15,7 @@ Database
 information_schema
 mysql
 test
-RESTORE FROM 'all.bak';
+RESTORE FROM 'all.bak' OVERWRITE;
 backup_id
 #
 SHOW DATABASES;
@@ -38,7 +38,7 @@ mysql
 test
 SHOW TABLES IN empty_db;
 Tables_in_empty_db
-RESTORE FROM 'all.bak';
+RESTORE FROM 'all.bak' OVERWRITE;
 backup_id
 #
 SHOW DATABASES;
@@ -66,7 +66,7 @@ empty_db
 mysql
 other_db
 test
-RESTORE FROM 'empty_db.bak';
+RESTORE FROM 'empty_db.bak' OVERWRITE;
 backup_id
 #
 USE empty_db;

=== modified file 'mysql-test/suite/backup/r/backup_nodata_driver.result'
--- a/mysql-test/suite/backup/r/backup_nodata_driver.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_nodata_driver.result	2008-11-21 15:02:34 +0000
@@ -1,7 +1,10 @@
+INSTALL PLUGIN example SONAME 'ha_example.so';
 DROP DATABASE IF EXISTS bup_nodata;
 DROP DATABASE IF EXISTS bup_data;
-Creating tables
-CREATE DATABASE bup_nodata;
+#
+# Create a database with tables that can work as
+# base tables for MERGE and FEDERATED.
+#
 CREATE DATABASE bup_data;
 CREATE TABLE bup_data.myisam1 (a int, b char(30)) ENGINE=MYISAM;
 CREATE TABLE bup_data.myisam2 (a int, b char(30)) ENGINE=MYISAM;
@@ -14,6 +17,10 @@ CREATE TABLE bup_data.f1 (
 `name` varchar(32) NOT NULL default ''
     )
 DEFAULT CHARSET=latin1;
+#
+# Create a database with tables from no-data engines.
+#
+CREATE DATABASE bup_nodata;
 CREATE TABLE bup_nodata.merge1 (a int, b char(30))
 ENGINE=MERGE UNION=(bup_data.myisam1, bup_data.myisam2, bup_data.myisam3);
 CREATE TABLE bup_nodata.f1 (
@@ -30,7 +37,9 @@ CREATE TABLE bup_nodata.e1 (
 Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
 Vapor_period smallint(4) unsigned DEFAULT '0' NOT NULL
 ) ENGINE=example;
-Inserting data
+#
+# Insert some data.
+#
 INSERT INTO bup_data.myisam1 VALUES (11, 'table 1');
 INSERT INTO bup_data.myisam1 VALUES (12, 'table 1');
 INSERT INTO bup_data.myisam1 VALUES (13, 'table 1');
@@ -45,7 +54,9 @@ INSERT INTO bup_data.f1 (id, name) VALUE
 INSERT INTO bup_data.f1 (id, `group`) VALUES (3, 42);
 INSERT INTO bup_data.f1 (id, `batch`) VALUES (4, 23);
 INSERT INTO bup_data.f1 (id, `qty`) VALUES (5, 1);
-show data
+#
+# Show the data.
+#
 SHOW FULL TABLES FROM bup_data;
 Tables_in_bup_data	Table_type
 f1	BASE TABLE
@@ -80,13 +91,21 @@ SELECT * FROM bup_nodata.b1;
 a	b	c
 SELECT * FROM bup_nodata.e1;
 Period	Vapor_period
+#
+# Backup the bup_data DB, which tables contain data.
+#
 BACKUP DATABASE bup_data TO 'bup_data.bak';
 backup_id
 #
+#
+# Backup the bup_nodata DB, which tables do not contain data.
+#
 BACKUP DATABASE bup_nodata TO 'bup_nodata.bak';
 backup_id
 #
-show data
+#
+# Show the data again. Backup did not modify them.
+#
 SHOW FULL TABLES FROM bup_data;
 Tables_in_bup_data	Table_type
 f1	BASE TABLE
@@ -121,8 +140,15 @@ SELECT * FROM bup_nodata.b1;
 a	b	c
 SELECT * FROM bup_nodata.e1;
 Period	Vapor_period
+#
+# Now drop the bup_data database.
+#
 DROP DATABASE bup_data;
-show data
+#
+# Show that the data have gone.
+# The MERGE and FEDERATED tables have errors since
+# their base tables have been dropped with bup_data.
+#
 SHOW FULL TABLES FROM bup_nodata;
 Tables_in_bup_nodata	Table_type
 b1	BASE TABLE
@@ -130,19 +156,34 @@ e1	BASE TABLE
 f1	BASE TABLE
 merge1	BASE TABLE
 SELECT * FROM bup_nodata.merge1;
-ERROR 42S02: Table 'bup_data.myisam1' doesn't exist
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 SELECT * FROM bup_nodata.f1;
 Got one of the listed errors
 SELECT * FROM bup_nodata.b1;
 a	b	c
 SELECT * FROM bup_nodata.e1;
 Period	Vapor_period
+#
+# Now drop the bup_nodata database too.
+#
 DROP DATABASE bup_nodata;
-Restoring nodata database.
-RESTORE FROM 'bup_nodata.bak';
-backup_id
 #
-show data
+# Now try to restore the bup_nodata database. This fails because
+# restore opens the tables for filling them with data, even when
+# they were empty on backup. 'bup_nodata.bak' does not contain
+# the base tables for the MERGE and FEDERATED tables.
+# NOTE: Since restore fails after restoring the meta data,
+# after creating the tables that is, we have the same
+# situation as before. The tables exist, but the base
+# tables for MERGE and FEDERATED do not exist.
+#
+RESTORE FROM 'bup_nodata.bak' OVERWRITE;
+Got one of the listed errors
+#
+# Show what we have.
+# NOTE: If restore would work as all or nothing,
+# all of the SHOW and SELECT statements in this section would fail.
+#
 SHOW FULL TABLES FROM bup_nodata;
 Tables_in_bup_nodata	Table_type
 b1	BASE TABLE
@@ -150,18 +191,24 @@ e1	BASE TABLE
 f1	BASE TABLE
 merge1	BASE TABLE
 SELECT * FROM bup_nodata.merge1;
-ERROR 42S02: Table 'bup_data.myisam1' doesn't exist
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 SELECT * FROM bup_nodata.f1;
 Got one of the listed errors
 SELECT * FROM bup_nodata.b1;
 a	b	c
 SELECT * FROM bup_nodata.e1;
 Period	Vapor_period
-Restoring data database.
+#
+# Now restore the bup_data database as well.
+#
 RESTORE FROM 'bup_data.bak';
 backup_id
 #
-show data
+#
+# Show that everything is well.
+# NOTE: If restore would work as all or nothing,
+# the bup_nodata tables would not exist here.
+#
 SHOW FULL TABLES FROM bup_data;
 Tables_in_bup_data	Table_type
 f1	BASE TABLE
@@ -196,5 +243,72 @@ SELECT * FROM bup_nodata.b1;
 a	b	c
 SELECT * FROM bup_nodata.e1;
 Period	Vapor_period
+#
+# Now restore the bup_nodata database and see if it is the same
+# as above. Note that this step would not be required here
+# because all bup_nodata tables have no data and were created
+# by the failed restore. Anyway, the correct approach is to do a
+# succeeding restore before assuming that everything exists again.
+#
+RESTORE FROM 'bup_nodata.bak' OVERWRITE;
+backup_id
+#
+#
+# Show that everything is well.
+#
+SHOW FULL TABLES FROM bup_nodata;
+Tables_in_bup_nodata	Table_type
+b1	BASE TABLE
+e1	BASE TABLE
+f1	BASE TABLE
+merge1	BASE TABLE
+SELECT * FROM bup_nodata.merge1;
+a	b
+11	table 1
+12	table 1
+13	table 1
+21	table 2
+22	table 2
+23	table 2
+31	table 3
+32	table 3
+33	table 3
+SELECT * FROM bup_nodata.f1;
+id	group	batch	qty	name
+1	0	0	0	foo
+2	0	0	0	fee
+3	42	0	0	
+4	0	23	0	
+5	0	0	1	
+SELECT * FROM bup_nodata.b1;
+a	b	c
+SELECT * FROM bup_nodata.e1;
+Period	Vapor_period
+#
+# Now drop the bup_data database with the base tables again.
+#
 DROP DATABASE bup_data;
+#
+# Show that the data have gone.
+# The MERGE and FEDERATED tables have errors since
+# their base tables have been dropped with bup_data.
+#
+SHOW FULL TABLES FROM bup_nodata;
+Tables_in_bup_nodata	Table_type
+b1	BASE TABLE
+e1	BASE TABLE
+f1	BASE TABLE
+merge1	BASE TABLE
+SELECT * FROM bup_nodata.merge1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+SELECT * FROM bup_nodata.f1;
+Got one of the listed errors
+SELECT * FROM bup_nodata.b1;
+a	b	c
+SELECT * FROM bup_nodata.e1;
+Period	Vapor_period
+#
+# Cleanup.
+#
 DROP DATABASE bup_nodata;
+UNINSTALL PLUGIN example;

=== modified file 'mysql-test/suite/backup/r/backup_security.result'
--- a/mysql-test/suite/backup/r/backup_security.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_security.result	2008-11-17 09:57:51 +0000
@@ -49,7 +49,7 @@ BACKUP DATABASE backup_test to 'bup_with
 backup_id
 #
 no_rights: Attempting restore. Should succeed
-RESTORE FROM 'bup_with_rights.bak';
+RESTORE FROM 'bup_with_rights.bak' OVERWRITE;
 backup_id
 #
 SELECT * FROM backup_test.t1;
@@ -62,7 +62,7 @@ a
 06 Test #1 - super privilege
 07 Test #1 - super privilege
 default: Do restore to ensure it still works with default test user.
-RESTORE FROM 'backup_test_orig.bak';
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
 backup_id
 #
 SELECT * FROM backup_test.t1;

=== modified file 'mysql-test/suite/backup/r/backup_snapshot.result'
--- a/mysql-test/suite/backup/r/backup_snapshot.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_snapshot.result	2008-11-17 09:57:51 +0000
@@ -60,7 +60,7 @@ backup_id
 con1: Dropping the database
 DROP TABLE bup_snapshot.t1;
 con1: Restoring the database
-RESTORE FROM "bup_snapshot.bak";
+RESTORE FROM "bup_snapshot.bak" OVERWRITE;
 backup_id
 #
 con1: Showing the data (no new data should be here).
@@ -106,7 +106,7 @@ backup_id
 con1: Dropping the database
 DROP TABLE bup_snapshot.t1;
 con1: Restoring the database
-RESTORE FROM "bup_snapshot.bak";
+RESTORE FROM "bup_snapshot.bak" OVERWRITE;
 backup_id
 #
 con1: Showing the data (no new data should be here).

=== modified file 'mysql-test/suite/backup/r/backup_timeout.result'
--- a/mysql-test/suite/backup/r/backup_timeout.result	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_timeout.result	2008-11-19 22:01:28 +0000
@@ -71,3 +71,4 @@ SHOW VARIABLES LIKE 'backup_wait%';
 Variable_name	Value
 backup_wait_timeout	50
 DROP DATABASE bup_ddl_blocker;
+SET DEBUG_SYNC= 'reset';

=== added file 'mysql-test/suite/backup/r/backup_vp_nontx.result'
--- a/mysql-test/suite/backup/r/backup_vp_nontx.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_vp_nontx.result	2008-11-20 09:49:34 +0000
@@ -0,0 +1,115 @@
+SET DEBUG_SYNC= 'RESET';
+DROP DATABASE IF EXISTS bup_vp;
+CREATE DATABASE bup_vp;
+
+Starting Test
+
+con_bup: Creating tables
+CREATE TABLE bup_vp.t1 (col_a CHAR(40)) ENGINE=MEMORY;
+con_bup: Loading data
+con_bup: Scenario a) - commited before backup
+INSERT INTO bup_vp.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("04 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("05 Some data to test");
+
+con_bup: Show the data before we start backup
+SELECT * FROM bup_vp.t1;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+

+Scenario (b): Insert in progress blocks CB and is included in backup
+con_ntx1: Start insert and stop it in the middle of processing
+con_ntx1: Make insert stop in the middle of execution
+SET DEBUG_SYNC= 'after_insert_locked_tables SIGNAL insert_started
+                   WAIT_FOR complete_insert';
+INSERT INTO bup_vp.t1 VALUES ("ntx1: 06 Some data to test");
+
+con_bup: Activate synchronization points for BACKUP.
+SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL sync_complete_insert';
+SET DEBUG_SYNC= 'before_backup_data_lock SIGNAL try_insert
+                 WAIT_FOR insert_blocked';
+SET DEBUG_SYNC= 'after_backup_binlog SIGNAL commit_unblocked
+                 WAIT_FOR finish_bup';
+con_bup: Backing up database -- will block with lock
+BACKUP DATABASE bup_vp TO "bup_vp.bak";
+
+SET DEBUG_SYNC= 'now WAIT_FOR sync_complete_insert';
+Backup has been blocked by ongoing insert
+SET DEBUG_SYNC= 'now SIGNAL complete_insert';
+
+con_ntx1: Reap insert
+Check that record has been inserted; Should be 1 record
+SELECT * FROM bup_vp.t1 WHERE col_a like 'ntx1%';
+col_a
+ntx1: 06 Some data to test
+
+con_ntx2: Wait until backup has set CB, then try to insert
+SET DEBUG_SYNC= 'now WAIT_FOR try_insert';
+SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL sync_insert_blocked';
+INSERT INTO bup_vp.t1 VALUES ("ntx2: Should NOT be in backup");
+
+SET DEBUG_SYNC= 'now WAIT_FOR sync_insert_blocked';
+Insert in ntx2 is blocked and should not be in t1; Should be 0 records
+SELECT * FROM bup_vp.t1 WHERE col_a like 'ntx2%';
+col_a
+
+SET DEBUG_SYNC= 'now SIGNAL insert_blocked';
+
+con_ntx1: Backup has now released CB. Perform insert
+SET DEBUG_SYNC= 'now WAIT_FOR commit_unblocked';
+INSERT INTO bup_vp.t1 VALUES ("ntx1: Should NOT be in backup");
+SET DEBUG_SYNC= 'now SIGNAL finish_bup';
+
+con_ntx1: Reap backup
+backup_id
+#
+
+con_bup: Showing data after updates and backup
+SELECT * FROM bup_vp.t1;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+ntx1: 06 Some data to test
+ntx2: Should NOT be in backup
+ntx1: Should NOT be in backup
+con_bup: Dropping the database
+DROP TABLE bup_vp.t1;
+DROP DATABASE bup_vp;
+con_bup: Restoring the database
+RESTORE FROM "bup_vp.bak";
+backup_id
+#
+
+con_bup: Showing the data after restore
+SELECT * FROM bup_vp.t1;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+ntx1: 06 Some data to test
+
+Verifying results:
+
+T1 should have changes from con_ntx1; Should be 1 record
+SELECT * FROM bup_vp.t1 WHERE col_a like 'ntx1%';
+col_a
+ntx1: 06 Some data to test
+
+T1 should not have the changes from con_ntx2; Should be 0 records
+SELECT * FROM bup_vp.t1 WHERE col_a like 'ntx2%';
+col_a
+
+con_bup: Cleanup
+DROP DATABASE bup_vp;
+SET DEBUG_SYNC= 'RESET';

=== added file 'mysql-test/suite/backup/r/backup_vp_tx.result'
--- a/mysql-test/suite/backup/r/backup_vp_tx.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/r/backup_vp_tx.result	2008-11-20 09:49:34 +0000
@@ -0,0 +1,203 @@
+SET DEBUG_SYNC= 'RESET';
+DROP DATABASE IF EXISTS bup_vp;
+CREATE DATABASE bup_vp;
+
+Starting Test
+
+con_bup: Creating tables
+CREATE TABLE bup_vp.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_vp.t2 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_vp.t3 (col_a CHAR(40)) ENGINE=INNODB;
+
+con_bup: Loading data
+con_bup: Scenario a) - commited before backup
+INSERT INTO bup_vp.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("04 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("05 Some data to test");
+INSERT INTO bup_vp.t2 VALUES ("01 Some data to test");
+INSERT INTO bup_vp.t2 VALUES ("02 Some data to test");
+INSERT INTO bup_vp.t2 VALUES ("03 Some data to test");
+INSERT INTO bup_vp.t2 VALUES ("04 Some data to test");
+INSERT INTO bup_vp.t2 VALUES ("05 Some data to test");
+INSERT INTO bup_vp.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_vp.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_vp.t3 VALUES ("03 Some data to test");
+INSERT INTO bup_vp.t3 VALUES ("04 Some data to test");
+INSERT INTO bup_vp.t3 VALUES ("05 Some data to test");
+
+con_bup: Show the data before we start backup
+SELECT * FROM bup_vp.t1;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+SELECT * FROM bup_vp.t2;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+SELECT * FROM bup_vp.t3;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+
+Scenario d) - commit after VP; tx not included in backup
+con_tx3: Start transaction but do not commit
+BEGIN;
+INSERT INTO bup_vp.t3 VALUES ("tx3: 06 Should NOT be in backup");
+
+Scenario b) - Commit in progress blocks CB; tx is included in backup
+con_tx1: Get a transaction going and stop in the middle of commit
+BEGIN;
+INSERT INTO bup_vp.t1 VALUES ("tx1: 06 Some data to test");
+con_tx1: Make commit stop in the middle of execution
+SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_started
+                       WAIT_FOR complete_commit';
+COMMIT;
+
+Scenario c) - commit blocked by CB; tx not included in backup
+con_tx2: Wait until tx1 has started
+SET DEBUG_SYNC= 'now WAIT_FOR commit_started';
+con_tx2: Start transaction but do not commit
+BEGIN;
+INSERT INTO bup_vp.t2 VALUES ("tx2: 06 Should NOT be in backup");
+
+con_bup: Activate synchronization points for BACKUP.
+SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL sync_complete_commit';
+SET DEBUG_SYNC= 'before_backup_data_lock SIGNAL try_commit 
+                 WAIT_FOR commit_blocked';
+SET DEBUG_SYNC= 'after_backup_binlog SIGNAL commit_unblocked
+                 WAIT_FOR finish_bup';
+con_bup: Backing up database -- will block with lock
+BACKUP DATABASE bup_vp TO "bup_vp.bak";
+
+SET DEBUG_SYNC= 'now WAIT_FOR sync_complete_commit';
+Backup has been blocked by ongoing commit
+Check that con_tx1 has not committed; Should be 0 records
+SELECT * FROM bup_vp.t1 WHERE col_a like 'tx1%';
+col_a
+
+SET DEBUG_SYNC= 'now SIGNAL complete_commit';
+
+con_tx1: Reap commit
+Check that con_tx1 has committed; Should be 1 record
+SELECT * FROM bup_vp.t1 WHERE col_a like 'tx1%';
+col_a
+tx1: 06 Some data to test
+
+
+con_tx2: Commit request will be blocked by CB
+SET DEBUG_SYNC= 'now WAIT_FOR try_commit';
+SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL sync_commit_blocked';
+COMMIT;
+
+SET DEBUG_SYNC= 'now WAIT_FOR sync_commit_blocked';
+Check that con_tx2 has not committed; Should be 0 records
+SELECT * FROM bup_vp.t2 WHERE col_a like 'tx2%';
+col_a
+
+SET DEBUG_SYNC= 'now SIGNAL commit_blocked';
+
+con_bup: Reap commit
+con_tx2: Backup has now released CB.
+Check that con_tx2 has committed; Should be 1 record
+SELECT * FROM bup_vp.t2 WHERE col_a like 'tx2%';
+col_a
+tx2: 06 Should NOT be in backup
+
+
+con_tx3: Backup has now released CB. Commit transaction
+SET DEBUG_SYNC= 'now WAIT_FOR commit_unblocked';
+COMMIT;
+SET DEBUG_SYNC= 'now SIGNAL finish_bup';
+
+con_bup: Reap backup
+backup_id
+#
+
+con_bup: Showing data after updates and backup
+SELECT * FROM bup_vp.t1;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+tx1: 06 Some data to test
+SELECT * FROM bup_vp.t2;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+tx2: 06 Should NOT be in backup
+SELECT * FROM bup_vp.t3;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+tx3: 06 Should NOT be in backup
+con_bup: Dropping the database
+DROP TABLE bup_vp.t1;
+DROP TABLE bup_vp.t2;
+DROP TABLE bup_vp.t3;
+DROP DATABASE bup_vp;
+con_bup: Restoring the database
+RESTORE FROM "bup_vp.bak";
+backup_id
+#
+
+con_bup: Showing the data after restore (tx2 and tx3 should not be there)
+SELECT * FROM bup_vp.t1;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+tx1: 06 Some data to test
+SELECT * FROM bup_vp.t2;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+SELECT * FROM bup_vp.t3;
+col_a
+01 Some data to test
+02 Some data to test
+03 Some data to test
+04 Some data to test
+05 Some data to test
+
+Verifying results:
+
+T1 should have changes from con_tx1; Should be 1 record
+SELECT * FROM bup_vp.t1 WHERE col_a like 'tx1%';
+col_a
+tx1: 06 Some data to test
+
+T2 should not have the changes from con_tx2; Should be 0 records
+SELECT * FROM bup_vp.t2 WHERE col_a like 'tx2%';
+col_a
+
+T3 should not have the changes from con_tx3; Should be 0 records
+SELECT * FROM bup_vp.t3 WHERE col_a like 'tx3%';
+col_a
+
+con_bup: Cleanup
+DROP DATABASE bup_vp;
+SET DEBUG_SYNC= 'RESET';

=== modified file 'mysql-test/suite/backup/t/backup.test'
--- a/mysql-test/suite/backup/t/backup.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup.test	2008-11-17 09:57:51 +0000
@@ -434,7 +434,7 @@ SELECT * FROM bup_delete.me;
 
 --echo do restore
 --replace_column 1 #
-RESTORE FROM 'bup_delete.bak';
+RESTORE FROM 'bup_delete.bak' OVERWRITE;
 
 --echo show the data
 SELECT * FROM bup_delete.me;
@@ -472,7 +472,7 @@ BACKUP DATABASE bup_default TO 'bup_defa
 
 --echo Restore the database.
 --replace_column 1 #
-RESTORE FROM 'bup_default_timestamp.bak';
+RESTORE FROM 'bup_default_timestamp.bak' OVERWRITE;
 
 --echo Show data after restore (timestamp should be same as above).
 SELECT * FROM bup_default.time_t1;

=== modified file 'mysql-test/suite/backup/t/backup_backupdir.test'
--- a/mysql-test/suite/backup/t/backup_backupdir.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_backupdir.test	2008-11-17 09:57:51 +0000
@@ -41,7 +41,7 @@ BACKUP DATABASE bup_backupdir TO 'bup_ba
 
 --echo Perform restore
 --replace_column 1 #
-RESTORE FROM 'bup_backupdir1.bak';
+RESTORE FROM 'bup_backupdir1.bak' OVERWRITE;
 
 --echo Now do the backup and restore by specifying a path.
 
@@ -54,7 +54,7 @@ BACKUP DATABASE bup_backupdir TO '../bup
 
 --echo Perform restore
 --replace_column 1 #
-RESTORE FROM '../bup_backupdir2.bak';
+RESTORE FROM '../bup_backupdir2.bak' OVERWRITE;
 
 --echo Perform backup
 --replace_column 1 #

=== modified file 'mysql-test/suite/backup/t/backup_commit_backup.test'
--- a/mysql-test/suite/backup/t/backup_commit_backup.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_commit_backup.test	2008-11-17 09:57:51 +0000
@@ -216,7 +216,7 @@ SELECT release_lock("sync");
 echo Checking contents of the backup image;
 
 replace_column 1 #;
-RESTORE FROM 'db1.bak';
+RESTORE FROM 'db1.bak' OVERWRITE;
 
 SELECT * FROM db1.t1;
 SELECT * FROM db1.t2;

=== removed file 'mysql-test/suite/backup/t/backup_commit_blocker.test'
--- a/mysql-test/suite/backup/t/backup_commit_blocker.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_commit_blocker.test	1970-01-01 00:00:00 +0000
@@ -1,800 +0,0 @@
-#
-# This test is for the commit blocker
-# The goals of the test should be to ensure the following assumptions for
-# the behaviour of the commit blocker hold true.
-#
-# a) transactions in progress are not committed until after the backup
-# b) transactions that are committing are allowed to commit
-# c) transactions that have not started are allowed to start but do not commit
-# d) non-transaction statements in progress are allowed to finish
-# e) non-transaction statements that have not started are blocked
-#
-# The results of the backup should show (based on statements above):
-#
-# a) Test result for this assumption: Not included in backup
-# b) Test result for this assumption: Included in backup
-# c) Test result for this assumption: Not included in backup
-# d) Test result for this assumption: Included in backup
-# e) Test result for this assumption: Not included in backup
-#
-# Note: the statements above assume statements that change data.
-#
-# The test shall run three sets of data manipulation statements. 
-#
-# 1) transactional statments only
-# 2) non-transactional statements only
-# 3) mix of both transactional and non-transactional statements
-#
-# TODO : Add a native driver to the test when one becomes available
-#
-
---source include/have_innodb.inc
---source include/have_debug_sync.inc
---source include/not_embedded.inc
-
---disable_warnings
-SET DEBUG_SYNC= 'RESET';
-DROP DATABASE IF EXISTS bup_commit_blocker;
---error 0,1
---remove_file $MYSQLTEST_VARDIR/master-data/bup_commit_blocker.bak;
---enable_warnings
-
-CREATE DATABASE bup_commit_blocker;
-
-#
-# Connections used in this test
-#
-# con1 - used to create data, load data, and run the backup 
-# con2 - used for setting up transactions in progress
-# con3 - used for setting up transactions in commit
-# con4 - used for setting up transactions about to start
-# con5 - used to show status
-# con6 - used for setting up non-transactions in progress
-# con7 - used for setting up non-transactions about to start
-#
-
-connect (con1,localhost,root,,);
-connect (con2,localhost,root,,);
-connect (con3,localhost,root,,);
-connect (con4,localhost,root,,);
-connect (con5,localhost,root,,);
-connect (con6,localhost,root,,);
-connect (con7,localhost,root,,);
-
-#
-# Note: Originally we used SELECT ... FROM INFORMATION_SCHEMA.PROCESSLIST; to show status of 
-# the various connections participating in the test. But INFORMATION_SCHEMA.PROCESSLIST implementation
-# proved to be not relaiable. From time to time (nondeterminisrtically) test hanged on these SELECTs.
-# As showing the status is not essential for the test (we test correctness by checking the contents of
-# the created backup image), the selects are commented out now. They can be re-enabled when
-# I_S.PROCESSLIST is in a better shape.
-#
-
-connection con1;
-
-#
-# Test 1 - transactional statements only
-#
-
---echo 
---echo Starting Test 1
---echo 
-
-#
-# Test 1 sequence diagram (not UML)
-#
-#   con1     con2     con3     con4     con5
-#  (setup)    |        |        |        |
-#     |       |        |        |        |
-#     |     BEGIN      |        |        |
-#     |    UPDATE t1   |        |        |
-#     |       |      BEGIN      |        |
-#     |       |     INSERT t2   |        |
-#     |       |     INSERT t2   |        |
-#     |       |        |        |    show status
-#   BACKUP    |        |        |        |
-#     |       |      COMMIT     |        |
-#     |       |        |        |    show status
-#     |       |        |      BEGIN      |
-#     |       |        |        |    show status
-#     |    DELETE t1   |        |        |
-#     |     COMMIT     |        |        |
-#     |       |      <...>      |        |
-#     |       |        |     UPDATE t3   |
-#     |       |        |     COMMIT      |
-#   <...>     |        |        |        |
-# (results)   |        |        |        |
-#
-# Note: The resume of the commands is indicated with <...> and
-#       may occur in any order.
-#
-
-# Create transaction tables and load them with data.
---echo con1: Creating tables
-CREATE TABLE bup_commit_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
-CREATE TABLE bup_commit_blocker.t2 (col_a CHAR(40)) ENGINE=INNODB;
-CREATE TABLE bup_commit_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
-
---echo con1: Loading data
-INSERT INTO bup_commit_blocker.t1 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("05 Some data to test");
-
-INSERT INTO bup_commit_blocker.t2 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("05 Some data to test");
-
-INSERT INTO bup_commit_blocker.t3 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("05 Some data to test");
-
---echo con1: Show that the new data doesn't exist before backup.
-SELECT * FROM bup_commit_blocker.t1;
-SELECT * FROM bup_commit_blocker.t2;
-SELECT * FROM bup_commit_blocker.t3;
-
-connection con2;
-
---echo con2: Get a transaction going and stop in the middle
---echo Assumption (a): TRX in progress is not included in backup
-BEGIN;
-  UPDATE bup_commit_blocker.t1 SET col_a = "con2: CHANGED" WHERE col_a LIKE '01%';
-
-connection con3;
-
---echo con3: Start a transaction and send commit after lock is taken
---echo Assumption (b): TRX in commit is included in backup
-BEGIN;
-  INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 04 Some data to test");
-  INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 05 Some data to test");
-
-connection con1;
-
-#
-# We must start the backup and allow it to gather the metadata first.
-# We stop (with a sync point) the backup after the metadata but before
-# the commit blocker.
-#
---echo con1: Activate synchronization points for BACKUP.
-# Before blocking commits, pause to show processlist state.
-# Before going to wait for the protection against global read lock to
-# disappear, signal about the wait, so that another thread can continue.
-# When COMMIT finishes, it releases the protection against global read lock,
-# which would allow BACKUP to continue while COMMIT also continues and
-# signals "commit_done". It is important that BACKUP does not run in
-# parallel and send another signal without waiting for the commit_done
-# signal to be processed. So BACKUP itself has to wait for that signal
-# after awaking and taking the global read lock. Only then BACKUP
-# can proceed and send a signal telling that it took the global read
-# lock. Unfortunately DEBUG_SYNC does not allow a sync point to emit a
-# signal after a wait_for action. So we need to send the signal in a later
-# sync point. For this test it is not important where this signal is sent,
-# as long as it is sent while BACKUP holds the global read lock.
-# Here we do it "before_backup_unblock_commit", where we have to
-# synchronize anyway.
-SET DEBUG_SYNC= 'before_commit_block SIGNAL bup_commit_block
-                 WAIT_FOR bup_go_read_lock';
-SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL bup_read_lock';
-SET DEBUG_SYNC= 'before_backup_data_lock WAIT_FOR commit_done';
-SET DEBUG_SYNC= 'before_backup_unblock_commit SIGNAL bup_read_locked
-                 WAIT_FOR finish';
---echo con1: Backing up database -- will block with lock
-send BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-
-connection con5;
-
---echo con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_block';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
-connection con3;
-
---echo con3: Activate synchronization points for COMMIT.
-SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_read_locked
-                 WAIT_FOR commit_go_done';
-SET DEBUG_SYNC= 'after_commit SIGNAL commit_done WAIT_FOR finish';
---echo con3: Starting commit -- will block on sync point
-send COMMIT;
-
-connection con5;
-
---echo con5: Wait for COMMIT to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR commit_read_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "COMMIT%";
-
---echo con5: Let BACKUP run until the next sync point.
-SET DEBUG_SYNC= 'now SIGNAL bup_go_read_lock WAIT_FOR bup_read_lock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
---echo con5: Let COMMIT continue until end of statement.
---echo con5: The completed COMMIT implicitly wakes BACKUP.
---echo con5: So wait for BACKUP to reach the next synchronization point.
-SET DEBUG_SYNC= 'now SIGNAL commit_go_done WAIT_FOR bup_read_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "COMMIT%";
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
-connection con4;
-
---echo con4: Activate synchronization point for BEGIN.
-SET DEBUG_SYNC= 'before_begin_trans SIGNAL begin_starting
-                 WAIT_FOR finish';
---echo con4: Starting begin -- will block on sync point
---echo Assumption (c): TRX not started is not included in backup
-send BEGIN;
-
-connection con5;
-
---echo con5: Wait for BEGIN to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR begin_starting';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BEGIN%";
-
---echo con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
-
-# Reconnect to connections and fetch their results.
-
-connection con2;
-
---echo con2: Completing transaction
-  DELETE FROM bup_commit_blocker.t1 WHERE col_a LIKE '02%';
-COMMIT;
-
-connection con3;
-
---echo con3: Fetch COMMIT result
-reap;
-
-connection con4;
-
---echo con4: Fetch BEGIN result and completing transaction
-reap;
-  UPDATE bup_commit_blocker.t3 SET col_a = "con4: 05 CHANGED" WHERE col_a LIKE '05%';
-  UPDATE bup_commit_blocker.t3 SET col_a = "con4: 06 CHANGED" WHERE col_a LIKE '06%';
-COMMIT;
-
-connection con1;
-
---echo con1: Fetch BACKUP result
---replace_column 1 #
-reap;
-
-# Now restore the database and then check to make sure the new rows
-# were not backed up.
-
-# Do selects to show that all changes got applied.
---echo con1: Showing data after updates and backup
-SELECT * FROM bup_commit_blocker.t1;
-SELECT * FROM bup_commit_blocker.t2;
-SELECT * FROM bup_commit_blocker.t3;
-
---echo con1: Dropping the database
-DROP TABLE bup_commit_blocker.t1;
-DROP TABLE bup_commit_blocker.t2;
-DROP TABLE bup_commit_blocker.t3;
-
---echo con1: Restoring the database
---replace_column 1 #
- RESTORE FROM "bup_commit_blocker.bak";
-
---echo con1: Showing the data (no new data should be here).
-SELECT * FROM bup_commit_blocker.t1;
-SELECT * FROM bup_commit_blocker.t2;
-SELECT * FROM bup_commit_blocker.t3;
-
---echo
---echo Verifying test 1 results:
---echo
-
---echo T1 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t1 WHERE col_a like 'con2%';
-
---echo T2 should have the changes after backup - count(*) = 2
-SELECT count(*) FROM bup_commit_blocker.t2 WHERE col_a like 'con3%';
-
---echo T3 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t3 WHERE col_a like 'con4%';
-
---echo con1: Cleanup
-DROP DATABASE bup_commit_blocker;
-
-remove_file $MYSQLTEST_VARDIR/master-data/bup_commit_blocker.bak;
-SET DEBUG_SYNC= 'RESET';
-
-#
-# Test 2 - non-transactional statements only
-#
-
---echo 
---echo Starting Test 2
---echo 
-
-# Ingo: DELETE was disabled before converting the test from
-#       BACKUP_BREAKPOINT to DEBUG_SYNC. I left it disabled
-#       as an attempt to enable it made an infinite loop in
-#       write_table_data() in the loop:
-#    while (sch.prepare_count > 0)
-#    if (sch.step())
-#      goto error;
-#        sch.prepare_count did not change from being 1.
-#        When this is fixed, please remove this comment.
-
-#
-# Test 2 sequence diagram (not UML)
-#
-#   con1     con2     con3     con4     con5     con6       con7
-#  (setup)    |        |        |        |        |          |
-#     |       |        |        |        |        |          |
-#     |       |        |        |        |   #DELETE t4      |
-#     |       |        |        |   #show status  |          |
-#   BACKUP    |        |        |        |        |          |
-#     |       |        |        |    show status  |          |
-#     |       |        |        |        |        |       (results)
-#     |       |        |        |        |        |       UPDATE t5
-#     |       |        |        |    show status  |          |
-#   <...>     |        |        |        |      <...>      <...>
-# (results)   |        |        |        |        |          |
-#
-# Note: The resume of the commands is indicated with <...> and
-#       may occur in any order.
-#
-
-CREATE DATABASE bup_commit_blocker;
-
-# Create a non-transaction table and load it with data.
---echo con1: Creating tables
-#CREATE TABLE bup_commit_blocker.t4 (col_a int) ENGINE=MEMORY;
-CREATE TABLE bup_commit_blocker.t5 (col_a int) ENGINE=MEMORY;
-
---echo con1: Loading data
-#INSERT INTO bup_commit_blocker.t4 VALUES (1), (2), (3), (4), (5);
-INSERT INTO bup_commit_blocker.t5 VALUES (10), (20), (30), (40), (50);
-
---echo con1: Show that the new data doesn't exist before backup.
-#SELECT * FROM bup_commit_blocker.t4;
-SELECT * FROM bup_commit_blocker.t5;
-
-#connection con6;
-#
-#--echo con6: Activate synchronization point for DELETE.
-#SET DEBUG_SYNC= 'at_delete_end SIGNAL del_at_end WAIT_FOR finish';
-#--echo con6: Starting non-trx in progress -- will block with lock
-#--echo Assumption (d): non-TRX in progress is included in backup
-#send DELETE FROM bup_commit_blocker.t4 WHERE col_a <= 2;
-#
-#connection con5;
-#
-#--echo con5: Wait for DELETE to reach its synchronization point.
-#SET DEBUG_SYNC= 'now WAIT_FOR del_at_end';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "DELETE%";
-
-connection con1;
-
---echo con1: Activate synchronization point for BACKUP.
-SET DEBUG_SYNC= 'before_backup_data_unlock SIGNAL bup_data_unlock
-                 WAIT_FOR finish';
---echo con1: Backing up database -- will block with lock
-send BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-
-connection con5;
-
---echo con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_data_unlock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
-connection con7;
-
---echo con7: Show that the statement in progress has executed before backup.
-#SELECT * FROM bup_commit_blocker.t4;
-SELECT * FROM bup_commit_blocker.t5;
-
---echo con7: Activate synchronization point for UPDATE.
-SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL upd_read_lock';
---echo con7: Starting non-trx about to start
---echo Assumption (e): non-TRX not started is not included in backup
-send UPDATE bup_commit_blocker.t5 SET col_a = 333 WHERE col_a = 30;
-
-connection con5;
-
---echo con5: Wait for UPDATE to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR upd_read_lock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "UPDATE%";
-
---echo con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
-
-# Reconnect to con6 and con7 and fetch their results.
-
-#connection con6;
-#
-#--echo con6: Fetch DELETE result
-#reap;
-
-connection con7;
-
---echo con7: Fetch UPDATE result
-reap;
-
-connection con1;
-
---echo con1: Fetch BACKUP result
---replace_column 1 #
-reap;
-
-# Now restore the database and then check to make sure the new rows
-# were not backed up.
-
-# Do selects to show that all changes got applied.
---echo con1: Showing data after updates and backup
-#SELECT * FROM bup_commit_blocker.t4;
-SELECT * FROM bup_commit_blocker.t5;
-
---echo con1: Dropping the database
-#DROP TABLE bup_commit_blocker.t4;
-DROP TABLE bup_commit_blocker.t5;
-
---echo con1: Restoring the database
---replace_column 1 #
- RESTORE FROM "bup_commit_blocker.bak";
-
---echo con1: Showing the data (no new data should be here).
-#SELECT * FROM bup_commit_blocker.t4;
-SELECT * FROM bup_commit_blocker.t5;
-
---echo
---echo Verifying test 2 results:
---echo
-
-#--echo T4 should have the changes after backup - count(*) = 3
-#SELECT count(*) FROM bup_commit_blocker.t4 WHERE col_a > 2;
-
---echo T5 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t5 WHERE col_a = 333;
-
---echo con1: Cleanup
-DROP DATABASE bup_commit_blocker;
-
-remove_file $MYSQLTEST_VARDIR/master-data/bup_commit_blocker.bak;
-SET DEBUG_SYNC= 'RESET';
-
-#
-# Test 3 - mix of both transactional and non-transactional statements
-#
-
---echo 
---echo Starting Test 3
---echo 
-
-#
-# Test 3 sequence diagram (not UML)
-#
-#   con1     con2     con3     con4     con5     con6       con7
-#  (setup)    |        |        |        |        |          |
-#     |       |        |        |        |        |          |
-#     |     BEGIN      |        |        |        |          |
-#     |    UPDATE t1   |        |        |        |          |
-#     |       |      BEGIN      |        |        |          |
-#     |       |     INSERT t2   |        |        |          |
-#     |       |     INSERT t2   |        |        |          |
-#   BACKUP    |        |        |        |        |          |
-#     |       |        |        |        |    #INSERT t4     |
-#     |       |        |        |    show status  |          |
-#     |       |      COMMIT     |        |        |          |
-#     |       |        |        |    show status  |          |
-#     |       |        |      BEGIN      |        |          |
-#     |       |        |        |    show status  |          |
-#     |       |        |        |        |        |      (results)
-#     |       |        |        |        |        |       DELETE t5
-#     |       |        |        |    show status  |          |
-#     |       |        |        |     wake all    |          |
-#     |    DELETE t1   |        |        |        |          |
-#     |     COMMIT     |        |        |        |          |
-#     |       |      <...>      |        |        |          |
-#     |       |        |     UPDATE t3   |        |          |
-#     |       |        |     UPDATE t3   |        |          |
-#     |       |        |     COMMIT      |        |          |
-#   <...>     |        |        |        |      <...>      <...>
-# (results)   |        |        |        |        |          |
-#
-# Note: The resume of the commands is indicated with <...> and
-#       may occur in any order.
-#
-
-CREATE DATABASE bup_commit_blocker;
-
-# Create tables and load them with data.
---echo con1: Creating tables
-CREATE TABLE bup_commit_blocker.t1 (col_a CHAR(40)) ENGINE=INNODB;
-CREATE TABLE bup_commit_blocker.t2 (col_a CHAR(40)) ENGINE=INNODB;
-CREATE TABLE bup_commit_blocker.t3 (col_a CHAR(40)) ENGINE=INNODB;
-#CREATE TABLE bup_commit_blocker.t4 (col_a int) ENGINE=MEMORY;
-CREATE TABLE bup_commit_blocker.t5 (col_a int) ENGINE=MEMORY;
-
---echo con1: Loading data
-INSERT INTO bup_commit_blocker.t1 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t1 VALUES ("05 Some data to test");
-
-INSERT INTO bup_commit_blocker.t2 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t2 VALUES ("05 Some data to test");
-
-INSERT INTO bup_commit_blocker.t3 VALUES ("01 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("02 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("03 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("04 Some data to test");
-INSERT INTO bup_commit_blocker.t3 VALUES ("05 Some data to test");
-
-#INSERT INTO bup_commit_blocker.t4 VALUES (1), (2), (3), (4), (5);
-INSERT INTO bup_commit_blocker.t5 VALUES (10), (20), (30), (40), (50);
-
---echo con1: Show that the new data doesn't exist before backup.
-SELECT * FROM bup_commit_blocker.t1;
-SELECT * FROM bup_commit_blocker.t2;
-SELECT * FROM bup_commit_blocker.t3;
-#SELECT * FROM bup_commit_blocker.t4;
-SELECT * FROM bup_commit_blocker.t5;
-
-connection con2;
-
---echo con2: Get a transaction going and stop in the middle
---echo Assumption (a): TRX in progress is not included in backup
-BEGIN;
-  UPDATE bup_commit_blocker.t1 SET col_a = "con2: CHANGED" WHERE col_a LIKE '01%';
-
-connection con3;
-
---echo con3: Start a transaction and send commit after lock is taken
---echo Assumption (b): TRX in commit is included in backup
-BEGIN;
-  INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 04 Some data to test");
-  INSERT INTO bup_commit_blocker.t2 VALUES ("con3: 05 Some data to test");
-
-connection con1;
-
-#
-# We must start the backup and allow it to gather the metadata first.
-# We stop (with a sync point) the backup after the metadata but before
-# the commit blocker.
-#
---echo con1: Activate synchronization points for BACKUP.
-# Before blocking commits, pause to show processlist state.
-# Before going to wait for the protection against global read lock to
-# disappear, signal about the wait, so that another thread can continue.
-# When COMMIT finishes, it releases the protection against global read lock,
-# which would allow BACKUP to continue while COMMIT also continues and
-# signals "commit_done". It is important that BACKUP does not run in
-# parallel and send another signal without waiting for the commit_done
-# signal to be processed. So BACKUP itself has to wait for that signal
-# after awaking and taking the global read lock. Only then BACKUP
-# can proceed and send a signal telling that it took the global read
-# lock. Unfortunately DEBUG_SYNC does not allow a sync point to emit a
-# signal after a wait_for action. So we need to send the signal in a later
-# sync point. For this test it is not important where this signal is sent,
-# as long as it is sent while BACKUP holds the global read lock.
-# Here we do it "before_backup_unblock_commit", where we have to
-# synchronize anyway.
-SET DEBUG_SYNC= 'before_commit_block SIGNAL bup_commit_block
-                 WAIT_FOR bup_go_read_lock';
-SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL bup_read_lock';
-SET DEBUG_SYNC= 'before_backup_data_lock WAIT_FOR commit_done';
-SET DEBUG_SYNC= 'before_backup_unblock_commit SIGNAL bup_read_locked
-                 WAIT_FOR finish';
---echo con1: Backing up database -- will block with lock
-send BACKUP DATABASE bup_commit_blocker TO "bup_commit_blocker.bak";
-
-#connection con6;
-#
-#--echo con6: Activate synchronization point for INSERT.
-#SET DEBUG_SYNC= 'after_insert_locked_tables SIGNAL insert_table_locked
-#                 WAIT_FOR finish';
-#--echo con6: Starting non-trx in progress -- will block
-#--echo Assumption (d): non-TRX in progress is included in backup
-#send INSERT INTO bup_commit_blocker.t4 VALUES (31), (32), (33);
-
-connection con5;
-
---echo con5: Wait for BACKUP to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR bup_commit_block';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
-#--echo con5: Wait for INSERT to reach its synchronization point.
-#SET DEBUG_SYNC= 'now WAIT_FOR insert_table_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
-connection con3;
-
---echo con3: Activate synchronization points for COMMIT.
-SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_read_locked
-                 WAIT_FOR commit_go_done';
-SET DEBUG_SYNC= 'after_commit SIGNAL commit_done WAIT_FOR finish';
---echo con3: Starting commit -- will block on sync point
-send COMMIT;
-
-connection con5;
-
---echo con5: Wait for COMMIT to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR commit_read_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "COMMIT%";
-
---echo con5: Let BACKUP run until the next sync point.
-SET DEBUG_SYNC= 'now SIGNAL bup_go_read_lock WAIT_FOR bup_read_lock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
---echo con5: Let COMMIT continue until the sync point at its end.
---echo con5: The completed COMMIT implicitly wakes BACKUP.
---echo con5: So wait for BACKUP to reach the next synchronization point.
-SET DEBUG_SYNC= 'now SIGNAL commit_go_done WAIT_FOR bup_read_locked';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "COMMIT%";
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BACKUP DATABASE%";
-
-connection con4;
-
---echo con4: Activate synchronization point for BEGIN.
-SET DEBUG_SYNC= 'before_begin_trans SIGNAL begin_starting
-                 WAIT_FOR finish';
---echo con4: Starting begin -- will block with lock
---echo Assumption (c): TRX not started is not included in backup
-send BEGIN;
-
-connection con5;
-
---echo con5: Wait for BEGIN to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR begin_starting';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "BEGIN%";
-
-connection con7;
-
---echo con7: Show that the statement in progress has executed before backup.
-#SELECT * FROM bup_commit_blocker.t4;
-SELECT * FROM bup_commit_blocker.t5;
-
---echo con7: Activate synchronization point for DELETE.
-SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL del_read_lock';
---echo con7: Starting non-trx about to start -- will block with lock
---echo Assumption (e): non-TRX not started is not included in backup
-send DELETE FROM bup_commit_blocker.t5 WHERE col_a = 50;
-
-connection con5;
-
---echo con5: Wait for DELETE to reach its synchronization point.
-SET DEBUG_SYNC= 'now WAIT_FOR del_read_lock';
-#SELECT state, info FROM
-#INFORMATION_SCHEMA.PROCESSLIST
-#WHERE info LIKE "DELETE%";
-
---echo con5: Sending finish signal to wake them all.
-SET DEBUG_SYNC= 'now SIGNAL finish';
-
-# Reconnect to con2, con3, con4, con6, and con7 and fetch their results.
-
-connection con2;
-
---echo con2: Completing transaction
-  DELETE FROM bup_commit_blocker.t2 WHERE col_a LIKE '02%';
-COMMIT;
-
-connection con3;
-
---echo con3: Fetch COMMIT result
-reap;
-
-connection con4;
-
---echo con4: Fetch BEGIN result and completing transaction
-reap;
-  UPDATE bup_commit_blocker.t3 SET col_a = "con4: 05 CHANGED" WHERE col_a LIKE '05%';
-  UPDATE bup_commit_blocker.t3 SET col_a = "con4: 06 CHANGED" WHERE col_a LIKE '06%';
-COMMIT;
-
-connection con6;
-
-#--echo con6: Fetch INSERT result
-#reap;
-
-connection con7;
-
---echo con7: Fetch DELETE result
-reap;
-
-connection con1;
-
---echo con1: Fetch BACKUP result
---replace_column 1 #
-reap;
-
-# Now restore the database and then check to make sure the new rows
-# were not backed up.
-
-# Do selects to show that all changes got applied.
---echo con1: Showing data after updates and backup
-SELECT * FROM bup_commit_blocker.t1;
-SELECT * FROM bup_commit_blocker.t2;
-SELECT * FROM bup_commit_blocker.t3;
-#SELECT * FROM bup_commit_blocker.t4;
-SELECT * FROM bup_commit_blocker.t5;
-
---echo con1: Dropping the database
-DROP TABLE bup_commit_blocker.t1;
-DROP TABLE bup_commit_blocker.t2;
-DROP TABLE bup_commit_blocker.t3;
-#DROP TABLE bup_commit_blocker.t4;
-DROP TABLE bup_commit_blocker.t5;
-
---echo con1: Restoring the database
---replace_column 1 #
-RESTORE FROM "bup_commit_blocker.bak";
-
---echo con1: Showing the data (no new data should be here).
-SELECT * FROM bup_commit_blocker.t1;
-SELECT * FROM bup_commit_blocker.t2;
-SELECT * FROM bup_commit_blocker.t3;
-#SELECT * FROM bup_commit_blocker.t4;
-SELECT * FROM bup_commit_blocker.t5;
-
---echo
---echo Verifying test 3 results:
---echo
-
---echo T1 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t1 WHERE col_a like 'con2%';
-
---echo T2 should have the changes after backup - count(*) = 2
-SELECT count(*) FROM bup_commit_blocker.t2 WHERE col_a like 'con3%';
-
---echo T3 should not have the changes after backup - count(*) = 0
-SELECT count(*) FROM bup_commit_blocker.t3 WHERE col_a like 'con4%';
-
-#--echo T4 should have the changes after backup - count(*) = 3
-#SELECT count(*) FROM bup_commit_blocker.t4 WHERE col_a > 30;
-
---echo T5 should not have the changes after backup - count(*) = 1
-SELECT count(*) FROM bup_commit_blocker.t5 WHERE col_a >= 50;
-
---echo con1: Cleanup
-DROP DATABASE bup_commit_blocker;
-
-remove_file $MYSQLTEST_VARDIR/master-data/bup_commit_blocker.bak;
-SET DEBUG_SYNC= 'RESET';
-

=== modified file 'mysql-test/suite/backup/t/backup_commit_restore.test'
--- a/mysql-test/suite/backup/t/backup_commit_restore.test	2008-10-23 08:13:54 +0000
+++ b/mysql-test/suite/backup/t/backup_commit_restore.test	2008-11-17 09:57:51 +0000
@@ -20,7 +20,7 @@ replace_column 1 #;
 BACKUP DATABASE commit_test TO '81';
 
 replace_column 1 #;
-RESTORE FROM '81';
+RESTORE FROM '81' OVERWRITE;
 
 SELECT * FROM t1;
 ROLLBACK;
@@ -37,7 +37,7 @@ replace_column 1 #;
 BACKUP DATABASE commit_test TO '82';
 
 replace_column 1 #;
-RESTORE FROM '82';
+RESTORE FROM '82' OVERWRITE;
 
 SELECT * FROM t1;
 SELECT * FROM t2;
@@ -58,7 +58,7 @@ replace_column 1 #;
 BACKUP DATABASE commit_test TO '83';
 
 replace_column 1 #;
-RESTORE FROM '83';
+RESTORE FROM '83' OVERWRITE;
 
 SELECT * FROM t1;
 SELECT * FROM t2;
@@ -81,7 +81,7 @@ replace_column 1 #;
 BACKUP DATABASE commit_test TO '84';
 
 replace_column 1 #;
-RESTORE FROM '84';
+RESTORE FROM '84' OVERWRITE;
 
 SELECT * FROM t1;
 SELECT * FROM t2;
@@ -106,7 +106,7 @@ replace_column 1 #;
 BACKUP DATABASE commit_test TO '85';
 
 replace_column 1 #;
-RESTORE FROM '85';
+RESTORE FROM '85' OVERWRITE;
 
 SELECT * FROM t1;
 SELECT * FROM t2;
@@ -133,7 +133,7 @@ BACKUP DATABASE commit_test TO '86';
 
 SET @@autocommit=0;
 replace_column 1 #;
-RESTORE FROM '86';
+RESTORE FROM '86' OVERWRITE;
 
 #Test of scenario from BUG#34205
 DROP TABLE t5;
@@ -162,7 +162,7 @@ BACKUP DATABASE commit_test TO '87';
 
 SET @@autocommit=1;
 replace_column 1 #;
-RESTORE FROM '87';
+RESTORE FROM '87' OVERWRITE;
 
 SELECT * FROM t1;
 SELECT * FROM t2;

=== modified file 'mysql-test/suite/backup/t/backup_compression.test'
--- a/mysql-test/suite/backup/t/backup_compression.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_compression.test	2008-11-17 09:57:51 +0000
@@ -12,11 +12,11 @@ replace_column 1 #;
 BACKUP DATABASE db1 TO 'db2.bak.gz' WITH COMPRESSION COMPRESSION_ALGORITHM=gzip;
 
 replace_column 1 #;
-RESTORE FROM 'db1.bak.gz';
+RESTORE FROM 'db1.bak.gz' OVERWRITE;
 SHOW TABLES FROM db1;
 
 replace_column 1 #;
-RESTORE FROM 'db2.bak.gz';
+RESTORE FROM 'db2.bak.gz' OVERWRITE;
 SHOW TABLES FROM db1;
 
 DROP DATABASE db1;

=== modified file 'mysql-test/suite/backup/t/backup_concurrent.test'
--- a/mysql-test/suite/backup/t/backup_concurrent.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_concurrent.test	2008-11-17 09:57:51 +0000
@@ -79,7 +79,7 @@ reap;
 --echo ---------------------------------------------------
 --echo Starting restore
 SET DEBUG_SYNC= 'after_backup_start_restore SIGNAL running WAIT_FOR restore';
-send RESTORE FROM 'backup1';
+send RESTORE FROM 'backup1' OVERWRITE;
 
 connection default;
 --echo Waiting for restore to get going

=== modified file 'mysql-test/suite/backup/t/backup_db_grants.test'
--- a/mysql-test/suite/backup/t/backup_db_grants.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_db_grants.test	2008-11-17 09:57:51 +0000
@@ -63,7 +63,7 @@ SHOW GRANTS FOR 'bup_user3'@'%';
 
 --echo Run Restore
 --replace_column 1 #
-RESTORE FROM 'bup_db_grants.bak';
+RESTORE FROM 'bup_db_grants.bak' OVERWRITE;
 
 SHOW TABLES FROM bup_db_grants;
 
@@ -90,7 +90,7 @@ CREATE USER 'bup_user1'@'nosuchhost';
 
 --echo Run Restore
 --replace_column 1 #
-RESTORE FROM 'bup_db_grants.bak';
+RESTORE FROM 'bup_db_grants.bak' OVERWRITE;
 
 SHOW TABLES FROM bup_db_grants;
 
@@ -178,7 +178,7 @@ EXECUTE stmt3;
 
 --echo Run restore.
 --replace_column 1 #
-RESTORE FROM 'bup_db_grants.bak';
+RESTORE FROM 'bup_db_grants.bak' OVERWRITE;
 
 FLUSH PRIVILEGES;
 

=== modified file 'mysql-test/suite/backup/t/backup_ddl_blocker.test'
--- a/mysql-test/suite/backup/t/backup_ddl_blocker.test	2008-10-24 08:25:48 +0000
+++ b/mysql-test/suite/backup/t/backup_ddl_blocker.test	2008-11-20 14:07:23 +0000
@@ -243,7 +243,7 @@ DROP TABLE bup_ddl_blocker.t1, bup_ddl_b
 
 --echo con1: Restoring the database
 --replace_column 1 #
-RESTORE FROM "bup_ddl_blocker.bak";
+RESTORE FROM "bup_ddl_blocker.bak" OVERWRITE;
 
 --echo con1: Showing columns that were backed up
 
@@ -297,7 +297,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR con3_start
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 --echo con1: Restoring database -- will block with lock
-send RESTORE FROM "bup_ddl_blocker_orig.bak";
+send RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 
 connection con6;
 
@@ -514,7 +514,7 @@ DROP TABLE bup_ddl_blocker.t01, bup_ddl_
 
 --echo con1: Restoring the database
 --replace_column 1 #
-RESTORE FROM "bup_ddl_blocker.bak";
+RESTORE FROM "bup_ddl_blocker.bak" OVERWRITE;
 
 --echo con1: Showing columns that were backed up
 --echo con1: Table t01 should be in restore
@@ -564,7 +564,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR con3_start
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 --echo con1: Restoring database -- will block with lock
-send RESTORE FROM "bup_ddl_blocker_orig.bak";
+send RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 
 connection con6;
 
@@ -774,7 +774,7 @@ DROP TABLE bup_ddl_blocker.t1, bup_ddl_b
 
 --echo con1: Restoring the database
 --replace_column 1 #
-RESTORE FROM "bup_ddl_blocker.bak";
+RESTORE FROM "bup_ddl_blocker.bak" OVERWRITE;
 
 --echo con1: Showing columns that were backed up
 --echo con1: Table t2 should not be in restore
@@ -823,7 +823,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR con3_start
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 --echo con1: Restoring database -- will block with lock
-send RESTORE FROM "bup_ddl_blocker_orig.bak";
+send RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 
 connection con6;
 
@@ -1061,7 +1061,7 @@ DROP DATABASE bup_ddl_blocker_3;
 --echo con1: Restoring the database
 --replace_column 1 #
 --disable_warnings
-RESTORE FROM "bup_ddl_blocker.bak";
+RESTORE FROM "bup_ddl_blocker.bak" OVERWRITE;
 --enable_warnings
 
 --echo con1: Showing databases that were backed up
@@ -1137,7 +1137,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR con3_start
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 --echo con1: Restoring database -- will block with lock
-send RESTORE FROM "bup_ddl_blocker_orig.bak";
+send RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 
 connection con6;
 
@@ -1381,7 +1381,7 @@ DROP DATABASE bup_ddl_blocker_4;
 
 --echo con1: Restoring the database
 --replace_column 1 #
-RESTORE FROM "bup_ddl_blocker.bak";
+RESTORE FROM "bup_ddl_blocker.bak" OVERWRITE;
 
 --echo con1: Showing databases that were backed up
 --echo con1: bup_ddl_blocker_1 has been renamed and
@@ -1465,7 +1465,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR con3_start
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 --echo con1: Restoring database -- will block with lock
-send RESTORE FROM "bup_ddl_blocker_orig.bak";
+send RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 
 connection con6;
 
@@ -1732,7 +1732,7 @@ DROP DATABASE bup_ddl_blocker_4;
 --echo con1: Restoring the database
 --replace_column 1 #
 --disable_warnings
-RESTORE FROM "bup_ddl_blocker.bak";
+RESTORE FROM "bup_ddl_blocker.bak" OVERWRITE;
 --enable_warnings
 
 --echo con1: Showing databases that were backed up
@@ -1829,7 +1829,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR con3_start
 SET DEBUG_SYNC= 'before_block_ddl SIGNAL bup_blocked WAIT_FOR status_shown';
 SET DEBUG_SYNC= 'after_block_ddl SIGNAL bup_started WAIT_FOR status_shown2';
 --echo con1: Restoring database -- will block with lock
-send RESTORE FROM "bup_ddl_blocker_orig.bak";
+send RESTORE FROM "bup_ddl_blocker_orig.bak" OVERWRITE;
 
 connection con6;
 

=== modified file 'mysql-test/suite/backup/t/backup_errors.test'
--- a/mysql-test/suite/backup/t/backup_errors.test	2008-11-05 09:41:15 +0000
+++ b/mysql-test/suite/backup/t/backup_errors.test	2008-11-17 09:57:51 +0000
@@ -294,3 +294,54 @@ DROP DATABASE db1;
 
 --echo
 --echo Done testing for Bug#38624
+
+
+--echo 
+--echo Testing RESTORE ... OVERWRITE functionality
+--echo See bug#34579
+--echo
+
+--source include/not_embedded.inc
+
+--echo Initialize
+CREATE DATABASE db1;
+USE db1;
+CREATE TABLE table1 (text VARCHAR(20));
+INSERT INTO table1 VALUES ('Inserted before');
+
+--echo 
+--echo Backup database
+--replace_column 1 #
+BACKUP DATABASE db1 TO 'overwrite.bak';
+
+--echo 
+--echo Insert more data and display
+INSERT INTO table1 VALUES ('Inserted after');
+SELECT * FROM table1;
+
+--echo 
+--echo Restore without OVERWRITE flag; will fail
+--error ER_RESTORE_DB_EXISTS
+RESTORE FROM 'overwrite.bak';
+
+--echo 
+--echo Restore with OVERWRITE flag; will succeed
+--replace_column 1 #
+RESTORE FROM 'overwrite.bak' OVERWRITE;
+
+--echo 
+--echo Show that inserted value 2 is not there
+SELECT * FROM table1;
+
+DROP DATABASE db1;
+
+--echo 
+--echo Restore after deleting db; will succeed
+--replace_column 1 #
+RESTORE FROM 'overwrite.bak';
+
+--echo 
+--echo Show that inserted value 2 is not there
+SELECT * FROM table1;
+
+DROP DATABASE db1;

=== modified file 'mysql-test/suite/backup/t/backup_fkey.test'
--- a/mysql-test/suite/backup/t/backup_fkey.test	2008-10-24 08:25:48 +0000
+++ b/mysql-test/suite/backup/t/backup_fkey.test	2008-11-17 09:57:51 +0000
@@ -79,12 +79,12 @@ SHOW VARIABLES LIKE 'foreign_key_checks%
 # Restore the database and ensure there are no errors.
 --echo Now restore the database.
 --replace_column 1 #
-RESTORE FROM 'backup_fkey.bak';
+RESTORE FROM 'backup_fkey.bak' OVERWRITE;
 
 # Now restore the original files to show there are no problems
 # restoring valid fkey relationships.
 --replace_column 1 #
-RESTORE FROM 'backup_fkey_orig.bak';
+RESTORE FROM 'backup_fkey_orig.bak' OVERWRITE;
 
 --echo Show data
 SELECT * FROM backup_fkey.parent;
@@ -120,7 +120,7 @@ SHOW VARIABLES LIKE 'foreign_key_checks%
 
 --echo Restoring data
 --replace_column 1 #
-RESTORE FROM 'backup_fkey.bak';
+RESTORE FROM 'backup_fkey.bak' OVERWRITE;
 
 --echo Verify foreign_key_checks = ON
 SHOW VARIABLES LIKE 'foreign_key_checks%';
@@ -131,7 +131,7 @@ SHOW VARIABLES LIKE 'foreign_key_checks%
 
 --echo Restoring data
 --replace_column 1 #
-RESTORE FROM 'backup_fkey.bak';
+RESTORE FROM 'backup_fkey.bak' OVERWRITE;
 
 --echo Verify foreign_key_checks = OFF
 SHOW VARIABLES LIKE 'foreign_key_checks%';

=== modified file 'mysql-test/suite/backup/t/backup_lock_myisam.test'
--- a/mysql-test/suite/backup/t/backup_lock_myisam.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_lock_myisam.test	2008-11-17 09:57:51 +0000
@@ -98,7 +98,7 @@ DROP DATABASE db1;
 --echo now start the restore and while the restore is running, fire the trigger
 --echo activate synchronization points for restore.
 SET DEBUG_SYNC= 'restore_in_progress SIGNAL wait_for_restore WAIT_FOR finish';
---send RESTORE FROM 'db1.bak'
+--send RESTORE FROM 'db1.bak' OVERWRITE;
 
 --echo From breakpoints:
 --connection breakpoints
@@ -147,7 +147,7 @@ DELETE FROM db2.t2;
 --echo now start the restore and while the restore is running, fire the trigger
 --echo activate synchronization points for restore.
 SET DEBUG_SYNC= 'restore_in_progress SIGNAL wait_for_restore WAIT_FOR finish';
---send RESTORE FROM 'db1.bak'
+--send RESTORE FROM 'db1.bak' OVERWRITE;
 
 --echo From breakpoints:
 --connection breakpoints

=== modified file 'mysql-test/suite/backup/t/backup_logs.test'
--- a/mysql-test/suite/backup/t/backup_logs.test	2008-11-07 10:40:48 +0000
+++ b/mysql-test/suite/backup/t/backup_logs.test	2008-11-17 09:57:51 +0000
@@ -154,7 +154,7 @@ SET DEBUG_SYNC= 'after_backup_start_rest
 
 --echo con2: Send restore command.
 --echo con2: Backup id = 501.
-send RESTORE FROM 'backup_logs_orig.bak';
+send RESTORE FROM 'backup_logs_orig.bak' OVERWRITE;
 
 connection con1;
 

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

=== modified file 'mysql-test/suite/backup/t/backup_logs_purge.test'
--- a/mysql-test/suite/backup/t/backup_logs_purge.test	2008-10-28 14:17:05 +0000
+++ b/mysql-test/suite/backup/t/backup_logs_purge.test	2008-11-17 09:57:51 +0000
@@ -74,16 +74,16 @@ BACKUP DATABASE backup_logs to 'backup3.
 BACKUP DATABASE backup_logs to 'backup4.bak';
 
 --echo Do restore of database
-RESTORE from 'backup1.bak';
+RESTORE from 'backup1.bak' OVERWRITE;
 
 --echo Do restore of database
-RESTORE from 'backup2.bak';
+RESTORE from 'backup2.bak' OVERWRITE;
 
 --echo Do restore of database
-RESTORE from 'backup3.bak';
+RESTORE from 'backup3.bak' OVERWRITE;
 
 --echo Do restore of database
-RESTORE from 'backup4.bak';
+RESTORE from 'backup4.bak' OVERWRITE;
 
 --file_exists $MYSQLTEST_VARDIR/master-data/backup1.bak
 --file_exists $MYSQLTEST_VARDIR/master-data/backup2.bak
@@ -148,18 +148,18 @@ BACKUP DATABASE backup_logs to 'backup4.
 SET SESSION debug="-d";
 
 --echo Do restore of database
-RESTORE from 'backup1.bak';
+RESTORE from 'backup1.bak' OVERWRITE;
 
 --echo Do restore of database
-RESTORE from 'backup2.bak';
+RESTORE from 'backup2.bak' OVERWRITE;
 
 --echo Do restore of database
-RESTORE from 'backup3.bak';
+RESTORE from 'backup3.bak' OVERWRITE;
 
 SET SESSION debug="+d,set_log_time";
 
 --echo Do restore of database
-RESTORE from 'backup4.bak';
+RESTORE from 'backup4.bak' OVERWRITE;
 
 SET SESSION debug="-d";
 
@@ -310,13 +310,13 @@ SELECT count(*) FROM mysql.backup_progre
 --echo Now do the same test for restore.
 
 --replace_column 1 #
-RESTORE FROM 'backup1.bak';
+RESTORE FROM 'backup1.bak' OVERWRITE;
 --replace_column 1 #
-RESTORE FROM 'backup2.bak';
+RESTORE FROM 'backup2.bak' OVERWRITE;
 --replace_column 1 #
-RESTORE FROM 'backup3.bak';
+RESTORE FROM 'backup3.bak' OVERWRITE;
 --replace_column 1 #
-RESTORE FROM 'backup4.bak';
+RESTORE FROM 'backup4.bak' OVERWRITE;
 
 SELECT count(*) FROM mysql.backup_history;
 SELECT count(*) FROM mysql.backup_progress;
@@ -329,7 +329,7 @@ connection con2;
 #
 --echo con2: Activate sync points for the backup statement.
 SET DEBUG_SYNC= 'before_restore_done SIGNAL ready WAIT_FOR proceed';
-SEND RESTORE FROM 'backup5.bak';
+SEND RESTORE FROM 'backup5.bak' OVERWRITE;
 
 connection con1;
 

=== modified file 'mysql-test/suite/backup/t/backup_no_be.test'
--- a/mysql-test/suite/backup/t/backup_no_be.test	2008-10-30 10:41:48 +0000
+++ b/mysql-test/suite/backup/t/backup_no_be.test	2008-11-17 09:57:51 +0000
@@ -84,7 +84,7 @@ SELECT drivers FROM mysql.backup_history
 # check that we can restore from the created image.
 
 --replace_column 1 #
-RESTORE FROM 'db1.bak';
+RESTORE FROM 'db1.bak' OVERWRITE;
 SHOW TABLES IN db1;
 
 

=== modified file 'mysql-test/suite/backup/t/backup_no_data.test'
--- a/mysql-test/suite/backup/t/backup_no_data.test	2008-10-09 09:55:08 +0000
+++ b/mysql-test/suite/backup/t/backup_no_data.test	2008-11-20 14:07:23 +0000
@@ -26,7 +26,7 @@ DROP DATABASE other_db;
 SHOW DATABASES;
 
 --replace_column 1 #
-RESTORE FROM 'all.bak';
+RESTORE FROM 'all.bak' OVERWRITE;
 
 SHOW DATABASES;
 
@@ -40,7 +40,7 @@ SHOW DATABASES;
 SHOW TABLES IN empty_db;
 
 --replace_column 1 #
-RESTORE FROM 'all.bak';
+RESTORE FROM 'all.bak' OVERWRITE;
 
 SHOW DATABASES;
 SHOW TABLES IN empty_db;
@@ -64,7 +64,7 @@ BACKUP DATABASE empty_db TO 'empty_db.ba
 SHOW DATABASES;
 
 --replace_column 1 #
-RESTORE FROM 'empty_db.bak';
+RESTORE FROM 'empty_db.bak' OVERWRITE;
 
 USE empty_db;
 

=== added file 'mysql-test/suite/backup/t/backup_nodata_driver-master.opt'
--- a/mysql-test/suite/backup/t/backup_nodata_driver-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_nodata_driver-master.opt	2008-11-21 15:02:34 +0000
@@ -0,0 +1 @@
+$EXAMPLE_PLUGIN_OPT

=== modified file 'mysql-test/suite/backup/t/backup_nodata_driver.test'
--- a/mysql-test/suite/backup/t/backup_nodata_driver.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_nodata_driver.test	2008-11-21 15:02:34 +0000
@@ -1,5 +1,9 @@
 #
 # This test tests the backup using no data engines.
+# These are engines which tables don't contain data.
+# This is obvious for BLACKHOLE and EXAMPLE.
+# Other engines behave like placeholders for tables of other
+# engines and don't have data themselves. Examples are MERGE and FEDERATED.
 # It was made a separate test due to the possibility that some
 # of the engines used may not be available on all platforms or
 # builds.
@@ -10,18 +14,26 @@
 #
 --source include/not_embedded.inc
 --source include/have_federated_db.inc
---source include/have_exampledb.inc
+# MERGE is always available --source include/have_merge.inc
 --source include/have_blackhole.inc
+#
+# Example engine must be loaded as plugin.
+# Currently this does not work on Windows yet.

+#
+--source include/not_windows.inc
+--source include/have_example_plugin.inc
+INSTALL PLUGIN example SONAME 'ha_example.so';
+--source include/have_exampledb.inc
 
 --disable_warnings
 DROP DATABASE IF EXISTS bup_nodata;
 DROP DATABASE IF EXISTS bup_data;
 --enable_warnings
 
-# Create data
---echo Creating tables
-CREATE DATABASE bup_nodata;
-
+--echo #
+--echo # Create a database with tables that can work as
+--echo # base tables for MERGE and FEDERATED.
+--echo #
 CREATE DATABASE bup_data;
 
 CREATE TABLE bup_data.myisam1 (a int, b char(30)) ENGINE=MYISAM;
@@ -39,6 +51,11 @@ CREATE TABLE bup_data.f1 (
     )
   DEFAULT CHARSET=latin1;
 
+--echo #
+--echo # Create a database with tables from no-data engines.
+--echo #
+CREATE DATABASE bup_nodata;
+
 CREATE TABLE bup_nodata.merge1 (a int, b char(30))
   ENGINE=MERGE UNION=(bup_data.myisam1, bup_data.myisam2, bup_data.myisam3);
 
@@ -60,8 +77,9 @@ CREATE TABLE bup_nodata.e1 (
   Vapor_period smallint(4) unsigned DEFAULT '0' NOT NULL
 ) ENGINE=example;
 
-# Insert some data (for merge and federated to ensure proper working tables)
---echo Inserting data
+--echo #
+--echo # Insert some data.
+--echo #
 INSERT INTO bup_data.myisam1 VALUES (11, 'table 1');
 INSERT INTO bup_data.myisam1 VALUES (12, 'table 1');
 INSERT INTO bup_data.myisam1 VALUES (13, 'table 1');
@@ -78,85 +96,146 @@ INSERT INTO bup_data.f1 (id, `group`) VA
 INSERT INTO bup_data.f1 (id, `batch`) VALUES (4, 23);
 INSERT INTO bup_data.f1 (id, `qty`) VALUES (5, 1);
 
-# Show the data
---echo show data
+--echo #
+--echo # Show the data.
+--echo #
 SHOW FULL TABLES FROM bup_data;
 SHOW FULL TABLES FROM bup_nodata;
-
 SELECT * FROM bup_nodata.merge1;
 SELECT * FROM bup_nodata.f1;
 SELECT * FROM bup_nodata.b1;
 SELECT * FROM bup_nodata.e1;
 
-# Do the backup of the bup_data DB.
+--echo #
+--echo # Backup the bup_data DB, which tables contain data.
+--echo #
 --replace_column 1 #
 BACKUP DATABASE bup_data TO 'bup_data.bak';
 
-# Do the backup of the bup_nodata DB.
+--echo #
+--echo # Backup the bup_nodata DB, which tables do not contain data.
+--echo #
 --replace_column 1 #
 BACKUP DATABASE bup_nodata TO 'bup_nodata.bak';
 
-# Show the data
---echo show data
+--echo #
+--echo # Show the data again. Backup did not modify them.
+--echo #
 SHOW FULL TABLES FROM bup_data;
 SHOW FULL TABLES FROM bup_nodata;
-
 SELECT * FROM bup_nodata.merge1;
 SELECT * FROM bup_nodata.f1;
 SELECT * FROM bup_nodata.b1;
 SELECT * FROM bup_nodata.e1;
 
-# Now drop the data database and show what is left
-
+--echo #
+--echo # Now drop the bup_data database.
+--echo #
 DROP DATABASE bup_data;
 
-# Show the data
---echo show data
+--echo #
+--echo # Show that the data have gone.
+--echo # The MERGE and FEDERATED tables have errors since
+--echo # their base tables have been dropped with bup_data.
+--echo #
 SHOW FULL TABLES FROM bup_nodata;
-
-# The merge and federated tables should have errors since data is missing.
---error ER_NO_SUCH_TABLE
+--error ER_WRONG_MRG_TABLE
 SELECT * FROM bup_nodata.merge1;
 --error ER_CONNECT_TO_FOREIGN_DATA_SOURCE,ER_QUERY_ON_FOREIGN_DATA_SOURCE
 SELECT * FROM bup_nodata.f1;
 SELECT * FROM bup_nodata.b1;
 SELECT * FROM bup_nodata.e1;
 
+--echo #
+--echo # Now drop the bup_nodata database too.
+--echo #
 DROP DATABASE bup_nodata;
 
-# Now restore the nodata database and see if it is the same as above.
---echo Restoring nodata database.
+--echo #
+--echo # Now try to restore the bup_nodata database. This fails because
+--echo # restore opens the tables for filling them with data, even when
+--echo # they were empty on backup. 'bup_nodata.bak' does not contain
+--echo # the base tables for the MERGE and FEDERATED tables.
+--echo # NOTE: Since restore fails after restoring the meta data,
+--echo # after creating the tables that is, we have the same
+--echo # situation as before. The tables exist, but the base
+--echo # tables for MERGE and FEDERATED do not exist.
+--echo #
 --replace_column 1 #
-RESTORE FROM 'bup_nodata.bak';
+--error ER_WRONG_MRG_TABLE,ER_CONNECT_TO_FOREIGN_DATA_SOURCE,ER_QUERY_ON_FOREIGN_DATA_SOURCE
+RESTORE FROM 'bup_nodata.bak' OVERWRITE;
 
-# Show the data
---echo show data
+--echo #
+--echo # Show what we have.
+--echo # NOTE: If restore would work as all or nothing,
+--echo # all of the SHOW and SELECT statements in this section would fail.
+--echo #
 SHOW FULL TABLES FROM bup_nodata;
-
-# The merge and federated tables should have errors since data is missing.
---error ER_NO_SUCH_TABLE
+--error ER_WRONG_MRG_TABLE
 SELECT * FROM bup_nodata.merge1;
 --error ER_CONNECT_TO_FOREIGN_DATA_SOURCE,ER_QUERY_ON_FOREIGN_DATA_SOURCE
 SELECT * FROM bup_nodata.f1;
 SELECT * FROM bup_nodata.b1;
 SELECT * FROM bup_nodata.e1;
 
-# Now restore the data database and see that all is well.
---echo Restoring data database.
+--echo #
+--echo # Now restore the bup_data database as well.
+--echo #
 --replace_column 1 #
 RESTORE FROM 'bup_data.bak';
 
-# Show the data
---echo show data
+--echo #
+--echo # Show that everything is well.
+--echo # NOTE: If restore would work as all or nothing,
+--echo # the bup_nodata tables would not exist here.
+--echo #
 SHOW FULL TABLES FROM bup_data;
 SHOW FULL TABLES FROM bup_nodata;
+SELECT * FROM bup_nodata.merge1;
+SELECT * FROM bup_nodata.f1;
+SELECT * FROM bup_nodata.b1;
+SELECT * FROM bup_nodata.e1;
+
+--echo #
+--echo # Now restore the bup_nodata database and see if it is the same
+--echo # as above. Note that this step would not be required here
+--echo # because all bup_nodata tables have no data and were created
+--echo # by the failed restore. Anyway, the correct approach is to do a
+--echo # succeeding restore before assuming that everything exists again.
+--echo #
+--replace_column 1 #
+RESTORE FROM 'bup_nodata.bak' OVERWRITE;
 
+--echo #
+--echo # Show that everything is well.
+--echo #
+SHOW FULL TABLES FROM bup_nodata;
 SELECT * FROM bup_nodata.merge1;
 SELECT * FROM bup_nodata.f1;
 SELECT * FROM bup_nodata.b1;
 SELECT * FROM bup_nodata.e1;
 
+--echo #
+--echo # Now drop the bup_data database with the base tables again.
+--echo #
 DROP DATABASE bup_data;
+
+--echo #
+--echo # Show that the data have gone.
+--echo # The MERGE and FEDERATED tables have errors since
+--echo # their base tables have been dropped with bup_data.
+--echo #
+SHOW FULL TABLES FROM bup_nodata;
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM bup_nodata.merge1;
+--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE,ER_QUERY_ON_FOREIGN_DATA_SOURCE
+SELECT * FROM bup_nodata.f1;
+SELECT * FROM bup_nodata.b1;
+SELECT * FROM bup_nodata.e1;
+
+--echo #
+--echo # Cleanup.
+--echo #
 DROP DATABASE bup_nodata;
 
 --error 0,1
@@ -164,3 +243,5 @@ DROP DATABASE bup_nodata;
 --error 0,1
 --remove_file $MYSQLTEST_VARDIR/master-data/bup_nodata.bak
 
+UNINSTALL PLUGIN example;
+

=== modified file 'mysql-test/suite/backup/t/backup_security.test'
--- a/mysql-test/suite/backup/t/backup_security.test	2008-10-24 08:25:48 +0000
+++ b/mysql-test/suite/backup/t/backup_security.test	2008-11-17 09:57:51 +0000
@@ -72,7 +72,7 @@ BACKUP DATABASE backup_test to 'bup_with
 
 --echo no_rights: Attempting restore. Should succeed
 --replace_column 1 #
-RESTORE FROM 'bup_with_rights.bak';
+RESTORE FROM 'bup_with_rights.bak' OVERWRITE;
 
 SELECT * FROM backup_test.t1;
 
@@ -82,7 +82,7 @@ disconnect with_rights;
 connection default;
 
 --replace_column 1 #
-RESTORE FROM 'backup_test_orig.bak';
+RESTORE FROM 'backup_test_orig.bak' OVERWRITE;
 
 SELECT * FROM backup_test.t1;
 

=== modified file 'mysql-test/suite/backup/t/backup_snapshot.test'
--- a/mysql-test/suite/backup/t/backup_snapshot.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_snapshot.test	2008-11-17 09:57:51 +0000
@@ -116,7 +116,7 @@ DROP TABLE bup_snapshot.t1;
 
 --echo con1: Restoring the database
 --replace_column 1 #
-RESTORE FROM "bup_snapshot.bak";
+RESTORE FROM "bup_snapshot.bak" OVERWRITE;
 
 --echo con1: Showing the data (no new data should be here).
 SELECT * FROM bup_snapshot.t1 WHERE word LIKE '-%';
@@ -175,7 +175,7 @@ DROP TABLE bup_snapshot.t1;
 
 --echo con1: Restoring the database
 --replace_column 1 #
-RESTORE FROM "bup_snapshot.bak";
+RESTORE FROM "bup_snapshot.bak" OVERWRITE;
 
 --echo con1: Showing the data (no new data should be here).
 SELECT * FROM bup_snapshot.t1 WHERE word LIKE '-%';

=== modified file 'mysql-test/suite/backup/t/backup_timeout.test'
--- a/mysql-test/suite/backup/t/backup_timeout.test	2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_timeout.test	2008-11-19 22:01:28 +0000
@@ -159,4 +159,6 @@ SHOW VARIABLES LIKE 'backup_wait%';
 
 DROP DATABASE bup_ddl_blocker;
 
+SET DEBUG_SYNC= 'reset';
+
 --remove_file $MYSQLTEST_VARDIR/master-data/bup_ddl_blocker.bak

=== added file 'mysql-test/suite/backup/t/backup_vp_nontx.test'
--- a/mysql-test/suite/backup/t/backup_vp_nontx.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_vp_nontx.test	2008-11-20 09:49:34 +0000
@@ -0,0 +1,256 @@
+#
+# This test is one of two validity point tests. See:
+#    backup_vp_tx.test
+#
+# The goal of the test should be to ensure the following assumptions
+# for the behavior of validity point (VP) hold. Validity point is
+# implemented using commit blocker (CB).
+#
+# Note: in this file, "DML" refers to DML operations executed in
+#       non-transactional storage engines.
+#
+# a) DMLs that are executed before VP are in the backup image
+#
+# b) setting the validity point should not be done while DMLs are
+#    being processed in any table involved in the backup. An active
+#    DML therefore blocks backup from setting commit blocker. The DML
+#    has to complete before backup can set CB (and ultimately set the
+#    VP), and will therefore be in the backup image
+#
+# c) setting the validity point should not be done while DMLs are
+#    being processed in any table involved in the backup. A DML
+#    operation requested when backup is ready to set VP is therefore
+#    blocked by CB. The DML has to wait for CB to be released before
+#    it can continue, and will therefore not be in the backup image
+#
+# d) DMLs executed after VP are not in the backup image
+#
+#
+
+--source include/have_debug_sync.inc
+--source include/not_embedded.inc
+
+--disable_warnings
+SET DEBUG_SYNC= 'RESET';
+DROP DATABASE IF EXISTS bup_vp;
+
+let $bdir=`SELECT @@backupdir`;
+
+--error 0,1
+remove_file $bdir/bup_vp.bak;
+--enable_warnings
+
+
+CREATE DATABASE bup_vp;
+
+#
+# Connections used in this test
+#
+# con_bup  - used to create data, load data, and run the backup 
+# con_ntx1 - used for non-transactional execution
+# con_ntx2 - used for non-transactional execution
+# con_sync - used to make sync point work flow easier to read
+#
+
+connect (con_bup,localhost,root,,);
+connect (con_ntx1,localhost,root,,);
+connect (con_ntx2,localhost,root,,);
+connect (con_sync,localhost,root,,);
+
+connection con_bup;
+
+--echo 
+--echo Starting Test
+--echo 
+
+#
+# Sequence diagram (not UML), only relevant parts shown
+#
+#      bup     tx1      tx2
+#       |       |        | 
+#       a)      |        | 
+#    (setup)    |        | 
+#       |       b)       | 
+#       |    INSERT      | 
+#     BACKUP  <...>      | 
+#     SET CB  <...>      | 
+#     <###>   <...>      | 
+#     <...>     |        c)
+#       |       |     INSERT
+#    SET VP     |      <###>
+#   RELEASE CB  |      <###>
+#       |       d)     <...>
+#       |    INSERT      | 
+#    BUP DONE   |        | 
+#   (results)   |        | 
+#
+# Note: Ongoing operations are indicated with <...>
+#       Blocked operations are indicated with <###>
+#
+
+# Create transaction tables and load them with data.
+--echo con_bup: Creating tables
+CREATE TABLE bup_vp.t1 (col_a CHAR(40)) ENGINE=MEMORY;
+
+--echo con_bup: Loading data
+--echo con_bup: Scenario a) - commited before backup
+INSERT INTO bup_vp.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("04 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("05 Some data to test");
+
+--echo 
+--echo con_bup: Show the data before we start backup
+SELECT * FROM bup_vp.t1;
+
+### CON 1 ###
+  --echo 
+  connection con_ntx1;
+
+  --echo Scenario (b): Insert in progress blocks CB and is included in backup
+  --echo con_ntx1: Start insert and stop it in the middle of processing
+
+  --echo con_ntx1: Make insert stop in the middle of execution
+  # Will continue once backup has been blocked from setting CB
+  SET DEBUG_SYNC= 'after_insert_locked_tables SIGNAL insert_started
+                   WAIT_FOR complete_insert';
+  send INSERT INTO bup_vp.t1 VALUES ("ntx1: 06 Some data to test");
+
+
+### CON BUP ###
+--echo 
+connection con_bup;
+
+# Backup will be blocked from setting CB by the ongoing insert in
+# con_ntx1. Backup will signal con_ntx1 that it has been blocked. The
+# insert will then finish, making backup able to set CB. When CB has
+# been set, ntx2 will be signaled to try to insert. ntx2 insert will
+# be blocked by the CB and send a signal that it has been blocked. CB
+# is then released, but backup is stopped immediately after releasing
+# CB. ntx2 will now be able to complete the insert, and ntx1 will
+# issue and complete another insert. Finally, backup is allowed to
+# complete.
+
+--echo con_bup: Activate synchronization points for BACKUP.
+# Signal when backup is blocked by ongoing insert in con_ntx1
+SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL sync_complete_insert';
+
+# ntx1 insert is completed, so backup can set CB. Just before reaching
+# VP, signal ntx2 should try to insert. Wait until ntx2 signals it has
+# been blocked
+SET DEBUG_SYNC= 'before_backup_data_lock SIGNAL try_insert
+                 WAIT_FOR insert_blocked';
+
+# ntx2 insert has been blocked. Create VP and release CB, and then wait
+# while ntx2 and ntx1 inserts.
+SET DEBUG_SYNC= 'after_backup_binlog SIGNAL commit_unblocked
+                 WAIT_FOR finish_bup';
+
+--echo con_bup: Backing up database -- will block with lock
+send BACKUP DATABASE bup_vp TO "bup_vp.bak";
+
+### CON SYNC ###
+--echo 
+connection con_sync;
+SET DEBUG_SYNC= 'now WAIT_FOR sync_complete_insert';
+--echo Backup has been blocked by ongoing insert
+
+# cannot test with select that insert has not completed ntx1 has X-lock
+SET DEBUG_SYNC= 'now SIGNAL complete_insert';
+
+### CON 1 ###
+  --echo 
+  connection con_ntx1;
+  --echo con_ntx1: Reap insert
+  reap;
+
+  --echo Check that record has been inserted; Should be 1 record
+  SELECT * FROM bup_vp.t1 WHERE col_a like 'ntx1%';
+  --echo 
+
+###########
+## Below this line happens after BACKUP has taken CB
+###########
+
+### CON 2 ###
+    connection con_ntx2;
+
+    --echo con_ntx2: Wait until backup has set CB, then try to insert
+    # Wait for backup to set CB
+    SET DEBUG_SYNC= 'now WAIT_FOR try_insert';
+    # Signal to backup that the insert is blocked
+    SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL sync_insert_blocked';
+    send INSERT INTO bup_vp.t1 VALUES ("ntx2: Should NOT be in backup");
+
+    # INSERT is blocked until CB has been released
+
+### CON SYNC ###
+--echo 
+connection con_sync;
+SET DEBUG_SYNC= 'now WAIT_FOR sync_insert_blocked';
+
+--echo Insert in ntx2 is blocked and should not be in t1; Should be 0 records
+SELECT * FROM bup_vp.t1 WHERE col_a like 'ntx2%';
+--echo 
+
+SET DEBUG_SYNC= 'now SIGNAL insert_blocked';
+
+
+### CON 1 ###
+  --echo 
+  connection con_ntx1;
+
+  --echo con_ntx1: Backup has now released CB. Perform insert
+  # Double-check that backup has reached sync point after CB release
+  SET DEBUG_SYNC= 'now WAIT_FOR commit_unblocked';
+  INSERT INTO bup_vp.t1 VALUES ("ntx1: Should NOT be in backup");
+  SET DEBUG_SYNC= 'now SIGNAL finish_bup';
+
+
+### CON BUP ###
+--echo 
+connection con_bup;
+--echo con_ntx1: Reap backup
+--replace_column 1 #
+reap;
+
+
+###########
+## Verify results
+###########
+
+# Do selects to show that all changes got applied.
+--echo 
+--echo con_bup: Showing data after updates and backup
+SELECT * FROM bup_vp.t1;
+
+--echo con_bup: Dropping the database
+DROP TABLE bup_vp.t1;
+DROP DATABASE bup_vp;
+
+--echo con_bup: Restoring the database
+--replace_column 1 #
+RESTORE FROM "bup_vp.bak";
+
+--echo 
+--echo con_bup: Showing the data after restore
+SELECT * FROM bup_vp.t1;
+
+--echo
+--echo Verifying results:
+--echo
+
+--echo T1 should have changes from con_ntx1; Should be 1 record
+SELECT * FROM bup_vp.t1 WHERE col_a like 'ntx1%';
+--echo 
+
+--echo T1 should not have the changes from con_ntx2; Should be 0 records
+SELECT * FROM bup_vp.t1 WHERE col_a like 'ntx2%';
+--echo 
+
+--echo con_bup: Cleanup
+DROP DATABASE bup_vp;
+
+remove_file $bdir/bup_vp.bak;
+SET DEBUG_SYNC= 'RESET';

=== added file 'mysql-test/suite/backup/t/backup_vp_tx.test'
--- a/mysql-test/suite/backup/t/backup_vp_tx.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup/t/backup_vp_tx.test	2008-11-20 09:49:34 +0000
@@ -0,0 +1,329 @@
+#
+# This test is one of two validity point tests. See:
+#    backup_vp_nontx.test
+#
+# The goal of the test should be to ensure the following assumptions
+# for the behavior of validity point (VP) hold. Validity point is
+# implemented using commit blocker (CB).
+#
+# a) transactions that commit before VP are in the backup image
+#
+# b) setting the validity point should not be done while commits are
+#    being processed in any table involved in the backup. Transactions
+#    with ongoing commits therefore block backup from setting commit
+#    blocker. The commit has to complete before backup can set CB (and
+#    ultimately set the VP), and will therefore be in the backup image
+#
+# c) setting the validity point should not be done while commits are
+#    being processed in any table involved in the backup. Transactions
+#    that try to commit when backup is ready to set VP are therefore
+#    blocked by CB. The commit has to wait for CB to be released
+#    before it can continue, and will therefore not be in the backup
+#    image
+#
+# d) transactions that commit after VP are not in the backup image
+#
+# Note: the transactions have to modify data.
+#
+#
+#
+
+--source include/have_innodb.inc
+--source include/have_debug_sync.inc
+--source include/not_embedded.inc
+
+--disable_warnings
+SET DEBUG_SYNC= 'RESET';
+DROP DATABASE IF EXISTS bup_vp;
+
+let $bdir=`SELECT @@backupdir`;
+
+--error 0,1
+remove_file $bdir/bup_vp.bak;
+--enable_warnings
+
+CREATE DATABASE bup_vp;
+
+#
+# Connections used in this test
+#
+# con_bup  - used to create data, load data, and run the backup 
+# con_tx1  - used for transactional execution
+# con_tx2  - used for transactional execution
+# con_tx3  - used for transactional execution
+# con_sync - used to make sync point work flow easier to read
+#
+
+connect (con_bup,localhost,root,,);
+connect (con_tx1,localhost,root,,);
+connect (con_tx2,localhost,root,,);
+connect (con_tx3,localhost,root,,);
+connect (con_sync,localhost,root,,);
+
+connection con_bup;
+
+--echo 
+--echo Starting Test
+--echo 
+
+#
+# Sequence diagram (not UML), only relevant parts shown
+#
+#      bup     tx1      tx2      tx3
+#       |       |        |        |
+#       a)      |        |        |
+#    (setup)    |        |        |
+#     COMMIT    |        |        d)
+#       |       |        |      BEGIN
+#       |       b)       |    INSERT t3
+#       |     BEGIN      |        |
+#       |   INSERT t1    |        |
+#       |     COMMIT     c)       |
+#       |     <...>    BEGIN      |
+#       |     <...>  INSERT t2    |
+#       |     <...>      |        |   
+#     BACKUP  <...>      |        |
+#     SET CB  <...>      |        |   
+#     <###>   <...>      |        |  
+#     <...>     |        |        |  
+#       |       |     COMMIT      |  
+#    SET VP     |      <###>      |   
+#   RELEASE CB  |      <###>      |  
+#       |       |      <...>    COMMIT
+#       |       |        |        |  
+#    BUP DONE   |        |        |  
+#   (results)   |        |        |     
+#
+# Note: Ongoing operations are indicated with <...>
+#       Blocked operations are indicated with <###>
+#
+
+# Create transaction tables and load them with data.
+--echo con_bup: Creating tables
+CREATE TABLE bup_vp.t1 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_vp.t2 (col_a CHAR(40)) ENGINE=INNODB;
+CREATE TABLE bup_vp.t3 (col_a CHAR(40)) ENGINE=INNODB;
+
+--echo 
+--echo con_bup: Loading data
+--echo con_bup: Scenario a) - commited before backup
+INSERT INTO bup_vp.t1 VALUES ("01 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("02 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("03 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("04 Some data to test");
+INSERT INTO bup_vp.t1 VALUES ("05 Some data to test");
+
+INSERT INTO bup_vp.t2 VALUES ("01 Some data to test");
+INSERT INTO bup_vp.t2 VALUES ("02 Some data to test");
+INSERT INTO bup_vp.t2 VALUES ("03 Some data to test");
+INSERT INTO bup_vp.t2 VALUES ("04 Some data to test");
+INSERT INTO bup_vp.t2 VALUES ("05 Some data to test");
+
+INSERT INTO bup_vp.t3 VALUES ("01 Some data to test");
+INSERT INTO bup_vp.t3 VALUES ("02 Some data to test");
+INSERT INTO bup_vp.t3 VALUES ("03 Some data to test");
+INSERT INTO bup_vp.t3 VALUES ("04 Some data to test");
+INSERT INTO bup_vp.t3 VALUES ("05 Some data to test");
+
+--echo 
+--echo con_bup: Show the data before we start backup
+SELECT * FROM bup_vp.t1;
+SELECT * FROM bup_vp.t2;
+SELECT * FROM bup_vp.t3;
+
+### CON 3 ###
+      --echo 
+      connection con_tx3;
+
+      --echo Scenario d) - commit after VP; tx not included in backup
+      --echo con_tx3: Start transaction but do not commit
+      BEGIN;
+          INSERT INTO bup_vp.t3 VALUES ("tx3: 06 Should NOT be in backup");
+
+### CON 1 ###
+  --echo 
+  connection con_tx1;
+
+  --echo Scenario b) - Commit in progress blocks CB; tx is included in backup
+  --echo con_tx1: Get a transaction going and stop in the middle of commit
+  BEGIN;
+      INSERT INTO bup_vp.t1 VALUES ("tx1: 06 Some data to test");
+
+      --echo con_tx1: Make commit stop in the middle of execution
+      # Will continue once backup has been blocked from setting CB
+      SET DEBUG_SYNC= 'within_ha_commit_trans SIGNAL commit_started
+                       WAIT_FOR complete_commit';
+      send COMMIT;
+
+### CON 2 ###
+    --echo 
+    connection con_tx2;
+
+    --echo Scenario c) - commit blocked by CB; tx not included in backup
+    --echo con_tx2: Wait until tx1 has started
+    SET DEBUG_SYNC= 'now WAIT_FOR commit_started';
+    --echo con_tx2: Start transaction but do not commit
+    BEGIN;
+        INSERT INTO bup_vp.t2 VALUES ("tx2: 06 Should NOT be in backup");
+    
+### CON BUP ###
+--echo 
+connection con_bup;
+
+# Backup will be blocked from setting CB by the ongoing commit in
+# con_tx1. Backup will signal con_tx1 that it has been blocked. The
+# commit will then finish, making backup able to set CB. When CB has
+# been set, tx2 will be signaled to try to commit. tx2 commit will be
+# blocked by the CB and send a signal that it has been blocked. CB is
+# then released, but backup is stopped immediately after releasing CB.
+# tx2 will now be able to complete the commit, and tx3 will issue and
+# complete a commit. Finally, backup is allowed to complete.
+
+--echo con_bup: Activate synchronization points for BACKUP.
+# Signal when backup is blocked by ongoing commit in con_tx1
+SET DEBUG_SYNC= 'wait_lock_global_read_lock SIGNAL sync_complete_commit';
+
+# tx1 commit is completed, so backup can set CB. Just before reaching
+# VP, signal tx2 should try to commit. Wait until tx2 signals it has
+# been blocked
+SET DEBUG_SYNC= 'before_backup_data_lock SIGNAL try_commit 
+                 WAIT_FOR commit_blocked';
+
+# tx2 commit has been blocked. Create VP and release CB, and then wait
+# while tx2 and tx2 commits.
+SET DEBUG_SYNC= 'after_backup_binlog SIGNAL commit_unblocked
+                 WAIT_FOR finish_bup';
+
+--echo con_bup: Backing up database -- will block with lock
+send BACKUP DATABASE bup_vp TO "bup_vp.bak";
+
+
+### CON SYNC ###
+--echo 
+connection con_sync;
+SET DEBUG_SYNC= 'now WAIT_FOR sync_complete_commit';
+--echo Backup has been blocked by ongoing commit
+
+--echo Check that con_tx1 has not committed; Should be 0 records
+SELECT * FROM bup_vp.t1 WHERE col_a like 'tx1%';
+--echo 
+
+SET DEBUG_SYNC= 'now SIGNAL complete_commit';
+
+### CON 1 ###
+  --echo 
+  connection con_tx1;
+  --echo con_tx1: Reap commit
+  reap;
+  --echo Check that con_tx1 has committed; Should be 1 record
+  SELECT * FROM bup_vp.t1 WHERE col_a like 'tx1%';
+  --echo 
+
+###########
+## Below this line happens after BACKUP has taken CB
+###########
+
+### CON 2 ###
+    --echo 
+    connection con_tx2;
+    --echo con_tx2: Commit request will be blocked by CB
+
+    # Wait for backup to set CB
+    SET DEBUG_SYNC= 'now WAIT_FOR try_commit';
+
+    # Signal to backup that the commit is blocked
+    SET DEBUG_SYNC= 'wait_if_global_read_lock SIGNAL sync_commit_blocked';
+
+    send COMMIT;
+
+    # Test is blocked on COMMIT until CB has been released
+
+### CON SYNC ###
+--echo 
+connection con_sync;
+SET DEBUG_SYNC= 'now WAIT_FOR sync_commit_blocked';
+
+--echo Check that con_tx2 has not committed; Should be 0 records
+SELECT * FROM bup_vp.t2 WHERE col_a like 'tx2%';
+--echo 
+
+SET DEBUG_SYNC= 'now SIGNAL commit_blocked';
+
+### CON 2 ###
+    --echo 
+    connection con_tx2;
+    --echo con_bup: Reap commit
+    # commit completes only after CB has been released
+    reap;
+
+    --echo con_tx2: Backup has now released CB.
+    --echo Check that con_tx2 has committed; Should be 1 record
+    SELECT * FROM bup_vp.t2 WHERE col_a like 'tx2%';
+    --echo 
+
+### CON 3 ###
+      --echo 
+      connection con_tx3;
+      --echo con_tx3: Backup has now released CB. Commit transaction
+
+      # Double-check that backup has reached sync point after CB release
+      SET DEBUG_SYNC= 'now WAIT_FOR commit_unblocked';
+      COMMIT;
+      SET DEBUG_SYNC= 'now SIGNAL finish_bup';
+
+
+### CON BUP ###
+--echo 
+connection con_bup;
+--echo con_bup: Reap backup
+--replace_column 1 #
+reap;
+
+###########
+## Verify results
+###########
+
+# Do selects to show that all changes got applied.
+--echo 
+--echo con_bup: Showing data after updates and backup
+SELECT * FROM bup_vp.t1;
+SELECT * FROM bup_vp.t2;
+SELECT * FROM bup_vp.t3;
+
+--echo con_bup: Dropping the database
+DROP TABLE bup_vp.t1;
+DROP TABLE bup_vp.t2;
+DROP TABLE bup_vp.t3;
+DROP DATABASE bup_vp;
+
+--echo con_bup: Restoring the database
+--replace_column 1 #
+RESTORE FROM "bup_vp.bak";
+
+--echo 
+--echo con_bup: Showing the data after restore (tx2 and tx3 should not be there)
+SELECT * FROM bup_vp.t1;
+SELECT * FROM bup_vp.t2;
+SELECT * FROM bup_vp.t3;
+
+--echo
+--echo Verifying results:
+--echo
+
+--echo T1 should have changes from con_tx1; Should be 1 record
+SELECT * FROM bup_vp.t1 WHERE col_a like 'tx1%';
+
+--echo 
+--echo T2 should not have the changes from con_tx2; Should be 0 records
+SELECT * FROM bup_vp.t2 WHERE col_a like 'tx2%';
+
+--echo 
+--echo T3 should not have the changes from con_tx3; Should be 0 records
+SELECT * FROM bup_vp.t3 WHERE col_a like 'tx3%';
+
+--echo 
+--echo con_bup: Cleanup
+DROP DATABASE bup_vp;
+
+remove_file $bdir/bup_vp.bak;
+SET DEBUG_SYNC= 'RESET';

=== modified file 'mysql-test/suite/backup/t/disabled.def'
--- a/mysql-test/suite/backup/t/disabled.def	2008-10-30 10:41:48 +0000
+++ b/mysql-test/suite/backup/t/disabled.def	2008-11-21 10:59:49 +0000
@@ -14,3 +14,5 @@ backup_triggers_and_events  : Bug#37762 
 #backup_no_be                : Bug#38023 2008-07-16 rafal Test triggers valgrind warnings described in the bug
 backup_no_data       : Bug#17823 2008-10-09 rafal Tests in main suite leave undeleted files causing this test to fail
 backup_ddl_blocker   : Bug#17823 2008-10-09 rafal Tests in main suite leave undeleted files causing this test to fail
+backup               : Bug#40807 2008-11-18 hakank Test fails on big-endian architecture
+backup_timeout       : Bug#40808 2008-11-18 hakank Test fails on big-endian architecture

=== modified file 'mysql-test/suite/backup_engines/include/backup_ptr_commit.inc'
--- a/mysql-test/suite/backup_engines/include/backup_ptr_commit.inc	2008-10-08 04:26:25 +0000
+++ b/mysql-test/suite/backup_engines/include/backup_ptr_commit.inc	2008-11-17 09:57:51 +0000
@@ -202,7 +202,7 @@ SELECT * FROM ptr.t3;
 
 --echo Perform restore operation
 --replace_column 1 #
-RESTORE FROM 'ptr_commit.bak';
+RESTORE FROM 'ptr_commit.bak' OVERWRITE;
 SHOW TABLES FROM ptr;
 SELECT * FROM ptr.t1;
 SELECT * FROM ptr.t2;

=== modified file 'mysql-test/suite/backup_engines/r/backup_online_testing.result'
--- a/mysql-test/suite/backup_engines/r/backup_online_testing.result	2008-06-30 19:40:33 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_online_testing.result	2008-11-19 22:01:28 +0000
@@ -1135,3 +1135,4 @@ COUNT(*)
 ***  DROP bup_online DATABASE ****
 
 DROP DATABASE bup_online;
+SET DEBUG_SYNC= 'RESET';

=== modified file 'mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result	2008-10-08 04:26:25 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_commit_mixed.result	2008-11-17 09:57:51 +0000
@@ -304,7 +304,7 @@ id	name
 Perform Restore and Recover committed data using mysqlbinlog position
 after backup.
 Perform restore operation
-RESTORE FROM 'ptr_commit.bak';
+RESTORE FROM 'ptr_commit.bak' OVERWRITE;
 backup_id
 #
 SHOW TABLES FROM ptr;

=== modified file 'mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result	2008-10-08 04:26:25 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_commit_row.result	2008-11-17 09:57:51 +0000
@@ -304,7 +304,7 @@ id	name
 Perform Restore and Recover committed data using mysqlbinlog position
 after backup.
 Perform restore operation
-RESTORE FROM 'ptr_commit.bak';
+RESTORE FROM 'ptr_commit.bak' OVERWRITE;
 backup_id
 #
 SHOW TABLES FROM ptr;

=== modified file 'mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result'
--- a/mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result	2008-10-08 04:26:25 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_ptr_commit_stmt.result	2008-11-17 09:57:51 +0000
@@ -304,7 +304,7 @@ id	name
 Perform Restore and Recover committed data using mysqlbinlog position
 after backup.
 Perform restore operation
-RESTORE FROM 'ptr_commit.bak';
+RESTORE FROM 'ptr_commit.bak' OVERWRITE;
 backup_id
 #
 SHOW TABLES FROM ptr;

=== modified file 'mysql-test/suite/backup_engines/r/backup_tmp_tables.result'
--- a/mysql-test/suite/backup_engines/r/backup_tmp_tables.result	2008-10-30 12:29:54 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_tmp_tables.result	2008-11-17 09:57:51 +0000
@@ -29,7 +29,7 @@ backup_id
 ** Drop and restore the database
 DROP TABLE t1;
 DROP TABLE t2;
-RESTORE FROM 'db.bkp';
+RESTORE FROM 'db.bkp' OVERWRITE;
 backup_id
 #
 ** Check definitions of the tables after restore

=== modified file 'mysql-test/suite/backup_engines/t/backup_online_testing.test'
--- a/mysql-test/suite/backup_engines/t/backup_online_testing.test	2008-06-30 19:40:33 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_online_testing.test	2008-11-19 22:01:28 +0000
@@ -1152,3 +1152,4 @@ DROP DATABASE bup_online;
 
 remove_file $MYSQLTEST_VARDIR/master-data/bup_online.bak;
 
+SET DEBUG_SYNC= 'RESET';

=== modified file 'mysql-test/suite/backup_engines/t/backup_tmp_tables.test'
--- a/mysql-test/suite/backup_engines/t/backup_tmp_tables.test	2008-11-12 17:42:23 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_tmp_tables.test	2008-11-17 09:57:51 +0000
@@ -52,7 +52,7 @@ BACKUP DATABASE db TO 'db.bkp';
 DROP TABLE t1;
 DROP TABLE t2;
 --replace_column 1 #
-RESTORE FROM 'db.bkp';
+RESTORE FROM 'db.bkp' OVERWRITE;
 
 #
 # Note: Above DROP TABLE statements should be removed once BUG#30099 is fixed.

=== added file 'mysql-test/suite/backup_engines/t/disabled.def'
--- a/mysql-test/suite/backup_engines/t/disabled.def	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/disabled.def	2008-11-18 21:10:05 +0000
@@ -0,0 +1,13 @@
+##############################################################################
+#
+#  List the test cases that are to be disabled temporarily.
+#
+#  Separate the test case name and the comment with ':'.
+#
+#    <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
+#
+#  Do not use any TAB characters for whitespace.
+#
+##############################################################################
+backup_ptr_mixed     : Bug#37281 2008-11-18 hakank Dates in Falcon on big-endian have wrong result.
+backup_ptr_row       : Bug#37281 2008-11-18 hakank Dates in Falcon on big-endian have wrong result.

=== renamed file 'mysql-test/suite/falcon/r/falcon_bug_28095_I.result' => 'mysql-test/suite/falcon/r/falcon_bug_28095.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_28095_I.result	2007-09-20 15:44:25 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_28095.result	2008-11-04 15:22:06 +0000
@@ -1,15 +1,35 @@
-SET STORAGE_ENGINE = Falcon;
-*** Bug #126: First phase ***
-*** Also covering bug #113 ***
+*** Bug #28095: First phase ***
+SET @@storage_engine = 'Falcon';
 DROP TABLE IF EXISTS t1;
 DROP TABLE IF EXISTS t2;
 CREATE TABLE t1 (a int);
 INSERT INTO t1 VALUES (1);
 INSERT INTO t1 VALUES (2);
 INSERT INTO t1 VALUES (3);
-SELECT * FROM t1;
+SELECT * FROM t1 ORDER BY a;
 a
 1
 2
 3
 CREATE TABLE t2 (b int);
+SELECT @@GLOBAL.falcon_debug_mask;
+@@GLOBAL.falcon_debug_mask
+0
+SET GLOBAL falcon_debug_mask = 4096;
+SELECT @@GLOBAL.falcon_debug_mask;
+@@GLOBAL.falcon_debug_mask
+4096
+*** Bug #28095: Second phase ***
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+3
+SELECT count(*) FROM t1;
+count(*)
+3
+SELECT @@GLOBAL.falcon_debug_mask;
+@@GLOBAL.falcon_debug_mask
+0
+DROP TABLE t1;
+DROP TABLE t2;

=== removed file 'mysql-test/suite/falcon/r/falcon_bug_28095_II.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_28095_II.result	2008-03-28 17:13:51 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_28095_II.result	1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
-*** Bug #126: Second phase ***
-*** Also test for bug #123 ***
-SET @@storage_engine = Falcon;
-SELECT * FROM t1;
-a
-1
-2
-3
-DROP TABLE t1, t2;

=== added file 'mysql-test/suite/falcon/r/falcon_bug_30124-big.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_30124-big.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_30124-big.result	2008-10-28 19:32:35 +0000
@@ -0,0 +1,34 @@
+*** Bug #30124 ***
+SET @@storage_engine = 'Falcon';
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+SET @@autocommit=0;
+CREATE TABLE t1 (a int auto_increment PRIMARY KEY, b int);
+PREPARE stmt1 FROM 'INSERT INTO t1 (b) VALUES (?)';
+CREATE PROCEDURE p1()
+BEGIN
+SET @i = 0;
+SET @v = 0;
+WHILE @i < 1000000 DO
+SET @a = @v;
+EXECUTE stmt1 USING @a;
+SET @v = @v + 1;
+IF @v = 10 THEN
+SET @v = 0;
+END IF;
+SET @i = @i + 1;
+END WHILE;
+END;//
+CALL p1;
+COMMIT;
+SET @@autocommit = 1;
+UPDATE t1 SET b = 5 WHERE b = 3;
+SELECT count(*) FROM t1;
+count(*)
+1000000
+SELECT count(*) FROM t1 WHERE b = 5;
+count(*)
+200000
+DEALLOCATE PREPARE stmt1;
+DROP TABLE t1;
+DROP PROCEDURE p1;

=== modified file 'mysql-test/suite/falcon/r/falcon_bug_30124.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_30124.result	2007-09-20 15:44:25 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_30124.result	2008-10-28 19:32:35 +0000
@@ -9,7 +9,7 @@ CREATE PROCEDURE p1()
 BEGIN
 SET @i = 0;
 SET @v = 0;
-WHILE @i < 500000 DO
+WHILE @i < 100000 DO
 SET @a = @v;
 EXECUTE stmt1 USING @a;
 SET @v = @v + 1;
@@ -25,10 +25,10 @@ SET @@autocommit = 1;
 UPDATE t1 SET b = 5 WHERE b = 3;
 SELECT count(*) FROM t1;
 count(*)
-500000
+100000
 SELECT count(*) FROM t1 WHERE b = 5;
 count(*)
-100000
+20000
 DEALLOCATE PREPARE stmt1;
 DROP TABLE t1;
 DROP PROCEDURE p1;

=== added file 'mysql-test/suite/falcon/r/falcon_bug_38186.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_38186.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_38186.result	2008-10-31 00:29:13 +0000
@@ -0,0 +1,2 @@
+*** Bug #38186 ***
+SET @@storage_engine = 'Falcon';

=== added file 'mysql-test/suite/falcon/r/falcon_bug_39708.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_39708.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_39708.result	2008-10-29 11:41:14 +0000
@@ -0,0 +1,6 @@
+CREATE TABLE t1(a VARCHAR(140) CHARACTER SET utf8, KEY(a)) ENGINE=falcon;
+ERROR 42000: Specified key was too long; max key length is 540 bytes
+SHOW WARNINGS;
+Level	Code	Message
+Error	1071	Specified key was too long; max key length is 540 bytes
+Error	1005	Can't create table 'test.t1' (errno: 213)

=== added file 'mysql-test/suite/falcon/r/falcon_bug_40130.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_40130.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_40130.result	2008-11-05 15:04:45 +0000
@@ -0,0 +1,398 @@
+*** Bug #40130 ***
+SET @@storage_engine = 'Falcon';
+DROP TABLE IF EXISTS table10;
+CREATE TABLE table10 (`time_key` time, key (`time_key` ));
+INSERT INTO table10 VALUES ('23:43:55');
+INSERT INTO table10 VALUES ('03:18:59');
+INSERT INTO table10 VALUES ('05:05:23');
+INSERT INTO table10 VALUES ('09:20:40');
+INSERT INTO table10 VALUES ('22:32:50');
+INSERT INTO table10 VALUES ('07:41:31');
+INSERT INTO table10 VALUES ('10:52:13');
+INSERT INTO table10 VALUES ('12:40:54');
+INSERT INTO table10 VALUES ('10:33:25');
+INSERT INTO table10 VALUES ('22:11:46');
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '09:11:23' WHERE `time_key` < '16:23:56';
+INSERT INTO table10 VALUES ( '20:25:18' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '10:33:25' WHERE `time_key` > '22:11:46';
+INSERT INTO table10 VALUES ( '17:58:48' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '00:16:10' );
+UPDATE table10 SET `time_key` = '16:05:35' WHERE `time_key` > '16:57:24';
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '20:24:01' );
+INSERT INTO table10 VALUES ( '18:37:59' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '21:05:17' WHERE `time_key` < '06:07:07';
+INSERT INTO table10 VALUES ( '00:05:40' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '13:34:36' );
+INSERT INTO table10 VALUES ( '22:35:15' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '09:32:02' );
+INSERT INTO table10 VALUES ( '12:02:39' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '19:22:23' WHERE `time_key` < '03:39:55';
+UPDATE table10 SET `time_key` = '13:45:38' WHERE `time_key` < '03:52:41';
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '21:57:00' WHERE `time_key` < '11:37:04';
+INSERT INTO table10 VALUES ( '18:56:03' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '21:46:34' );
+INSERT INTO table10 VALUES ( '00:46:37' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '11:54:45' );
+INSERT INTO table10 VALUES ( '11:00:16' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '04:41:27' WHERE `time_key` > '05:45:30';
+INSERT INTO table10 VALUES ( '05:55:02' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '02:51:17' WHERE `time_key` < '05:33:58';
+INSERT INTO table10 VALUES ( '06:07:14' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '19:17:13' );
+UPDATE table10 SET `time_key` = '14:23:25' WHERE `time_key` < '18:44:25';
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '01:54:06' );
+INSERT INTO table10 VALUES ( '05:36:42' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '04:04:15' WHERE `time_key` < '17:09:11';
+INSERT INTO table10 VALUES ( '13:22:58' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '03:45:01' WHERE `time_key` < '01:02:29';
+INSERT INTO table10 VALUES ( '14:45:34' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '12:33:12' );
+INSERT INTO table10 VALUES ( '21:40:27' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '05:05:45' );
+INSERT INTO table10 VALUES ( '01:21:15' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '01:43:44' WHERE `time_key` > '18:44:54';
+UPDATE table10 SET `time_key` = '16:00:25' WHERE `time_key` > '17:37:45';
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '09:17:29' );
+UPDATE table10 SET `time_key` = '00:32:27' WHERE `time_key` < '19:55:22';
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '00:01:27' WHERE `time_key` < '23:49:20';
+INSERT INTO table10 VALUES ( '11:10:06' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '21:52:14' WHERE `time_key` > '00:54:57';
+INSERT INTO table10 VALUES ( '10:32:20' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '05:48:51' WHERE `time_key` < '05:53:48';
+UPDATE table10 SET `time_key` = '04:11:47' WHERE `time_key` > '14:02:03';
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '20:58:47' );
+INSERT INTO table10 VALUES ( '06:58:04' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '14:41:45' );
+UPDATE table10 SET `time_key` = '00:45:47' WHERE `time_key` < '21:51:00';
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '09:01:24' );
+INSERT INTO table10 VALUES ( '07:07:37' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '06:25:00' );
+INSERT INTO table10 VALUES ( '05:47:01' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '12:31:51' WHERE `time_key` > '04:34:05';
+INSERT INTO table10 VALUES ( '01:31:26' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '01:46:22' );
+INSERT INTO table10 VALUES ( '01:14:58' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '04:09:31' );
+UPDATE table10 SET `time_key` = '08:28:13' WHERE `time_key` > '14:50:18';
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '11:19:43' WHERE `time_key` < '04:30:14';
+INSERT INTO table10 VALUES ( '20:03:24' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '14:40:32' WHERE `time_key` < '15:30:08';
+UPDATE table10 SET `time_key` = '03:13:02' WHERE `time_key` < '21:47:42';
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '20:37:56' );
+UPDATE table10 SET `time_key` = '15:51:19' WHERE `time_key` < '01:39:43';
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '07:15:18' WHERE `time_key` > '05:37:40';
+INSERT INTO table10 VALUES ( '18:47:30' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '13:32:24' WHERE `time_key` > '23:38:12';
+INSERT INTO table10 VALUES ( '23:32:39' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '22:01:18' WHERE `time_key` < '17:51:48';
+INSERT INTO table10 VALUES ( '11:41:29' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '15:45:55' WHERE `time_key` > '04:03:52';
+UPDATE table10 SET `time_key` = '05:43:47' WHERE `time_key` < '07:29:01';
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '23:44:48' WHERE `time_key` < '00:33:42';
+UPDATE table10 SET `time_key` = '08:56:04' WHERE `time_key` > '12:16:41';
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '19:23:41' );
+INSERT INTO table10 VALUES ( '18:44:20' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '00:40:04' WHERE `time_key` > '11:34:06';
+UPDATE table10 SET `time_key` = '23:45:59' WHERE `time_key` < '09:44:50';
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '18:54:59' WHERE `time_key` < '15:46:02';
+INSERT INTO table10 VALUES ( '17:37:41' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '17:08:04' WHERE `time_key` < '14:11:50';
+UPDATE table10 SET `time_key` = '21:33:59' WHERE `time_key` > '17:44:43';
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '03:50:15' WHERE `time_key` > '19:35:18';
+UPDATE table10 SET `time_key` = '23:15:47' WHERE `time_key` < '12:18:46';
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '22:50:01' );
+INSERT INTO table10 VALUES ( '17:29:53' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '21:33:30' );
+INSERT INTO table10 VALUES ( '06:27:52' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '07:49:31' );
+INSERT INTO table10 VALUES ( '21:31:25' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '13:50:22' );
+INSERT INTO table10 VALUES ( '15:13:07' );
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '14:06:24' );
+INSERT INTO table10 VALUES ( '19:10:11' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '05:03:39' WHERE `time_key` > '11:46:31';
+INSERT INTO table10 VALUES ( '04:35:34' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '14:37:01' WHERE `time_key` < '02:11:03';
+INSERT INTO table10 VALUES ( '10:52:22' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '15:37:40' WHERE `time_key` > '11:19:00';
+INSERT INTO table10 VALUES ( '08:46:29' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '07:59:59' WHERE `time_key` < '05:27:20';
+UPDATE table10 SET `time_key` = '00:45:15' WHERE `time_key` < '20:07:08';
+COMMIT;
+START TRANSACTION;
+INSERT INTO table10 VALUES ( '00:51:31' );
+UPDATE table10 SET `time_key` = '10:00:58' WHERE `time_key` < '16:41:45';
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '13:49:37' WHERE `time_key` > '10:40:48';
+INSERT INTO table10 VALUES ( '05:16:25' );
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '14:46:15' WHERE `time_key` < '12:48:22';
+UPDATE table10 SET `time_key` = '05:50:46' WHERE `time_key` < '07:58:43';
+COMMIT;
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '00:11:06' WHERE `time_key` < '16:39:47';
+UPDATE table10 SET `time_key` = '04:13:41' WHERE `time_key` < '14:55:39';
+COMMIT;
+SELECT * FROM table10;
+time_key
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+04:13:41
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '00:28:04' WHERE `time_key` < '09:58:46';
+UPDATE table10 SET `time_key` = '04:56:25' WHERE `time_key` > '09:26:08';
+COMMIT;
+SELECT * FROM table10;
+time_key
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+00:28:04
+DROP TABLE table10;

=== added file 'mysql-test/suite/falcon/r/falcon_bug_40158.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_40158.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_40158.result	2008-11-05 14:51:37 +0000
@@ -0,0 +1,34 @@
+*** Bug #40158 ***
+SET @@storage_engine = 'Falcon';
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (`"strangename"` int);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+"strangename"
+1
+SELECT `"strangename"` FROM t1;
+"strangename"
+1
+DROP TABLE t1;
+SET LOCAL SQL_MODE=ANSI_QUOTES;
+CREATE TABLE t1 ("""strangename""" int);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+"strangename"
+1
+SELECT """strangename""" FROM t1;
+"strangename"
+1
+DROP TABLE t1;
+CREATE TABLE t1 (`""strangename""` int);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+""strangename""
+1
+SELECT `""strangename""` FROM t1;
+""strangename""
+1
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1
+DROP TABLE t1;

=== modified file 'mysql-test/suite/falcon/t/disabled.def'
--- a/mysql-test/suite/falcon/t/disabled.def	2008-09-11 16:28:29 +0000
+++ b/mysql-test/suite/falcon/t/disabled.def	2008-11-04 15:22:06 +0000
@@ -10,6 +10,4 @@
 #
 ##############################################################################
 
-falcon_bug_28095_I  : Bug#xxxxx 2008-04-22 hakank Disabled until soft restart is in main tree
-falcon_bug_28095_II : Bug#xxxxx 2008-03-22 hakank Disabled until soft restart is in main tree
 falcon_bug_32398 : HF disabled until new fix for this bug is developed

=== renamed file 'mysql-test/suite/falcon/t/falcon_bug_28095_I.test' => 'mysql-test/suite/falcon/t/falcon_bug_28095.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_28095_I.test	2007-09-29 04:30:42 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_28095.test	2008-11-13 14:55:42 +0000
@@ -1,20 +1,62 @@
 --source include/have_falcon.inc
-SET STORAGE_ENGINE = Falcon;
+
+#
+# Bug #28095: Falcon Drop table causes crash
 #
-# Mantis bug #126 first phase: Drop table causes crash
-# Mantis bug #113: JStar is crashing on shutdown
+# Note: This test consists of two phases involving a "soft"
+#    server restart with --shutdown_server. We do the
+#    restart with the help of include/restart_mysqld.inc.
 #
---echo *** Bug #126: First phase ***
---echo *** Also covering bug #113 ***
+--echo *** Bug #28095: First phase ***
+
+# ----------------------------------------------------- #
+# --- Initialisation                                --- #
+# ----------------------------------------------------- #
+let $engine = 'Falcon';
+eval SET @@storage_engine = $engine;
+
 --disable_warnings
 DROP TABLE IF EXISTS t1;
 DROP TABLE IF EXISTS t2;
 --enable_warnings
 
 CREATE TABLE t1 (a int);
+
+# ----------------------------------------------------- #
+# --- Test                                          --- #
+# ----------------------------------------------------- #
 INSERT INTO t1 VALUES (1);
 INSERT INTO t1 VALUES (2);
 INSERT INTO t1 VALUES (3);
-SELECT * FROM t1;
+SELECT * FROM t1 ORDER BY a;
 
 CREATE TABLE t2 (b int);
+
+#
+# We set a global variable to make sure that the
+# following restart really works. Global variables
+# should be resetted after a server restart.
+#
+SELECT @@GLOBAL.falcon_debug_mask;
+SET GLOBAL falcon_debug_mask = 4096;
+SELECT @@GLOBAL.falcon_debug_mask;
+
+# ----------------------------------------------------- #
+# --- Restart server                                --- #
+# ----------------------------------------------------- #
+--source include/restart_mysqld.inc
+
+--echo *** Bug #28095: Second phase ***
+SELECT * FROM t1 ORDER BY a;
+
+# ----------------------------------------------------- #
+# --- Check                                         --- #
+# ----------------------------------------------------- #
+SELECT count(*) FROM t1;
+SELECT @@GLOBAL.falcon_debug_mask;
+
+# ----------------------------------------------------- #
+# --- Final cleanup                                 --- #
+# ----------------------------------------------------- #
+DROP TABLE t1;
+DROP TABLE t2;

=== removed file 'mysql-test/suite/falcon/t/falcon_bug_28095_II-master.opt'
--- a/mysql-test/suite/falcon/t/falcon_bug_28095_II-master.opt	2008-03-28 17:13:51 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_28095_II-master.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---sql_mode=''

=== removed file 'mysql-test/suite/falcon/t/falcon_bug_28095_II.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_28095_II.test	2008-03-28 17:13:51 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_28095_II.test	1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
---source include/have_falcon.inc
-#
-# Mantis bug #126 second phase: Drop table causes crash
-# Mantis bug #123: Table cannot be read after restarting mysqld
-#
---echo *** Bug #126: Second phase ***
---echo *** Also test for bug #123 ***
-SET @@storage_engine = Falcon;
-
-SELECT * FROM t1;
-DROP TABLE t1, t2;

=== added file 'mysql-test/suite/falcon/t/falcon_bug_30124-big.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_30124-big.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_30124-big.test	2008-10-28 19:32:35 +0000
@@ -0,0 +1,73 @@
+--source include/have_falcon.inc
+--source include/big_test.inc
+
+#
+# Bug #30124: UPDATE has unacceptable performance
+#
+#    This update should take just a few seconds.
+#    It must unlock 900,000 records after updating only 100,000.
+#    With the bug, it took 30 to 60 minutes.
+#    It takes a while to build the file though.
+#
+--echo *** Bug #30124 ***
+
+# ----------------------------------------------------- #
+# --- Initialisation                                --- #
+# ----------------------------------------------------- #
+let $engine = 'Falcon';
+eval SET @@storage_engine = $engine;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+SET @@autocommit=0;
+
+CREATE TABLE t1 (a int auto_increment PRIMARY KEY, b int);
+
+PREPARE stmt1 FROM 'INSERT INTO t1 (b) VALUES (?)';
+
+DELIMITER //;
+CREATE PROCEDURE p1()
+BEGIN
+  SET @i = 0;
+  SET @v = 0;
+
+  WHILE @i < 1000000 DO
+    SET @a = @v;
+
+    EXECUTE stmt1 USING @a;
+
+    SET @v = @v + 1;
+    IF @v = 10 THEN
+      SET @v = 0;
+    END IF;
+
+    SET @i = @i + 1;
+  END WHILE;
+END;//
+DELIMITER ;//
+
+CALL p1;
+COMMIT;
+
+# ----------------------------------------------------- #
+# --- Test                                          --- #
+# ----------------------------------------------------- #
+SET @@autocommit = 1;
+UPDATE t1 SET b = 5 WHERE b = 3;
+
+# ----------------------------------------------------- #
+# --- Check                                         --- #
+# ----------------------------------------------------- #
+SELECT count(*) FROM t1;
+SELECT count(*) FROM t1 WHERE b = 5;
+
+
+# ----------------------------------------------------- #
+# --- Final cleanup                                 --- #
+# ----------------------------------------------------- #
+DEALLOCATE PREPARE stmt1;
+DROP TABLE t1;
+DROP PROCEDURE p1;

=== modified file 'mysql-test/suite/falcon/t/falcon_bug_30124.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_30124.test	2007-09-29 04:30:42 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_30124.test	2008-10-28 19:32:35 +0000
@@ -1,14 +1,15 @@
 --source include/have_falcon.inc
+
 #
 # Bug #30124: UPDATE has unacceptable performance
 #
-# This update should take just a few seconds.
-# It must unlock 900,000 records after updating only 100,000.
-# With the bug, it took 30 to 60 minutes.
-# It takes a while to build the file though.
+#    This update should take just a few seconds.
+#    It must unlock 900,000 records after updating only 100,000.
+#    With the bug, it took 30 to 60 minutes.
+#    It takes a while to build the file though.
 #
-# Note: original test case is with loop count of 1 mio.
-#       Lowered to 500k due to long run time.
+# Note: Original test case is with loop count of 1 mio.
+#       Lowered to 100k due to long run time on slow machines.
 --echo *** Bug #30124 ***
 
 # ----------------------------------------------------- #
@@ -34,7 +35,7 @@ BEGIN
   SET @i = 0;
   SET @v = 0;
 
-  WHILE @i < 500000 DO
+  WHILE @i < 100000 DO
     SET @a = @v;
 
     EXECUTE stmt1 USING @a;

=== added file 'mysql-test/suite/falcon/t/falcon_bug_38186.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_38186.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_38186.test	2008-10-31 00:29:13 +0000
@@ -0,0 +1,29 @@
+--source include/have_falcon.inc
+#
+# Bug #38186: 
+# CREATE TABLESPACE can fail when invoked immediately following a
+# DROP TABLESPACE statement that used the same tablespace name.
+#
+--echo *** Bug #38186 ***
+
+# ----------------------------------------------------- #
+# --- Initialisation                                --- #
+# ----------------------------------------------------- #
+let $engine = 'Falcon';
+eval SET @@storage_engine = $engine;
+# ----------------------------------------------------- #
+# --- Test                                          --- #
+# ----------------------------------------------------- #
+--disable_query_log
+let $i = 100;
+while($i)
+{
+  eval CREATE TABLESPACE ts ADD DATAFILE 'file.fts' ENGINE = $engine;
+  CREATE TABLE t(i int) TABLESPACE ts;
+  INSERT INTO t values(1);
+  DROP TABLE t;
+  eval DROP TABLESPACE ts ENGINE= $engine;
+  dec $i;
+}
+--enable_query_log
+

=== added file 'mysql-test/suite/falcon/t/falcon_bug_39708-master.opt'
--- a/mysql-test/suite/falcon/t/falcon_bug_39708-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_39708-master.opt	2008-10-29 11:41:14 +0000
@@ -0,0 +1 @@
+--falcon-page-size=2k

=== added file 'mysql-test/suite/falcon/t/falcon_bug_39708.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_39708.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_39708.test	2008-10-29 11:41:14 +0000
@@ -0,0 +1,5 @@
+--source include/have_falcon.inc
+
+--error ER_TOO_LONG_KEY
+CREATE TABLE t1(a VARCHAR(140) CHARACTER SET utf8, KEY(a)) ENGINE=falcon;
+SHOW WARNINGS;

=== added file 'mysql-test/suite/falcon/t/falcon_bug_40130.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_40130.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_40130.test	2008-11-05 15:04:45 +0000
@@ -0,0 +1,333 @@
+--source include/have_falcon.inc
+
+#
+# Bug #40130: Falcon date / time indexes broken
+#
+--echo *** Bug #40130 ***
+
+# ----------------------------------------------------- #
+# --- Initialisation                                --- #
+# ----------------------------------------------------- #

+let $engine = 'Falcon';
+eval SET @@storage_engine = $engine;
+
+--disable_warnings
+DROP TABLE IF EXISTS table10;
+--enable_warnings
+
+# ----------------------------------------------------- #
+# --- Test                                          --- #
+# ----------------------------------------------------- #
+
+CREATE TABLE table10 (`time_key` time, key (`time_key` ));
+INSERT INTO table10 VALUES ('23:43:55');
+INSERT INTO table10 VALUES ('03:18:59');
+INSERT INTO table10 VALUES ('05:05:23');
+INSERT INTO table10 VALUES ('09:20:40');
+INSERT INTO table10 VALUES ('22:32:50');
+INSERT INTO table10 VALUES ('07:41:31');
+INSERT INTO table10 VALUES ('10:52:13');
+INSERT INTO table10 VALUES ('12:40:54');
+INSERT INTO table10 VALUES ('10:33:25');
+INSERT INTO table10 VALUES ('22:11:46');
+
+SET AUTOCOMMIT=OFF;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '09:11:23' WHERE `time_key` < '16:23:56'; 
+INSERT INTO table10 VALUES ( '20:25:18' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '10:33:25' WHERE `time_key` > '22:11:46'; 
+INSERT INTO table10 VALUES ( '17:58:48' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '00:16:10' ); 
+UPDATE table10 SET `time_key` = '16:05:35' WHERE `time_key` > '16:57:24'; 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '20:24:01' ); 
+INSERT INTO table10 VALUES ( '18:37:59' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '21:05:17' WHERE `time_key` < '06:07:07'; 
+INSERT INTO table10 VALUES ( '00:05:40' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '13:34:36' ); 
+INSERT INTO table10 VALUES ( '22:35:15' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '09:32:02' ); 
+INSERT INTO table10 VALUES ( '12:02:39' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '19:22:23' WHERE `time_key` < '03:39:55'; 
+UPDATE table10 SET `time_key` = '13:45:38' WHERE `time_key` < '03:52:41'; 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '21:57:00' WHERE `time_key` < '11:37:04'; 
+INSERT INTO table10 VALUES ( '18:56:03' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '21:46:34' ); 
+INSERT INTO table10 VALUES ( '00:46:37' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '11:54:45' ); 
+INSERT INTO table10 VALUES ( '11:00:16' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '04:41:27' WHERE `time_key` > '05:45:30'; 
+INSERT INTO table10 VALUES ( '05:55:02' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '02:51:17' WHERE `time_key` < '05:33:58'; 
+INSERT INTO table10 VALUES ( '06:07:14' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '19:17:13' ); 
+UPDATE table10 SET `time_key` = '14:23:25' WHERE `time_key` < '18:44:25'; 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '01:54:06' ); 
+INSERT INTO table10 VALUES ( '05:36:42' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '04:04:15' WHERE `time_key` < '17:09:11'; 
+INSERT INTO table10 VALUES ( '13:22:58' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '03:45:01' WHERE `time_key` < '01:02:29'; 
+INSERT INTO table10 VALUES ( '14:45:34' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '12:33:12' ); 
+INSERT INTO table10 VALUES ( '21:40:27' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '05:05:45' ); 
+INSERT INTO table10 VALUES ( '01:21:15' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '01:43:44' WHERE `time_key` > '18:44:54'; 
+UPDATE table10 SET `time_key` = '16:00:25' WHERE `time_key` > '17:37:45'; 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '09:17:29' ); 
+UPDATE table10 SET `time_key` = '00:32:27' WHERE `time_key` < '19:55:22'; 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '00:01:27' WHERE `time_key` < '23:49:20'; 
+INSERT INTO table10 VALUES ( '11:10:06' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '21:52:14' WHERE `time_key` > '00:54:57'; 
+INSERT INTO table10 VALUES ( '10:32:20' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '05:48:51' WHERE `time_key` < '05:53:48'; 
+UPDATE table10 SET `time_key` = '04:11:47' WHERE `time_key` > '14:02:03'; 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '20:58:47' ); 
+INSERT INTO table10 VALUES ( '06:58:04' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '14:41:45' ); 
+UPDATE table10 SET `time_key` = '00:45:47' WHERE `time_key` < '21:51:00'; 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '09:01:24' ); 
+INSERT INTO table10 VALUES ( '07:07:37' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '06:25:00' ); 
+INSERT INTO table10 VALUES ( '05:47:01' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '12:31:51' WHERE `time_key` > '04:34:05'; 
+INSERT INTO table10 VALUES ( '01:31:26' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '01:46:22' ); 
+INSERT INTO table10 VALUES ( '01:14:58' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '04:09:31' ); 
+UPDATE table10 SET `time_key` = '08:28:13' WHERE `time_key` > '14:50:18'; 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '11:19:43' WHERE `time_key` < '04:30:14'; 
+INSERT INTO table10 VALUES ( '20:03:24' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '14:40:32' WHERE `time_key` < '15:30:08'; 
+UPDATE table10 SET `time_key` = '03:13:02' WHERE `time_key` < '21:47:42'; 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '20:37:56' ); 
+UPDATE table10 SET `time_key` = '15:51:19' WHERE `time_key` < '01:39:43'; 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '07:15:18' WHERE `time_key` > '05:37:40'; 
+INSERT INTO table10 VALUES ( '18:47:30' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '13:32:24' WHERE `time_key` > '23:38:12'; 
+INSERT INTO table10 VALUES ( '23:32:39' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '22:01:18' WHERE `time_key` < '17:51:48'; 
+INSERT INTO table10 VALUES ( '11:41:29' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '15:45:55' WHERE `time_key` > '04:03:52'; 
+UPDATE table10 SET `time_key` = '05:43:47' WHERE `time_key` < '07:29:01'; 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '23:44:48' WHERE `time_key` < '00:33:42'; 
+UPDATE table10 SET `time_key` = '08:56:04' WHERE `time_key` > '12:16:41'; 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '19:23:41' ); 
+INSERT INTO table10 VALUES ( '18:44:20' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '00:40:04' WHERE `time_key` > '11:34:06'; 
+UPDATE table10 SET `time_key` = '23:45:59' WHERE `time_key` < '09:44:50'; 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '18:54:59' WHERE `time_key` < '15:46:02'; 
+INSERT INTO table10 VALUES ( '17:37:41' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '17:08:04' WHERE `time_key` < '14:11:50'; 
+UPDATE table10 SET `time_key` = '21:33:59' WHERE `time_key` > '17:44:43'; 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '03:50:15' WHERE `time_key` > '19:35:18'; 
+UPDATE table10 SET `time_key` = '23:15:47' WHERE `time_key` < '12:18:46'; 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '22:50:01' ); 
+INSERT INTO table10 VALUES ( '17:29:53' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '21:33:30' ); 
+INSERT INTO table10 VALUES ( '06:27:52' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '07:49:31' ); 
+INSERT INTO table10 VALUES ( '21:31:25' );
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '13:50:22' ); 
+INSERT INTO table10 VALUES ( '15:13:07' ); 
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '14:06:24' ); 
+INSERT INTO table10 VALUES ( '19:10:11' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '05:03:39' WHERE `time_key` > '11:46:31'; 
+INSERT INTO table10 VALUES ( '04:35:34' );
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '14:37:01' WHERE `time_key` < '02:11:03'; 
+INSERT INTO table10 VALUES ( '10:52:22' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '15:37:40' WHERE `time_key` > '11:19:00'; 
+INSERT INTO table10 VALUES ( '08:46:29' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '07:59:59' WHERE `time_key` < '05:27:20'; 
+UPDATE table10 SET `time_key` = '00:45:15' WHERE `time_key` < '20:07:08';
+COMMIT;
+
+START TRANSACTION; 
+INSERT INTO table10 VALUES ( '00:51:31' ); 
+UPDATE table10 SET `time_key` = '10:00:58' WHERE `time_key` < '16:41:45'; 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '13:49:37' WHERE `time_key` > '10:40:48'; 
+INSERT INTO table10 VALUES ( '05:16:25' ); 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '14:46:15' WHERE `time_key` < '12:48:22'; 
+UPDATE table10 SET `time_key` = '05:50:46' WHERE `time_key` < '07:58:43'; 
+COMMIT;
+
+START TRANSACTION; 
+UPDATE table10 SET `time_key` = '00:11:06' WHERE `time_key` < '16:39:47'; 
+UPDATE table10 SET `time_key` = '04:13:41' WHERE `time_key` < '14:55:39'; 
+COMMIT;
+
+SELECT * FROM table10;
+
+START TRANSACTION;
+UPDATE table10 SET `time_key` = '00:28:04' WHERE `time_key` < '09:58:46'; 
+UPDATE table10 SET `time_key` = '04:56:25' WHERE `time_key` > '09:26:08'; 
+COMMIT;
+
+SELECT * FROM table10;
+
+# ----------------------------------------------------- #
+# --- Final cleanup                                 --- #
+# ----------------------------------------------------- #
+DROP TABLE table10;

=== added file 'mysql-test/suite/falcon/t/falcon_bug_40158.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_40158.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_40158.test	2008-11-05 14:51:37 +0000
@@ -0,0 +1,50 @@
+--source include/have_falcon.inc
+
+#
+# Bug #40158: Falcon assertion in StorageInterface::encodeRecord() line 2635 on CREATE TABLE
+#
+--echo *** Bug #40158 ***
+
+# ----------------------------------------------------- #
+# --- Initialisation                                --- #
+# ----------------------------------------------------- #
+let $engine = 'Falcon';
+eval SET @@storage_engine = $engine;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# ----------------------------------------------------- #
+# --- Test                                          --- #
+# ----------------------------------------------------- #
+
+CREATE TABLE t1 (`"strangename"` int);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+SELECT `"strangename"` FROM t1;
+DROP TABLE t1;
+
+SET LOCAL SQL_MODE=ANSI_QUOTES;
+
+CREATE TABLE t1 ("""strangename""" int);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+SELECT """strangename""" FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (`""strangename""` int);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+SELECT `""strangename""` FROM t1;
+
+# ----------------------------------------------------- #
+# --- Check                                         --- #
+# ----------------------------------------------------- #
+
+SELECT COUNT(*) FROM t1;
+
+# ----------------------------------------------------- #
+# --- Final cleanup                                 --- #
+# ----------------------------------------------------- #
+DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_backup.result'
--- a/mysql-test/suite/rpl/r/rpl_backup.result	2008-10-31 15:31:52 +0000
+++ b/mysql-test/suite/rpl/r/rpl_backup.result	2008-11-17 09:57:51 +0000
@@ -169,7 +169,7 @@ CREATE TABLE rpl_backup.t2 (b int);
 INSERT INTO rpl_backup.t2 VALUES (888), (999);
 Get master's binlog position before restore.
 Backup_id = 502.
-RESTORE FROM 'rpl_bup_m2.bak';
+RESTORE FROM 'rpl_bup_m2.bak' OVERWRITE;
 backup_id
 502
 Show the incident event issued as a result of restore.
@@ -241,7 +241,7 @@ t1	BASE TABLE
 t2	BASE TABLE
 STOP SLAVE;
 Backup_id = 602.
-RESTORE FROM '../master-data/rpl_bup_m2.bak';
+RESTORE FROM '../master-data/rpl_bup_m2.bak' OVERWRITE;
 backup_id
 602
 Showing databases on slave.
@@ -258,11 +258,11 @@ BACKUP DATABASE rpl_backup TO 'rpl_bup_s
 backup_id
 603
 Test restore on slave while replication turned on.
-RESTORE FROM 'rpl_bup_s1.bak';
+RESTORE FROM 'rpl_bup_s1.bak' OVERWRITE;
 ERROR HY000: A restore operation was attempted on a slave during replication. You must stop the slave prior to running a restore.
 Stop slave and restart after restore.
 STOP SLAVE;
-RESTORE FROM 'rpl_bup_s3.bak';
+RESTORE FROM 'rpl_bup_s3.bak' OVERWRITE;
 backup_id
 #
 START SLAVE;
@@ -312,7 +312,7 @@ sql_log_bin	ON
 RESET MASTER;
 Get master's binlog position before restore.
 Backup_id = 504.
-RESTORE FROM 'rpl_bup_m3.bak';
+RESTORE FROM 'rpl_bup_m3.bak' OVERWRITE;
 backup_id
 504
 Get master's binlog position after restore.

=== modified file 'mysql-test/suite/rpl/t/rpl_backup.test'
--- a/mysql-test/suite/rpl/t/rpl_backup.test	2008-10-31 15:31:52 +0000
+++ b/mysql-test/suite/rpl/t/rpl_backup.test	2008-11-17 09:57:51 +0000
@@ -209,7 +209,7 @@ INSERT INTO rpl_backup.t2 VALUES (888), 
 let $master_before_pos = query_get_value("SHOW MASTER STATUS", Position, 1);
 
 --echo Backup_id = 502.
-RESTORE FROM 'rpl_bup_m2.bak';
+RESTORE FROM 'rpl_bup_m2.bak' OVERWRITE;
 
 --echo Show the incident event issued as a result of restore.
 --replace_column 2 # 5 #
@@ -266,7 +266,7 @@ STOP SLAVE;
 --source include/wait_for_slave_to_stop.inc
 
 --echo Backup_id = 602.
-RESTORE FROM '../master-data/rpl_bup_m2.bak';
+RESTORE FROM '../master-data/rpl_bup_m2.bak' OVERWRITE;
 
 --echo Showing databases on slave.
 SHOW DATABASES LIKE 'rpl_backup%';
@@ -289,13 +289,13 @@ connection slave;
 --echo Test restore on slave while replication turned on.
 
 --error ER_RESTORE_ON_SLAVE
-RESTORE FROM 'rpl_bup_s1.bak';
+RESTORE FROM 'rpl_bup_s1.bak' OVERWRITE;
 
 --echo Stop slave and restart after restore.
 STOP SLAVE;
 
 --replace_column 1 #
-RESTORE FROM 'rpl_bup_s3.bak';
+RESTORE FROM 'rpl_bup_s3.bak' OVERWRITE;
 
 START SLAVE;
 --source include/wait_for_slave_to_start.inc
@@ -354,7 +354,7 @@ RESET MASTER;
 let $master_before_pos = query_get_value("SHOW MASTER STATUS", Position, 1);
 
 --echo Backup_id = 504.
-RESTORE FROM 'rpl_bup_m3.bak';
+RESTORE FROM 'rpl_bup_m3.bak' OVERWRITE;
 
 --echo Get master's binlog position after restore.
 let $master_after_pos = query_get_value("SHOW MASTER STATUS", Position, 1);

=== added file 'mysql-test/suite/sys_vars/t/disabled.def'
--- a/mysql-test/suite/sys_vars/t/disabled.def	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/disabled.def	2008-11-26 15:16:58 +0000
@@ -0,0 +1,21 @@
+##############################################################################
+#
+#  List the test cases that are to be disabled temporarily.
+#
+#  Separate the test case name and the comment with ':'.
+#
+#    <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
+#
+#  Do not use any TAB characters for whitespace.
+#
+##############################################################################
+key_buffer_size_basic_64    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+rpl_recovery_rank_basic_64  : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+sort_buffer_size_basic_64   : Bug #36522: Some tests of system variables have diffs on 64bit platorms
+query_cache_size_basic_32   : Bug#36747: Allocating a large query cache is not deterministic
+query_cache_size_basic_64   : Bug#36747: Allocating a large query cache is not deterministic
+query_alloc_block_size_basic_64:  Bug #37708 query_alloc_block_size_basic_64 fails in pushbuild
+sort_buffer_size_basic_32   : Bug#36875 main.sort_buffer_size_basic_32 fails on some systems
+key_buffer_size_basic_32    : Bug#36876 main.key_buffer_size_basic_32 fails on some systems
+max_heap_table_size_basic_32 : Bug#36877 main.max_heap_table_size_basic_32 fails on some systems
+tmp_table_size_basic_32     : Bug#36878 main.tmp_table_size_basic_32 fails on some systems

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2008-11-07 11:45:16 +0000
+++ b/mysql-test/t/disabled.def	2008-11-26 15:16:58 +0000
@@ -9,32 +9,14 @@
 #  Do not use any TAB characters for whitespace.
 #
 ##############################################################################
-innodb          : WL#1213: Waiting for InnoDB team to add support for 4-byte character sets.
-concurrent_innodb        : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences
 federated_transactions   : Bug#29523 Transactions do not work
 show_check      : Bug #32682    Test show_check fails in 6.0
 lowercase_table3         : Bug#32667 lowercase_table3.test reports to error log
-rpl_log_pos          : Bug#8693 Test 'rpl_log_pos' fails sometimes
 ctype_create         : Bug#32965 main.ctype_create fails
-backup_no_engine     : Bug#36021 2008-04-13 rsomla server crashes when openning table with unknown storage engine
 csv_alter_table      : Bug#33696 2008-01-21 pcrews no .result file - bug allows NULL columns in CSV tables
-query_cache_wlock_invalidate_func: Bug#35390 causes not deterministic results.
 cast                 : Bug#35594 2008-03-27 main.cast fails on Windows2003-64
-maria-preload        : Bug#35107 crashes
-key_buffer_size_basic_64    : Bug #36522: Some tests of system variables have diffs on 64bit platorms
-rpl_recovery_rank_basic_64  : Bug #36522: Some tests of system variables have diffs on 64bit platorms
-sort_buffer_size_basic_64   : Bug #36522: Some tests of system variables have diffs on 64bit platorms
-log_output_basic      : Bug#34820 log_output can be set to illegal value
-query_cache_size_basic_32   : Bug#36747: Allocating a large query cache is not deterministic
-query_cache_size_basic_64   : Bug#36747: Allocating a large query cache is not deterministic
-query_alloc_block_size_basic_64:  Bug #37708 query_alloc_block_size_basic_64 fails in pushbuild
 wait_timeout_func           : Bug #36873 wait_timeout_func.test fails randomly
 timestamp_func              : Bug #37702 timestamp_func relies on sleep and is unstable in pushbuild
-sort_buffer_size_basic_32   : Bug#36875 main.sort_buffer_size_basic_32 fails on some systems
-key_buffer_size_basic_32    : Bug#36876 main.key_buffer_size_basic_32 fails on some systems
-max_heap_table_size_basic_32 : Bug#36877 main.max_heap_table_size_basic_32 fails on some systems
-tmp_table_size_basic_32     : Bug#36878 main.tmp_table_size_basic_32 fails on some systems
-backup_triggers_and_events  : Bug#37762 2008-07-01 rafal Test fails on remove_file for unknown reasons
-backup_no_be                : Bug#38023 2008-07-16 rafal Test triggers valgrind warnings described in the bug
-user_limits                 : Bug#23921 2008-07-25 joro random failure of user_limits.test
 thread_cache_size_func      : Bug#40574 2008-11-07 joro main.thread_cache_size_func fails in pushbuild when run with pool of threads
+log_output_basic     : Bug #40988       log_output_basic.test succeeded though syntactically false.
+innodb               : Bug #41056    Innodb.test shows some difference to its result file.

=== modified file 'mysql-test/t/implicit_commit.test'
--- a/mysql-test/t/implicit_commit.test	2008-07-27 13:14:46 +0000
+++ b/mysql-test/t/implicit_commit.test	2008-11-20 14:03:27 +0000
@@ -1136,7 +1136,7 @@ source include/implicit_commit_helper.in
 --echo #
 
 let $statement=
-  restore from 'backup_db1.ba';
+  restore from 'backup_db1.ba' overwrite;
 source include/implicit_commit_helper.inc;
 
 --remove_file $MYSQLTEST_VARDIR/master-data/backup_db1.ba

=== modified file 'sql/backup/backup_info.h'
--- a/sql/backup/backup_info.h	2008-10-27 13:06:21 +0000
+++ b/sql/backup/backup_info.h	2008-11-13 13:02:36 +0000
@@ -48,6 +48,10 @@ class Backup_info: public backup::Image_
 
  private:
 
+  // Prevent copying/assignments
+  Backup_info(const Backup_info&);
+  Backup_info& operator=(const Backup_info&);
+
   class Global_iterator; ///< Iterates over global items (for which meta-data is stored).
   class Perdb_iterator;  ///< Iterates over all per-database objects (except tables).
 

=== modified file 'sql/backup/backup_kernel.h'
--- a/sql/backup/backup_kernel.h	2008-10-30 17:53:24 +0000
+++ b/sql/backup/backup_kernel.h	2008-11-17 09:57:51 +0000
@@ -30,7 +30,7 @@ void backup_shutdown();
   Called from the big switch in mysql_execute_command() to execute
   backup related statement
 */
-int execute_backup_command(THD*, LEX*, String*);
+int execute_backup_command(THD*, LEX*, String*, bool);
 
 // forward declarations
 
@@ -74,7 +74,7 @@ class Backup_restore_ctx: public backup:
                                    const char*);  
 
   int do_backup();
-  int do_restore();
+  int do_restore(bool overwrite);
   int fatal_error(int, ...);
   int log_error(int, ...);
 
@@ -84,6 +84,10 @@ class Backup_restore_ctx: public backup:
 
  private:
 
+  // Prevent copying/assignments
+  Backup_restore_ctx(const Backup_restore_ctx&);
+  Backup_restore_ctx& operator=(const Backup_restore_ctx&);
+
   /** @c current_op points to the @c Backup_restore_ctx for the
       ongoing backup/restore operation.  If pointer is null, no
       operation is currently running. */

=== modified file 'sql/backup/be_thread.cc'
--- a/sql/backup/be_thread.cc	2008-10-30 12:29:54 +0000
+++ b/sql/backup/be_thread.cc	2008-12-05 22:05:20 +0000
@@ -109,10 +109,7 @@ pthread_handler_t backup_thread_for_lock
     Turn off condition variable check for lock.
   */
   locking_thd->lock_state= LOCK_NOT_STARTED;
-
-#if !defined( __WIN__) /* Win32 calls this in pthread_create */
   my_thread_init();
-#endif
 
   /*
     First, create a new THD object.

=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc	2008-11-13 08:40:43 +0000
+++ b/sql/backup/kernel.cc	2008-11-20 13:53:41 +0000
@@ -121,6 +121,8 @@ static int send_reply(Backup_restore_ctx
   @param[IN] thd        current thread object reference.
   @param[IN] lex        results of parsing the statement.
   @param[IN] backupdir  value of the backupdir variable from server.
+  @param[IN] overwrite  whether or not restore should overwrite existing
+                        DB with same name as in backup image
 
   @note This function sends response to the client (ok, result set or error).
 
@@ -132,7 +134,7 @@ static int send_reply(Backup_restore_ctx
  */
 
 int
-execute_backup_command(THD *thd, LEX *lex, String *backupdir)
+execute_backup_command(THD *thd, LEX *lex, String *backupdir, bool overwrite)
 {
   int res= 0;
   
@@ -226,7 +228,7 @@ execute_backup_command(THD *thd, LEX *le
     
     DEBUG_SYNC(thd, "after_backup_start_restore");
 
-    res= context.do_restore();      
+    res= context.do_restore(overwrite);      
 
     DEBUG_SYNC(thd, "restore_before_end");
 
@@ -331,7 +333,6 @@ int send_reply(Backup_restore_ctx &conte
     goto err;
   }
   my_eof(context.thd());                        // Never errors
-  context.report_cleanup();                     // Never errors
   DBUG_RETURN(0);
 
  err:
@@ -399,7 +400,7 @@ Backup_restore_ctx::Backup_restore_ctx(T
 Backup_restore_ctx::~Backup_restore_ctx()
 {
   close();
-  
+
   delete mem_alloc;
   delete m_catalog;  
   delete m_stream;
@@ -1199,11 +1200,14 @@ int Backup_restore_ctx::restore_triggers
 
   @pre @c prepare_for_restore() method was called.
 
+  @param[IN] overwrite whether or not restore should overwrite existing
+                       DB with same name as in backup image
+
   @returns 0 on success, error code otherwise.
 
   @todo Remove the @c reset_diagnostic_area() hack.
 */
-int Backup_restore_ctx::do_restore()
+int Backup_restore_ctx::do_restore(bool overwrite)
 {
   DBUG_ENTER("do_restore");
 
@@ -1223,6 +1227,24 @@ int Backup_restore_ctx::do_restore()
 
   DBUG_PRINT("restore", ("Restoring meta-data"));
 
+  // unless RESTORE... OVERWRITE: return error if database already exists
+  if (!overwrite) {
+    Image_info::Db_iterator *dbit= info.get_dbs();
+
+    if (!dbit) {
+      DBUG_RETURN(fatal_error(ER_OUT_OF_RESOURCES));
+    }
+
+    Image_info::Db *mydb;
+    while ((mydb= static_cast<Image_info::Db*>((*dbit)++))) {
+      if (!obs::check_db_existence(&mydb->name())) {
+        delete dbit;
+        DBUG_RETURN(fatal_error(ER_RESTORE_DB_EXISTS, mydb->name().ptr()));
+      }
+    }
+    delete dbit;
+  }
+
   disable_fkey_constraints();                   // Never errors
 
   if (read_meta_data(info, s))
@@ -1971,6 +1993,7 @@ int bcat_create_item(st_bstream_image_he
     {
       DBUG_PRINT("restore",(" tablespace has changed on the server - aborting"));
       info->m_ctx.fatal_error(ER_BACKUP_TS_CHANGE, desc);
+      delete ts;
       return BSTREAM_ERROR;
     }
   }

=== modified file 'sql/backup/logger.h'
--- a/sql/backup/logger.h	2008-11-13 08:40:43 +0000
+++ b/sql/backup/logger.h	2008-11-14 15:02:10 +0000
@@ -67,7 +67,6 @@ class Logger
      DBUG_ASSERT(backup_log);
      return backup_log->get_backup_id(); 
    }
-   void report_cleanup() { delete backup_log; }
    
    void save_errors();
    void stop_save_errors();
@@ -85,6 +84,10 @@ class Logger
   int write_message(log_level::value level , int error_code, const char *msg);
 
  private:
+  // Prevent copying/assigments
+  Logger(const Logger&);
+  Logger& operator=(const Logger&);
+
   util::SAVED_MYSQL_ERROR error;   ///< Used to store saved errors.
   bool m_save_errors;        ///< Flag telling if errors should be saved.
   bool m_push_errors;        ///< Should errors be pushed on warning stack?
@@ -96,12 +99,16 @@ inline
 Logger::Logger(THD *thd) 
   :m_type(BACKUP), m_state(CREATED),
    m_thd(thd), m_save_errors(FALSE), m_push_errors(TRUE), backup_log(0)
-{}
+{
+  clear_saved_errors();
+}
+ 
 
 inline
 Logger::~Logger()
 {
   clear_saved_errors();
+  delete backup_log;
 }
 
 /// Report unregistered message.

=== modified file 'sql/backup/restore_info.h'
--- a/sql/backup/restore_info.h	2008-05-05 15:06:40 +0000
+++ b/sql/backup/restore_info.h	2008-11-13 13:02:36 +0000
@@ -47,6 +47,10 @@ class Restore_info: public backup::Image
 
  private:
 
+  // Prevent copying/assignments
+  Restore_info(const Restore_info&);
+  Restore_info& operator=(const Restore_info&);
+
   friend int backup::restore_table_data(THD*, Restore_info&, 
                                         backup::Input_stream&);
   friend int ::bcat_add_item(st_bstream_image_header*,

=== modified file 'sql/backup/stream.h'
--- a/sql/backup/stream.h	2008-10-15 20:00:48 +0000
+++ b/sql/backup/stream.h	2008-11-13 13:02:36 +0000
@@ -98,7 +98,7 @@ class Stream: public fd_stream
   ::String  *m_path;
   int     m_flags;  ///< flags used when opening the file
   size_t  m_block_size;
-  Logger  m_log;
+  Logger&  m_log;
 
   friend int stream_write(void*, bstream_blob*, bstream_blob);
   friend int stream_read(void*, bstream_blob*, bstream_blob);

=== modified file 'sql/backup/stream_v1.c'
--- a/sql/backup/stream_v1.c	2008-09-30 08:08:16 +0000
+++ b/sql/backup/stream_v1.c	2008-11-13 13:02:36 +0000
@@ -1277,10 +1277,9 @@ int bstream_wr_meta_data(backup_stream *
     CHECK_WR_RES(bstream_wr_item_def(s,cat,PER_TABLE_ITEM,item));
   }
 
+wr_error:
   bcat_iterator_free(cat,iter);
 
-  wr_error:
-
   return ret;
 }
 

=== modified file 'sql/lex.h'
--- a/sql/lex.h	2008-07-09 07:12:43 +0000
+++ b/sql/lex.h	2008-11-17 09:57:51 +0000
@@ -389,6 +389,7 @@ static SYMBOL symbols[] = {
   { "OUT",              SYM(OUT_SYM)},
   { "OUTER",		SYM(OUTER)},
   { "OUTFILE",		SYM(OUTFILE)},
+  { "OVERWRITE",		SYM(OVERWRITE_SYM)},
   { "OWNER",		SYM(OWNER_SYM)},
   { "PACK_KEYS",	SYM(PACK_KEYS_SYM)},
   { "PARSER",           SYM(PARSER_SYM)},

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2008-11-24 15:30:37 +0000
+++ b/sql/mysqld.cc	2008-12-05 22:15:43 +0000
@@ -8258,7 +8258,7 @@ mysqld_get_one_option(int optid,
   {
     if (!argument || !argument[0])
     {
-      log_backup_output_options= LOG_FILE;
+      log_backup_output_options= LOG_TABLE;
       log_backup_output_str= log_output_typelib.type_names[1];
     }
     else

=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt	2008-11-13 08:40:43 +0000
+++ b/sql/share/errmsg.txt	2008-11-19 22:08:05 +0000
@@ -6423,7 +6423,7 @@ ER_BACKUP_PURGE_DATETIME
 ER_BACKUP_LOGS_DELETED
   eng "Backup log entries deleted: "
 ER_BACKUP_LOGS_TRUNCATED
-  eng "All backup logs entries have been deleted"
+  eng "All backup log entries have been deleted"
 ER_MASTER_BLOCKING_SLAVES
   eng "The master is not allowing slave connections."
 ER_RESTORE_ON_MASTER
@@ -6432,6 +6432,7 @@ ER_RESTORE_ON_SLAVE
   eng "A restore operation was attempted on a slave during replication. You must stop the slave prior to running a restore."
 ER_NONUNIQ_DB 42000 S1009
         eng "Not unique database: '%-.192s'"
+ER_RESTORE_DB_EXISTS
+  eng "Database \'%-.64s\' already exists. Use OVERWRITE flag to overwrite."
 ER_QUERY_CACHE_DISABLED
 	eng "Query cache is disabled; restart the server with query_cache_type=1 to enable it"
-

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-11-13 08:40:43 +0000
+++ b/sql/sql_parse.cc	2008-11-17 09:57:51 +0000
@@ -43,7 +43,7 @@
   @defgroup Runtime_Environment Runtime Environment
   @{
 */
-int execute_backup_command(THD*, LEX*, String*);
+int execute_backup_command(THD*, LEX*, String*, bool);
 
 /* Used in error handling only */
 #define SP_TYPE_STRING(LP) \
@@ -2312,11 +2312,29 @@ mysql_execute_command(THD *thd)
                         sys_var_backupdir.value_length);
     backupdir.length(sys_var_backupdir.value_length);
 
+    /* Used to specify if RESTORE should overwrite existing db with same name */
+    bool overwrite_restore= false;
+
+    Item *it= (Item *)lex->value_list.head();
+
+    // Item only set for RESTORE in sql_yacc.yy, no error checking of
+    // item necessary
+    if (it)
+    {
+      /*
+        it is OK to only emulate fix_fields, because we need only
+        value of constant
+      */
+      it->quick_fix_field();
+
+      if ((int8)it->val_int() == 1)
+        overwrite_restore= true;
+    }
     /*
       Note: execute_backup_command() sends a correct response to the client
       (either ok, result set or error message).
      */ 
-    if (execute_backup_command(thd, lex, &backupdir))
+    if (execute_backup_command(thd, lex, &backupdir, overwrite_restore))
       goto error;
     break;
   }

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2008-11-13 08:40:43 +0000
+++ b/sql/sql_yacc.yy	2008-11-17 09:57:51 +0000
@@ -974,6 +974,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  OUTER
 %token  OUTFILE
 %token  OUT_SYM                       /* SQL-2003-R */
+%token  OVERWRITE_SYM
 %token  OWNER_SYM
 %token  PACK_KEYS_SYM
 %token  PAGE_SYM
@@ -6433,12 +6434,32 @@ restore:
             lex->clear_db_list();
           }
           FROM
-          TEXT_STRING_sys
+          TEXT_STRING_sys 
+          opt_overwrite
           {
             Lex->backup_dir = $4; 
           }
         ;
 
+opt_overwrite:
+          /* empty */ 
+          {         
+            LEX *lex= Lex;
+            Item *it= new Item_int((int8) 0);
+
+            lex->value_list.empty();
+            lex->value_list.push_front(it);
+          }
+        | OVERWRITE_SYM 
+          {
+            LEX *lex= Lex;
+            Item *it= new Item_int((int8) 1);
+
+            lex->value_list.empty();
+            lex->value_list.push_front(it);
+           }
+         ;
+
 backup:   
           BACKUP_SYM 
           {

=== modified file 'storage/falcon/BlobReference.cpp'
--- a/storage/falcon/BlobReference.cpp	2008-06-19 15:09:45 +0000
+++ b/storage/falcon/BlobReference.cpp	2008-10-31 15:42:42 +0000
@@ -157,5 +157,5 @@ int BlobReference::getReference(int size
 	for (n = 0; n < 64; n += 8)
 		*q++ = (UCHAR) (blobId >> n);
 
-	return q - buffer;
+	return (int)(q - buffer);
 }

=== modified file 'storage/falcon/Cache.cpp'
--- a/storage/falcon/Cache.cpp	2008-10-23 07:58:38 +0000
+++ b/storage/falcon/Cache.cpp	2008-10-31 15:42:42 +0000
@@ -102,6 +102,7 @@ Cache::Cache(Database *db, int pageSz, i
 	ioThreads = new Thread*[numberIoThreads];
 	memset(ioThreads, 0, numberIoThreads * sizeof(ioThreads[0]));
 	flushing = false;
+	recovering = false;
 	
 	try
 		{
@@ -221,6 +222,15 @@ Bdb* Cache::fetchPage(Dbb *dbb, int32 pa
 #endif
 
 	ASSERT (pageNumber >= 0);
+
+	if (recovering && pageType != PAGE_inventory &&
+		!PageInventoryPage::isPageInUse (dbb, pageNumber))
+		{
+		Log::debug ("During recovery, fetched page %d tablespace %d type %d marked free in PIP\n",
+			pageNumber, dbb->tableSpaceId, pageType);
+		PageInventoryPage::markPageInUse(dbb, pageNumber, 0);
+		}
+
 	int slot = pageNumber % hashSize;
 	LockType actual = lockType;
 	Sync sync (&syncObject, "Cache::fetchPage");
@@ -842,7 +852,7 @@ void Cache::ioThread(void)
 						
 					flushLock.unlock();
 					//Log::debug(" %d Writing %s %d pages: %d - %d\n", thread->threadId, (const char*) dbb->fileName, count, pageNumber, pageNumber + count - 1);
-					int length = p - buffer;
+					int length = (int)(p - buffer);
 					priority.schedule(PRIORITY_LOW);
 					
 					try

=== modified file 'storage/falcon/Cache.h'
--- a/storage/falcon/Cache.h	2008-10-02 22:15:11 +0000
+++ b/storage/falcon/Cache.h	2008-10-30 00:22:54 +0000
@@ -81,6 +81,7 @@ public:
 	int			numberBuffers;
 	bool		panicShutdown;
 	bool		flushing;
+	bool		recovering;
 
 protected:
 	Bdb*		findBuffer (Dbb *dbb, int pageNumber, LockType lockType);

=== modified file 'storage/falcon/CollationCaseless.cpp'
--- a/storage/falcon/CollationCaseless.cpp	2008-05-14 18:39:57 +0000
+++ b/storage/falcon/CollationCaseless.cpp	2008-10-31 15:42:42 +0000
@@ -98,7 +98,7 @@ int CollationCaseless::makeKey(Value *va
 	while (q > p && q [-1] == ' ')
 		--q;
 
-	l = q - p;
+	l = (int)(q - p);
 
 	for (int n = 0; n < l; ++n)
 		p [n] = caseTable [p [n]];

=== modified file 'storage/falcon/Database.cpp'
--- a/storage/falcon/Database.cpp	2008-10-23 07:58:38 +0000
+++ b/storage/falcon/Database.cpp	2008-10-29 23:25:13 +0000
@@ -1471,7 +1471,7 @@ void Database::truncateTable(Table *tabl
 	Sync syncDDLLock(&syncSysDDL, "Database::truncateTable(SysDDL)");
 	syncDDLLock.lock(Exclusive);
 	
-	// Lock syncScavenge before locking syncSysDDL, syncTables, or table->syncObject.
+	// Lock syncScavenge before locking syncTables, or table->syncObject.
 	// The scavenger locks syncScavenge  and then syncTables
 	// If we run out of record memory, forceRecordScavenge will eventually call table->syncObject.
 

=== modified file 'storage/falcon/DateTime.cpp'
--- a/storage/falcon/DateTime.cpp	2008-06-19 15:09:45 +0000
+++ b/storage/falcon/DateTime.cpp	2008-10-31 15:42:42 +0000
@@ -626,7 +626,7 @@ int DateTime::lookup(const char *string,
 
 	for (const char **tbl = table; *tbl; ++tbl)
 		if (match (temp, *tbl))
-			return tbl - table;
+			return (int)(tbl - table);
 
 	return -1;
 }
@@ -660,7 +660,7 @@ int DateTime::getString(int length, char
 			  time.tm_mon + 1, 
 			  time.tm_mday);
 
-	return strlen (buffer);
+	return (int)strlen(buffer);
 }
 
 
@@ -1056,7 +1056,7 @@ int DateTime::compare(DateTime when)
 
 DateTime DateTime::convert(const char *string)
 {
-	return convert (string, strlen (string));
+	return convert (string, (int)strlen (string));
 }
 
 const char* DateTime::getTimeZone()
@@ -1143,7 +1143,7 @@ int Time::getString(int length, char *bu
 			  time.tm_min, 
 			  time.tm_sec);
 
-	return strlen (buffer);
+	return (int)strlen (buffer);
 }
 
 const TimeZone* DateTime::findTimeZone(const char *string)

=== modified file 'storage/falcon/Dbb.cpp'
--- a/storage/falcon/Dbb.cpp	2008-10-16 02:53:35 +0000
+++ b/storage/falcon/Dbb.cpp	2008-10-30 00:22:54 +0000
@@ -1397,3 +1397,8 @@ void Dbb::updateSerialLogBlockSize(void)
 	header->serialLogBlockSize = database->serialLogBlockSize;
 	bdb->release(REL_HISTORY);
 }
+
+void Dbb::setCacheRecovering(bool state)
+{
+	cache->recovering = state;
+}

=== modified file 'storage/falcon/Dbb.h'
--- a/storage/falcon/Dbb.h	2008-07-24 08:45:03 +0000
+++ b/storage/falcon/Dbb.h	2008-10-30 00:22:54 +0000
@@ -184,6 +184,7 @@ public:
 	void	printPage(Bdb* bdb);
 	void	updateBlob(Section *blobSection, int recordNumber, Stream* blob, Transaction* transaction);
 	void	updateSerialLogBlockSize(void);
+	void	setCacheRecovering(bool state);
 	
 	Cache		*cache;
 	Database	*database;

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

=== modified file 'storage/falcon/DeferredIndexWalker.cpp'
--- a/storage/falcon/DeferredIndexWalker.cpp	2008-10-16 02:53:35 +0000
+++ b/storage/falcon/DeferredIndexWalker.cpp	2008-11-03 00:33:04 +0000
@@ -110,10 +110,16 @@ DINode* DeferredIndexWalker::next(void)
 		{
 		nodePending = false;
 
-		return currentNode = (slot >= leaf->count) ? NULL : leaf->nodes[slot];
+		if (slot < leaf->count)
+			return (currentNode = leaf->nodes[slot]);
+
+		if (!deferredIndex->levels)
+			return NULL;  // Only one bucket and it is empty
+		// else the first leaf is empty.  Back up a level.
 		}
+	else
+		++slot;
 
-	++slot;
 	DIBucket *bucket;
 		
 	for (;;)

=== modified file 'storage/falcon/EditString.cpp'
--- a/storage/falcon/EditString.cpp	2008-05-14 18:39:57 +0000
+++ b/storage/falcon/EditString.cpp	2008-10-31 15:42:42 +0000
@@ -367,8 +367,8 @@ char* EditString::formatString(Value * v
 {
 	char		*temp;
 	const char	*from = value->getString (&temp);
-	int			fromLength = strlen (from);
-	int			fpos = 0, tpos = 0;
+	size_t		fromLength = strlen (from);
+	size_t		fpos = 0, tpos = 0;
 	char		c;
 	reset();
 

=== modified file 'storage/falcon/EncodedDataStream.cpp'
--- a/storage/falcon/EncodedDataStream.cpp	2008-05-30 15:40:29 +0000
+++ b/storage/falcon/EncodedDataStream.cpp	2008-10-31 15:42:42 +0000
@@ -1358,7 +1358,7 @@ void EncodedDataStream::encodeOpaque(int
 void EncodedDataStream::encodeEncoding(const UCHAR *encodedValue)
 {
 	const UCHAR *p = skip(encodedValue);
-	stream->putSegment(p - encodedValue, (const char*) encodedValue, true);
+	stream->putSegment((int)(p - encodedValue), (const char*) encodedValue, true);
 }
 
 INT64 EncodedDataStream::getInt64(int requiredScale)

=== modified file 'storage/falcon/Filter.cpp'
--- a/storage/falcon/Filter.cpp	2008-05-14 18:39:57 +0000
+++ b/storage/falcon/Filter.cpp	2008-10-31 15:42:42 +0000
@@ -133,7 +133,7 @@ int Filter::getWord(int bufferLength, ch
 
 	*q = 0;
 
-	return q - buffer;
+	return (int)(q - buffer);
 }
 
 void Filter::start()

=== modified file 'storage/falcon/FilterSet.cpp'
--- a/storage/falcon/FilterSet.cpp	2008-05-14 18:39:57 +0000
+++ b/storage/falcon/FilterSet.cpp	2008-10-31 15:42:42 +0000
@@ -152,5 +152,5 @@ JString FilterSet::stripSQL(const char *
 	while (end > sql && end [-1] != ')')
 		--end;
 
-	return JString (sql, end - sql);
+	return JString (sql, (int)(end - sql));
 }

=== modified file 'storage/falcon/FsbSort.cpp'
--- a/storage/falcon/FsbSort.cpp	2008-05-14 18:39:57 +0000
+++ b/storage/falcon/FsbSort.cpp	2008-10-31 15:42:42 +0000
@@ -69,7 +69,7 @@ FsbSort::FsbSort(CompiledStatement *stat
 
 	int *ptr = contextIds;
 	getStreams(&ptr);
-	numberContexts = ptr - contextIds;
+	numberContexts = (int)(ptr - contextIds);
 }
 
 FsbSort::~FsbSort()

=== modified file 'storage/falcon/IO.cpp'
--- a/storage/falcon/IO.cpp	2008-09-11 10:56:00 +0000
+++ b/storage/falcon/IO.cpp	2008-10-31 00:29:13 +0000
@@ -117,6 +117,19 @@ static char baseDir[PATH_MAX+1]={0};
 bool deleteFilesOnExit = false;
 bool inCreateDatabase = false;
 
+#ifdef _WIN32
+static int winUnlink(const char *file);
+static int winOpen(const char *filename, int flags,...);
+#endif
+
+#ifdef _WIN32
+#define POSIX_OPEN_FILE winOpen
+#define POSIX_UNLINK_FILE winUnlink
+#else
+#define POSIX_OPEN_FILE   ::open
+#define POSIX_UNLINK_FILE ::unlink
+#endif
+
 #ifdef _DEBUG
 #undef THIS_FILE
 static const char THIS_FILE[]=__FILE__;
@@ -186,7 +199,7 @@ bool IO::openFile(const char * name, boo
 	ASSERT(!inCreateDatabase);
 
 	fileName = getPath(name);
-	fileId = ::open (fileName, (readOnly) ? (O_RDONLY | O_BINARY) : (O_RDWR | O_BINARY));
+	fileId = POSIX_OPEN_FILE(fileName, (readOnly) ? (O_RDONLY | O_BINARY) : (O_RDWR | O_BINARY));
 
 	if (fileId < 0)
 		{
@@ -241,7 +254,7 @@ bool IO::createFile(const char *name)
 	Log::debug("IO::createFile: creating file \"%s\"\n", name);
 
 	fileName = getPath(name);
-	fileId = ::open (fileName.getString(),O_CREAT | O_RDWR | O_RANDOM | O_EXCL | O_BINARY,
+	fileId = POSIX_OPEN_FILE (fileName.getString(),O_CREAT | O_RDWR | O_RANDOM | O_EXCL | O_BINARY,
 						S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP);
 
 
@@ -557,6 +570,7 @@ void IO::writeHeader(Hdr *header)
 void IO::deleteFile()
 {
 	deleteFile(fileName);
+	fileName="";
 }
 
 int IO::pread(int64 offset, int length, UCHAR* buffer)
@@ -675,10 +689,132 @@ void IO::sync(void)
 		traceOperation(TRACE_SYNC_END);
 }
 
+#ifdef _WIN32
+#define FALCON_DELETED_FILE "fdf"
+
+/*
+	The only safe way to delete file on Windows without invalidating open file 
+	handles is that:
+	- rename file to be deleted to a unique temporary name.
+	- open file it with FILE_FLAG_DELETE_ON_CLOSE
+	- close the file handle
+	Temp file will disappear as soon as last handle on it is closed.
+	This works only if files are opened with FILE_SHARE_DELETE flag.
+*/
+
+static int winUnlink(const char *file)
+{
+	DWORD attributes = GetFileAttributes(file);
+
+	// Bail out, if file does not exist.
+	if (attributes == INVALID_FILE_ATTRIBUTES)
+		return -1;
+
+	// If file is a symbolic link, just delete the link, but not the link target
+	if (attributes & FILE_ATTRIBUTE_REPARSE_POINT)
+		{
+		if(DeleteFile(file))
+			return 0;
+		return -1;
+		}
+
+	// Rename the file to unique name, then open with FILE_FLAG_DELETE_ON_CLOSE
+	// and close.
+	char  tmpDir[MAX_PATH];
+	strncpy(tmpDir, file, sizeof(tmpDir)-1);
+	char *p = strrchr(tmpDir ,SEPARATOR);
+	if (p)
+		*p = 0;
+	else
+		strcpy(tmpDir,".");
+
+	char  tmpFile[MAX_PATH];
+	if (GetTempFileName(tmpDir, FALCON_DELETED_FILE, 0, tmpFile))
+		{
+		if (MoveFileEx(file, tmpFile, MOVEFILE_REPLACE_EXISTING))
+			{
+			HANDLE hFile = CreateFile(tmpFile, 0,
+				FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+				NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
+
+			if (hFile != INVALID_HANDLE_VALUE)
+				{
+				CloseHandle(hFile);
+				return 0;
+				}
+			}
+		else
+			DeleteFile(tmpFile);
+		}
+	
+	// Something went wrong. Try DeleteFile(), even if it can invalidate
+	// open file handles.
+	if(DeleteFile(file))
+		return 0;
+
+	return -1;
+}
+
+/* 
+	A wrapper for Posix open(). The reason it is there is the FILE_SHARE_DELETE 
+	flag used in CreateFile, which allows for  posixly-correct unlink
+	(that works with open files)
+*/
+static int winOpen(const char *filename, int flags,...)
+{
+	DWORD access;
+	if (flags & O_WRONLY)
+		access = GENERIC_WRITE;
+	else if (flags & O_RDWR)
+		access = GENERIC_READ|GENERIC_WRITE;
+	else
+		access = GENERIC_READ;
+
+	DWORD disposition;
+	if (flags & O_CREAT)
+		disposition = CREATE_NEW;
+	else
+		disposition = OPEN_EXISTING;
+
+	DWORD attributes;
+	if (flags & O_RANDOM)
+		attributes = FILE_FLAG_RANDOM_ACCESS;
+	else
+		attributes = FILE_ATTRIBUTE_NORMAL;
+
+	HANDLE hFile = CreateFile(filename, access, 
+		FILE_SHARE_DELETE, NULL, disposition, attributes, NULL);
+	
+	if (hFile == INVALID_HANDLE_VALUE)
+		{
+		switch(GetLastError())
+			{
+			case ERROR_ACCESS_DENIED:
+				errno = EACCES;
+				break;
+			case ERROR_FILE_NOT_FOUND:
+			case ERROR_PATH_NOT_FOUND:
+				errno = ENOENT;
+				break;
+			default:
+				errno = EINVAL;
+				break;
+			}
+		return -1;
+		}
+	return _open_osfhandle((intptr_t)hFile, 
+		flags & (_O_APPEND|_O_RDONLY|_O_TEXT));
+}
+
+#endif
+
 void IO::deleteFile(const char* fileName)
 {
-	JString path = getPath(fileName);
-	unlink(path.getString());
+	if(fileName && *fileName)
+		{
+		JString path = getPath(fileName);
+		POSIX_UNLINK_FILE(path.getString());
+		}
 }
 
 void IO::tracePage(Bdb* bdb)
@@ -810,3 +946,4 @@ uint16 IO::computeChecksum(Page *page, s
 	return (uint16) sum;
 
 }
+

=== modified file 'storage/falcon/Index.cpp'
--- a/storage/falcon/Index.cpp	2008-10-16 02:53:35 +0000
+++ b/storage/falcon/Index.cpp	2008-10-29 23:25:13 +0000
@@ -582,7 +582,7 @@ void Index::update(Record * oldRecord, R
 	IndexKey key(this);
 	makeKey (record, &key);
 
-	// If there is a duplicate in the old version chain, don't both with another
+	// If there is a duplicate in the old version chain, don't bother with another
 
 	if (duplicateKey (&key, oldRecord))
 		return;

=== modified file 'storage/falcon/IndexRootPage.cpp'
--- a/storage/falcon/IndexRootPage.cpp	2008-08-25 22:09:13 +0000
+++ b/storage/falcon/IndexRootPage.cpp	2008-10-31 15:42:42 +0000
@@ -1198,7 +1198,7 @@ void IndexRootPage::positionIndex(Dbb* d
 		offset = page->computePrefix (key, highKey);
 		}
 
-	walkIndex->setNodes(page->nextPage, page->length - ((UCHAR*) node.node - (UCHAR*) page->nodes), node.node);
+	walkIndex->setNodes(page->nextPage, page->length - (int)((UCHAR*) node.node - (UCHAR*) page->nodes), node.node);
 	bdb->release(REL_HISTORY);
 }
 

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

=== modified file 'storage/falcon/MemMgr.cpp'
--- a/storage/falcon/MemMgr.cpp	2008-08-20 16:28:44 +0000
+++ b/storage/falcon/MemMgr.cpp	2008-11-03 00:34:05 +0000
@@ -55,7 +55,7 @@
 #include "LogStream.h"
 #endif
 
-static const int guardBytes = sizeof(long); // * 2048;
+static const size_t guardBytes = sizeof(long); // * 2048;
 
 #ifndef ASSERT
 #define ASSERT
@@ -112,7 +112,7 @@ struct Client {
 	};
 
 #ifdef _DEBUG
-	void* MemMgrPoolAllocateDebug (MemMgr *pool, unsigned int s, const char *file, int line)
+	void* MemMgrPoolAllocateDebug (MemMgr *pool, size_t s, const char *file, int line)
 	{
 		void *object = pool->allocateDebug(s, file, line);
 
@@ -120,12 +120,12 @@ struct Client {
 			printf("MemMgrAllocateDebug at %p\n", stopAddress);
 
 		if (traceFile)
-			fprintf(traceFile, "a %d %p\n", s, object);
+			fprintf(traceFile, "a " I64FORMAT " %p\n", (int64)s, object);
 
 		return object;
 	}
 
-	void* MemMgrAllocateDebug (unsigned int s, const char *file, int line)
+	void* MemMgrAllocateDebug (size_t s, const char *file, int line)
 	{
 		if(!memoryManagerAlive)
 			return malloc(s);
@@ -136,7 +136,7 @@ struct Client {
 			printf("MemMgrAllocateDebug at %p\n", stopAddress);
 
 		if (traceFile)
-			fprintf(traceFile, "a %d %p\n", s, object);
+			fprintf(traceFile, "a " I64FORMAT " %p\n", (int64)s, object);
 
 		return object;
 	}
@@ -159,7 +159,7 @@ struct Client {
 		memoryManager.releaseDebug (object);
 	}
 
-	void* MemMgrRecordAllocate (int size, const char *file, int line)
+	void* MemMgrRecordAllocate (size_t size, const char *file, int line)
 	{
 		return recordManager.allocateDebug (size, file, line);
 	}
@@ -169,12 +169,12 @@ struct Client {
 		recordManager.releaseDebug (record);
 	}
 #else
-	void* MemMgrPoolAllocate (MemMgr *pool, unsigned int s)
+	void* MemMgrPoolAllocate (MemMgr *pool, size_t s)
 	{
 		return pool->allocate (s);
 	}
 
-	void* MemMgrAllocate (unsigned int s)
+	void* MemMgrAllocate (size_t s)
 	{
 		if(!memoryManagerAlive)
 			return malloc(s);
@@ -190,7 +190,7 @@ struct Client {
 			memoryManager.release (object);
 	}
 
-	void* MemMgrRecordAllocate (int size, const char *file, int line)
+	void* MemMgrRecordAllocate (size_t size, const char *file, int line)
 	{
 		return recordManager.allocate (size);
 	}
@@ -346,10 +346,12 @@ MemMgr::~MemMgr(void)
 		*isAlive = false;
 }
 
-MemBlock* MemMgr::alloc(int length)
+MemBlock* MemMgr::alloc(size_t s)
 {
-	if (length <= 0)
-		throw SQLError (RUNTIME_ERROR, "illegal memory allocate for %d bytes", length);
+	if (s > INT_MAX)
+		throw SQLError (RUNTIME_ERROR, "illegal memory allocate for " I64FORMAT " bytes", (int64)s);
+
+	int length = (int) s;
 
 	Sync sync (&mutex, "MemMgr::alloc");
 	sync.lock(Exclusive);
@@ -522,9 +524,9 @@ MemBlock* MemMgr::alloc(int length)
 	return block;
 }
 
-void* MemMgr::allocate(int size)
+void* MemMgr::allocate(size_t size)
 {
-	int length = ROUNDUP(size, roundingSize) + OFFSET(MemBlock*, body) + guardBytes;
+	size_t length = ROUNDUP(size, roundingSize) + OFFSET(MemBlock*, body) + guardBytes;
 	MemBlock *memory;
 
 	ASSERT(signature == defaultSignature);
@@ -547,9 +549,9 @@ void* MemMgr::allocate(int size)
 	return &memory->body;
 }
 
-void* MemMgr::allocateDebug(int size, const char* fileName, int line)
+void* MemMgr::allocateDebug(size_t size, const char* fileName, int line)
 {
-	int length = ROUNDUP(size, roundingSize) + OFFSET(MemBlock*, body) + guardBytes;
+	size_t length = ROUNDUP(size, roundingSize) + OFFSET(MemBlock*, body) + guardBytes;
 	MemBlock *memory;
 
 	ASSERT(signature == defaultSignature);
@@ -563,7 +565,7 @@ void* MemMgr::allocateDebug(int size, co
 #endif
 
 	memset (&memory->body, INIT_BYTE, size);
-	int l = ABS(memory->length) - size - OFFSET(MemBlock*,body);
+	size_t l = ABS(memory->length) - size - OFFSET(MemBlock*,body);
 	ASSERT(l >= guardBytes && l < length - size + guardBytes + (int) sizeof (MemFreeBlock));
 	memset (&memory->body + size, GUARD_BYTE, l);
 	++blocksAllocated;

=== modified file 'storage/falcon/MemMgr.h'
--- a/storage/falcon/MemMgr.h	2008-08-06 11:53:21 +0000
+++ b/storage/falcon/MemMgr.h	2008-10-31 15:42:42 +0000
@@ -19,6 +19,7 @@
 
 #include "Mutex.h"
 #include "SyncObject.h"
+#include <limits.h>
 
 
 #ifndef MEM_DEBUG
@@ -135,12 +136,12 @@ public:
 	friend void  MemMgrLogDump();
 
 protected:
-	MemBlock*	alloc(int size);
+	MemBlock*	alloc(size_t size);
 	static void	corrupt(const char* text);
 	
 public:
-	void*		allocate(int size);
-	void*		allocateDebug(int size, const char* fileName, int line);
+	void*		allocate(size_t size);
+	void*		allocateDebug(size_t size, const char* fileName, int line);
 	void		releaseBlock(MemBlock *block);
 	void		validateBlock(MemBlock *block);
 	void		analyze (int mask, Stream *stream, InfoTable *summaryTable, InfoTable *detailTable);

=== modified file 'storage/falcon/MemoryManager.h'
--- a/storage/falcon/MemoryManager.h	2008-09-14 20:12:37 +0000
+++ b/storage/falcon/MemoryManager.h	2008-10-31 15:42:42 +0000
@@ -43,35 +43,35 @@ class MemMgr;
 struct MemObject;
 
 #ifdef _DEBUG
-	extern void* MemMgrAllocateDebug (unsigned int s, const char *file, int line);
-	extern void* MemMgrPoolAllocateDebug (MemMgr *pool, unsigned int s, const char *file, int line);
+	extern void* MemMgrAllocateDebug (size_t s, const char *file, int line);
+	extern void* MemMgrPoolAllocateDebug (MemMgr *pool, size_t s, const char *file, int line);
 	
 	WINSTATIC ALWAYS_INLINE void* operator new(size_t s) THROWS_BAD_ALLOC
-		{ return MemMgrAllocateDebug ((unsigned int) s, __FILE__, __LINE__); }
+		{ return MemMgrAllocateDebug (s, __FILE__, __LINE__); }
 		
 	WINSTATIC ALWAYS_INLINE void* operator new(size_t s, const int  &n) 
-		{ return MemMgrAllocateDebug ((unsigned int) s, __FILE__, __LINE__); }
+		{ return MemMgrAllocateDebug (s, __FILE__, __LINE__); }
 		
 	WINSTATIC ALWAYS_INLINE void* operator new(size_t s, const char *file, int line) 
-		{ return MemMgrAllocateDebug ((unsigned int) s, file, line); }
+		{ return MemMgrAllocateDebug (s, file, line); }
 		
 	WINSTATIC ALWAYS_INLINE void* operator new[](size_t s) THROWS_BAD_ALLOC
-		{ return MemMgrAllocateDebug ((unsigned int) s, __FILE__, __LINE__); }
+		{ return MemMgrAllocateDebug (s, __FILE__, __LINE__); }
 		
 	WINSTATIC ALWAYS_INLINE void* operator new[](size_t s, const char *file, int line) THROWS_BAD_ALLOC
-		{ return MemMgrAllocateDebug ((unsigned int) s, file, line); }
+		{ return MemMgrAllocateDebug (s, file, line); }
 
 	WINSTATIC ALWAYS_INLINE void* operator new(size_t s, MemMgr *pool) THROWS_BAD_ALLOC
-		{ return MemMgrPoolAllocateDebug (pool, (unsigned int) s, __FILE__, __LINE__); }
+		{ return MemMgrPoolAllocateDebug (pool, s, __FILE__, __LINE__); }
 
 	WINSTATIC ALWAYS_INLINE void* operator new(size_t s, MemMgr *pool, const char *file, int line) 
-		{ return MemMgrPoolAllocateDebug (pool, (unsigned int) s, file, line); }
+		{ return MemMgrPoolAllocateDebug (pool, s, file, line); }
 		
 	WINSTATIC ALWAYS_INLINE void* operator new[](size_t s, MemMgr *pool) THROWS_BAD_ALLOC
 		{ return MemMgrPoolAllocateDebug (pool, (unsigned int) s, __FILE__, __LINE__); }
 
 	WINSTATIC ALWAYS_INLINE void* operator new[](size_t s, MemMgr *pool, const char *file, int line) 
-		{ return MemMgrPoolAllocateDebug (pool, (unsigned int) s, file, line); }
+		{ return MemMgrPoolAllocateDebug (pool,  s, file, line); }
 
 #define POOL_NEW(arg) new(arg, THIS_FILE, __LINE__)
 #define NEW	new (THIS_FILE, __LINE__)
@@ -81,8 +81,8 @@ struct MemObject;
 #endif
 
 #else
-	extern void* MemMgrAllocate (unsigned int s);
-	extern void* MemMgrPoolAllocate (MemMgr *pool, unsigned int s);
+	extern void* MemMgrAllocate (size_t s);
+	extern void* MemMgrPoolAllocate (MemMgr *pool, size_t s);
 	
 	WINSTATIC ALWAYS_INLINE void* operator new(size_t s) THROWS_BAD_ALLOC
 		{ return MemMgrAllocate (s); }
@@ -91,7 +91,7 @@ struct MemObject;
 		{ return ::MemMgrPoolAllocate (pool, s); }
 
 	WINSTATIC ALWAYS_INLINE void* operator new[](size_t s, MemMgr *pool) THROWS_BAD_ALLOC
-		{ return ::MemMgrPoolAllocate (pool, s); }
+		{ return ::MemMgrPoolAllocate (pool,s); }
 
 	WINSTATIC ALWAYS_INLINE void* operator new(size_t s, const int  &n) THROWS_BAD_ALLOC
 		{ return ::MemMgrAllocate (s); }
@@ -118,7 +118,7 @@ extern void		MemMgrAnalyze(MemMgrWhat wh
 extern void		MemMgrRelease (void *object);
 extern void		MemMgrValidate (void *object);
 extern void		MemMgrAnalyze(int mask, Stream *stream);
-extern void*	MemMgrRecordAllocate (int size, const char *file, int line);
+extern void*	MemMgrRecordAllocate (size_t size, const char *file, int line);
 extern void		MemMgrRecordDelete (char *record);
 extern void		MemMgrSetMaxRecordMember (long long size);
 extern MemMgr*	MemMgrGetFixedPool (int id);

=== modified file 'storage/falcon/Record.cpp'
--- a/storage/falcon/Record.cpp	2008-10-27 18:00:09 +0000
+++ b/storage/falcon/Record.cpp	2008-10-29 23:25:13 +0000
@@ -849,7 +849,7 @@ void Record::setPriorVersion(Record* rec
 	ASSERT(false);
 }
 
-int Record::thaw(bool force)
+int Record::thaw(void)
 {
 	return 0;
 }

=== modified file 'storage/falcon/Record.h'
--- a/storage/falcon/Record.h	2008-10-24 05:35:38 +0000
+++ b/storage/falcon/Record.h	2008-10-29 23:25:13 +0000
@@ -88,7 +88,7 @@ public:
 	virtual Record*	getPriorVersion();
 	virtual Record*	getGCPriorVersion(void);
 	virtual	void	print(void);
-	virtual int		thaw(bool force = false);
+	virtual int		thaw(void);
 	virtual const char*	getEncodedRecord();
 	virtual int		setRecordData(const UCHAR *dataIn, int dataLength);
 	virtual void	serialize(Serialize* stream);

=== modified file 'storage/falcon/RecordScavenge.cpp'
--- a/storage/falcon/RecordScavenge.cpp	2008-10-24 05:06:52 +0000
+++ b/storage/falcon/RecordScavenge.cpp	2008-10-29 23:25:13 +0000
@@ -56,7 +56,7 @@ void RecordScavenge::inventoryRecord(Rec
 		uint64 age = baseGeneration - record->generation;
 		int size = record->size + sizeof(MemBigHeader);
 		
-		if (record->hasRecord(false) || record->state == recChilled)
+		if (record->hasRecord(false) || (record->state == recChilled))
 			size += sizeof(MemBigHeader);
 			
 		if (age != UNDEFINED && age < AGE_GROUPS)

=== modified file 'storage/falcon/RecordVersion.cpp'
--- a/storage/falcon/RecordVersion.cpp	2008-10-24 05:35:38 +0000
+++ b/storage/falcon/RecordVersion.cpp	2008-11-07 01:09:04 +0000
@@ -55,6 +55,9 @@ RecordVersion::RecordVersion(Table *tbl,
 		{
 		priorVersion->addRef();
 		recordNumber = oldVersion->recordNumber;
+
+		if (priorVersion->state == recChilled)
+			priorVersion->thaw();
 		
 		if (trans == priorVersion->getTransaction())
 			oldVersion->setSuperceded (true);
@@ -353,7 +356,7 @@ uint64 RecordVersion::getVirtualOffset()
 	return (virtualOffset);
 }
 
-int RecordVersion::thaw(bool force)
+int RecordVersion::thaw()
 {
 	Sync syncThaw(format->table->getSyncThaw(this), "RecordVersion::thaw");
 	syncThaw.lock(Exclusive);
@@ -370,7 +373,7 @@ int RecordVersion::thaw(bool force)
 	// true, then the record data can be restored from the serial log. If writePending
 	// is false, then the record data has been written to the data pages.
 	
-	if (trans && (trans->writePending || force))
+	if (trans && trans->writePending)
 		{
 		trans->addRef();
 		bytesRestored = trans->thaw(this);

=== modified file 'storage/falcon/RecordVersion.h'
--- a/storage/falcon/RecordVersion.h	2008-10-24 05:06:52 +0000
+++ b/storage/falcon/RecordVersion.h	2008-10-29 23:25:13 +0000
@@ -53,7 +53,7 @@ public:
 	virtual void		setPriorVersion (Record *oldVersion);
 	virtual void		setVirtualOffset(uint64 offset);
 	virtual uint64		getVirtualOffset();
-	virtual int			thaw(bool force = false);
+	virtual int			thaw(void);
 	virtual void		print(void);
 	virtual int			getSize(void);
 	virtual void		serialize(Serialize* stream);

=== modified file 'storage/falcon/RecoveryObjects.cpp'
--- a/storage/falcon/RecoveryObjects.cpp	2008-09-03 22:17:54 +0000
+++ b/storage/falcon/RecoveryObjects.cpp	2008-10-29 23:25:13 +0000
@@ -99,7 +99,7 @@ bool RecoveryObjects::isObjectActive(int
 	return object->pass1Count == object->currentCount;
 }
 
-static inline RecoveryPage * findInHashBucket(RecoveryPage *head, int objectNumber, int tableSpaceId)
+RecoveryPage* RecoveryObjects::findInHashBucket(RecoveryPage *head, int objectNumber, int tableSpaceId)
 {
 	for (RecoveryPage *object = head ; object; object = object->collision)
 		if (object->objectNumber == objectNumber && object->tableSpaceId == tableSpaceId)

=== modified file 'storage/falcon/RecoveryObjects.h'
--- a/storage/falcon/RecoveryObjects.h	2008-07-18 21:24:52 +0000
+++ b/storage/falcon/RecoveryObjects.h	2008-10-29 23:25:13 +0000
@@ -40,6 +40,7 @@ public:
 	void			reset();
 	bool			bumpIncarnation(int objectNumber, int tableSpaceId, int state, bool pass1);
 	void			clear();
+	RecoveryPage*	findInHashBucket(RecoveryPage *head, int objectNumber, int tableSpaceId);
 	RecoveryPage*	findRecoveryObject(int objectNumber, int tableSpaceId);
 	void			setActive(int objectNumber, int tableSpaceId);
 	void			setInactive(int objectNumber, int tableSpaceId);

=== modified file 'storage/falcon/SRLUpdateIndex.cpp'
--- a/storage/falcon/SRLUpdateIndex.cpp	2008-10-16 02:53:35 +0000
+++ b/storage/falcon/SRLUpdateIndex.cpp	2008-11-14 15:38:44 +0000
@@ -60,25 +60,39 @@ void SRLUpdateIndex::append(DeferredInde
 	uint64 virtualOffset = 0;
 	uint64 virtualOffsetAtEnd = 0;
 
-	// Remember where this is logged
-
-	virtualOffset = log->writeWindow->getNextVirtualOffset();
-
 	for (DINode *node = walker.next(); node;)
 		{
 		START_RECORD(srlUpdateIndex, "SRLUpdateIndex::append(2)");
+		
+		// Save the absolute offset of the DeferredIndex record within the serial log.
+		// This must be done inside the SerialLog::syncWrite lock set by START_RECORD().
+
+		if (virtualOffset == 0)
+			virtualOffset = log->startRecordVirtualOffset;
+
 		log->updateIndexUseVector(indexId, tableSpaceId, 1);
 		SerialLogTransaction *srlTrans = log->getTransaction(transaction->transactionId);
 		srlTrans->setTransaction(transaction);
 		ASSERT(transaction->writePending);
+		
+		// Set the record header fields
+		
 		putInt(tableSpaceId);
 		putInt(transaction->transactionId);
 		putInt(indexId);
 		putInt(idxVersion);
+		
+		// Initialize the length field, adjust with correct length later.
+		// Use a fixed-length integer to accommodate a larger number.
+		
 		UCHAR *lengthPtr = putFixedInt(0);
 		UCHAR *start = log->writePtr;
 		UCHAR *end = log->writeWarningTrack;
 
+		// Write the variable-length index node data. If the data length
+		// will extend past the end of the current window, start a new
+		// record.
+		
 		for (; node; node = walker.next())
 			{
 			if (log->writePtr + byteCount(node->recordNumber) +
@@ -93,10 +107,18 @@ void SRLUpdateIndex::append(DeferredInde
 		int len = (int) (log->writePtr - start);
 		//printf("SRLUpdateIndex::append tid %d, index %d, length %d, ptr %x (%x)\n",  transaction->transactionId, indexId, len, lengthPtr, org);
 		ASSERT(len >= 0);
-		putFixedInt(len, lengthPtr);
-		const UCHAR *p = lengthPtr;
-		ASSERT(getInt(&p) == len);
+
+		// Update the length field
+		
+		if (len > 0)
+			putFixedInt(len, lengthPtr);
+		
+		// Save the absolute offset of the end of the DeferredIndex record
+		
 		virtualOffsetAtEnd = log->writeWindow->getNextVirtualOffset();
+		
+		// End this serial log record and flush to disk. Force the creation of
+		// a new serial log window.
 		log->endRecord();
 		
 		if (node)
@@ -218,9 +240,9 @@ void SRLUpdateIndex::thaw(DeferredIndex*
 {
 	Sync sync(&log->syncWrite, "SRLUpdateIndex::thaw");
 	sync.lock(Exclusive);
+
 	uint64 virtualOffset = deferredIndex->virtualOffset;
 	int recordNumber = 0;  // a valid record number to get into the loop.
-	ASSERT(deferredIndex->virtualOffset);
 	Transaction *trans = deferredIndex->transaction;
 	TransId transId = trans->transactionId;
 	indexId = deferredIndex->index->indexId;
@@ -235,21 +257,25 @@ void SRLUpdateIndex::thaw(DeferredIndex*
 	
 	if (window == NULL)
 		{
-		Log::log("A window for DeferredIndex::virtualOffset=" I64FORMAT " could not be found.\n",
-		         deferredIndex->virtualOffset);
+		Log::log("Index thaw FAIL: A window for DeferredIndex::virtualOffset=" I64FORMAT " could not be found.\n", deferredIndex->virtualOffset);
 		log->printWindows();
-		
 		return;
 		}
-		
-	// Find the correct block within the window and set the offset using that block.
 
-	SerialLogBlock *block = window->firstBlock();
-	uint32 blockOffset = 0;
-	ASSERT( (UCHAR *) block == window->buffer);
+	// Location of the DeferredIndex within the window
+	
 	uint32 windowOffset = (uint32) (virtualOffset - window->virtualOffset);
-
-	while (windowOffset >= blockOffset + block->length)
+	
+	// Location of the block in which the DeferredIndex resides
+	
+	uint32 blockOffset = 0; 
+	
+	// Find the block in which the DeferredIndex resides, starting with the first
+	// block in the window. Accumulate each block's offset in blockOffset.
+	
+	SerialLogBlock *block = window->firstBlock();
+	
+	while (blockOffset + block->length <= windowOffset)
 		{
 		SerialLogBlock *prevBlock = block;
 		block = window->nextBlock(block);
@@ -257,21 +283,37 @@ void SRLUpdateIndex::thaw(DeferredIndex*
 		blockOffset += thisBlockOffset;
 		}
 
+	// Find the location of the DeferredIndex in the target block. Adjust for the
+	// offset of the data buffer within the block structure.
+	
 	uint32 offsetWithinBlock = (windowOffset - blockOffset - OFFSET(SerialLogBlock*, data));
+	
+	// Get the serial log version and set the input pointer to the specified offset within
+	// the target block. Activate the window, if necessary.
+	
 	control->setWindow(window, block, offsetWithinBlock);
 	ASSERT(control->input == window->buffer + windowOffset);
 	ASSERT(control->inputEnd <= window->bufferEnd);
 
-	// Read the SerialLogRecord type and header
-
-	UCHAR type = getInt();
-	ASSERT(type == srlUpdateIndex);
-	read();		// this read() is also in control->nextRecord() below.
+	// Now we are pointing at a serial log record, so read the entire record.
+	// Version records are written at the top of each block. If necessary,
+	// advance past the version record and read the SRLUpdateIndex record.
 
-	while (virtualOffset < deferredIndex->virtualOffsetAtEnd)
+	SerialLogRecord* srlRecord = control->nextRecord();
+	
+	if (srlRecord && srlRecord->type == srlVersion)
+		srlRecord = control->nextRecord();
+		
+	if (srlRecord)
+		ASSERT(srlRecord->type == srlUpdateIndex);
+	else
+		Log::log("Index thaw FAIL: SRLUpdateIndex record not found. DeferredIndex::virtualOffset=" I64FORMAT "\n", deferredIndex->virtualOffset);
+	
+	// The DeferredIndex may reside in several serial log records. Read each record and
+	// rebuild the index from the nodes stored within the record.
+	
+	while (srlRecord && virtualOffset < deferredIndex->virtualOffsetAtEnd)
 		{
-		sync.unlock();
-
 		// Read the header of the deferredIndex and validate.
 
 		ASSERT(transactionId == transId);
@@ -283,7 +325,7 @@ void SRLUpdateIndex::thaw(DeferredIndex*
 					
 		IndexKey indexKey(deferredIndex->index);
 
-		// Read each IndexKey and add it to the deferredIndex.   set ptr and end for nextKey()
+		// Read each IndexKey and add it to the deferredIndex. Set ptr and end for nextKey().
 
 		ptr = data;
 		end = ptr + dataLength;
@@ -291,13 +333,15 @@ void SRLUpdateIndex::thaw(DeferredIndex*
 		for (recordNumber = nextKey(&indexKey); recordNumber >= 0; recordNumber = nextKey(&indexKey))
 			deferredIndex->addNode(&indexKey, recordNumber);
 
-		sync.lock(Exclusive);
-
 		for (;;)
 			{
 			// Quit if there are no more SerialLogRecords for this DeferredIndex.
 
 			SerialLogWindow *inputWindow = control->inputWindow;
+
+			if (!inputWindow)
+				break;
+				
 			virtualOffset = inputWindow->virtualOffset + (control->input - inputWindow->buffer);
 
 			if (virtualOffset >= deferredIndex->virtualOffsetAtEnd)
@@ -305,9 +349,9 @@ void SRLUpdateIndex::thaw(DeferredIndex*
 
 			// Find the next SerialLogRecord of this deferredIndex.
 
-			SerialLogRecord *record = control->nextRecord();
+			srlRecord = control->nextRecord();
 
-			if ((record == this) && (transactionId == transId) && (indexId == deferredIndex->index->indexId))
+			if (srlRecord == this && transactionId == transId && indexId == deferredIndex->index->indexId)
 				break;
 			}
 		}

=== modified file 'storage/falcon/SRLUpdateRecords.cpp'
--- a/storage/falcon/SRLUpdateRecords.cpp	2008-10-24 05:06:52 +0000
+++ b/storage/falcon/SRLUpdateRecords.cpp	2008-11-14 15:38:44 +0000
@@ -76,6 +76,9 @@ int SRLUpdateRecords::thaw(RecordVersion
 	if (!window)
 		return 0;
 		
+	Sync sync(&log->syncWrite, "SRLUpdateRecords::thaw");
+	sync.lock(Exclusive);
+	
 	// Return pointer to record data
 
 	control->input = window->buffer + (record->getVirtualOffset() - window->virtualOffset);
@@ -94,14 +97,15 @@ int SRLUpdateRecords::thaw(RecordVersion
 	int dataLength   = control->getInt();
 	int bytesReallocated = 0;
 	
+	window->deactivateWindow();
+	sync.unlock();
+	
 	// setRecordData() handles race conditions with an interlocked compare and exchange,
 	// but check the state and record number anyway
 
 	if (record->state == recChilled && recordNumber == record->recordNumber)
 		bytesReallocated = record->setRecordData(control->input, dataLength);
 
-	window->deactivateWindow();
-
 	if (bytesReallocated > 0)
 		{
 		ASSERT(recordNumber == record->recordNumber);
@@ -124,10 +128,14 @@ void SRLUpdateRecords::append(Transactio
 {
 	uint32 chilledRecordsWindow = 0;
 	uint32 chilledBytesWindow   = 0;
-	uint32 windowNumber         = 0;
 	SerialLogTransaction *srlTrans = NULL;
 	int savepointId;
 	
+	// Generate one serial log record per write window. To ensure that
+	// chilled records are grouped by savepoint, start a new serial
+	// log record for each savepoint. Several serial log records may
+	// be generated for one savepoint.
+	
 	for (RecordVersion *record = records; record;)
 		{
 		START_RECORD(srlUpdateRecords, "SRLUpdateRecords::append");
@@ -160,7 +168,6 @@ void SRLUpdateRecords::append(Transactio
 			if (record->state == recChilled)
 				{
 				transaction->chillPoint = &record->nextInTrans;
-				
 				continue;
 				}
 				
@@ -169,7 +176,8 @@ void SRLUpdateRecords::append(Transactio
 			if (record->state == recNoChill)
 				continue;
 
-			// If this is a different savepoint, start another record
+			// If this is a different savepoint, break out of the inner loop
+			// and start another serial log record
 			
 			if (chillRecords && record->savePointId != savepointId)
 				break;
@@ -178,20 +186,34 @@ void SRLUpdateRecords::append(Transactio
 			tableSpaceId = table->dbb->tableSpaceId;
 			Stream stream;
 			
-			// Thawed records are indicated by a non-zero virtual offset, and
-			// are already in the serial log. If this record is to be re-chilled,
-			// then no need to get the record data or set the virtual offset.
+			// A non-zero virtual offset indicates that the record was previously
+			// chilled and thawed and is already in the serial log.
+			//
+			// If this record is being re-chilled, then there is no need to get
+			// the record data or set the virtual offset.
+			//
+			// If this record is being committed, then there is nothing to do.
 
-			if (chillRecords && record->state != recDeleted && record->virtualOffset != 0)
+			if (record->virtualOffset != 0)
 				{
-				int chillBytes = record->getEncodedSize();
-				chill(transaction, record, chillBytes);
-				log->chilledRecords++;
-				log->chilledBytes += chillBytes;
-				ASSERT(transaction->thawedRecords > 0);
+				if (chillRecords && record->state != recDeleted)
+					{
+					int chillBytes = record->getEncodedSize();
 
-				if (transaction->thawedRecords)
-					transaction->thawedRecords--;
+					chill(transaction, record, chillBytes);
+					
+					log->chilledRecords++;
+					log->chilledBytes += chillBytes;
+					
+					ASSERT(transaction->thawedRecords > 0);
+
+					if (transaction->thawedRecords)
+						transaction->thawedRecords--;
+					}
+				else
+					{

+					// Record is already in serial log
+					}
 
 				continue;
 				}
@@ -215,13 +237,15 @@ void SRLUpdateRecords::append(Transactio
 				 byteCount(stream.totalLength) + stream.totalLength >= end)
 				break;
 			
-			// Set the virtual offset of the record in the serial log
-
 			ASSERT(record->recordNumber >= 0);
 			ASSERT(log->writePtr > (UCHAR *)log->writeWindow->buffer);
+			
+			// Set the virtual offset of the record in the serial log
+
 			record->setVirtualOffset(log->writeWindow->currentLength + log->writeWindow->virtualOffset);
 			uint32 sectionId = table->dataSectionId;
 			log->updateSectionUseVector(sectionId, tableSpaceId, 1);
+			
 			putInt(tableSpaceId);
 			putInt(record->getPriorVersion() ? sectionId : -(int) sectionId - 1);
 			putInt(record->recordNumber);
@@ -233,14 +257,18 @@ void SRLUpdateRecords::append(Transactio
 				chilledRecordsWindow++;
 				chilledBytesWindow += stream.totalLength;
 				}
-			} // next record
+			} // next record version
 		
 		int len = (int) (log->writePtr - start);
 		
+		// The length field is 0, update if necessary
+		
 		if (len > 0)
 			putFixedInt(len, lengthPtr);
 		
-		if (record)
+		// Flush record data, if any, and force the creation of a new serial log window
+		
+		if (record && len > 0)
 			log->flush(true, 0, &sync);
 		else
 			sync.unlock();
@@ -250,9 +278,10 @@ void SRLUpdateRecords::append(Transactio
 			log->chilledRecords += chilledRecordsWindow;
 			log->chilledBytes   += chilledBytesWindow;
 			transaction->chilledRecords += chilledRecordsWindow;
-			windowNumber = (uint32)log->writeWindow->virtualOffset / SRL_WINDOW_SIZE;
+			transaction->chilledBytes += chilledBytesWindow;
+//			uint32 windowNumber = (uint32)log->writeWindow->virtualOffset / SRL_WINDOW_SIZE;
 			}
-		} // next window
+		} // next serial log record and write window
 }
 
 void SRLUpdateRecords::read(void)

=== modified file 'storage/falcon/SerialLog.cpp'
--- a/storage/falcon/SerialLog.cpp	2008-10-20 21:28:11 +0000
+++ b/storage/falcon/SerialLog.cpp	2008-11-14 15:38:44 +0000
@@ -131,6 +131,7 @@ SerialLog::SerialLog(Database *db, JStri
 	gophers = NULL;
 	wantToSerializeGophers = 0;
 	serializeGophers = 0;
+	startRecordVirtualOffset = 0;
 	
 	for (uint n = 0; n < falcon_gopher_threads; ++n)
 		{
@@ -217,7 +218,9 @@ void SerialLog::recover()
 	sync.lock(Exclusive);
 	recovering = true;
 	recoveryPhase = 0;	// Find last block and recovery block
-	
+
+	defaultDbb->setCacheRecovering(true);
+
 	// See if either or both files have valid blocks
 
 	SerialLogWindow *window1 = allocWindow(file1, 0);
@@ -414,7 +417,8 @@ void SerialLog::recover()
 		info->sectionUseVector.zap();
 		info->indexUseVector.zap();
 		}
-		
+
+	defaultDbb->setCacheRecovering(false);
 	Log::log("Recovery complete\n");
 	recoveryPhase = 0;	// Find last lock and recovery block
 }
@@ -708,6 +712,8 @@ void SerialLog::startRecord()
 	if (writeError)
 		throw SQLError(IO_ERROR_SERIALLOG, "Previous I/O error on serial log prevents further processing");
 
+	startRecordVirtualOffset = writeWindow->getNextVirtualOffset();
+	
 	if (writePtr == writeBlock->data)
 		putVersion();
 

=== modified file 'storage/falcon/SerialLog.h'
--- a/storage/falcon/SerialLog.h	2008-10-20 21:28:11 +0000
+++ b/storage/falcon/SerialLog.h	2008-11-14 15:38:44 +0000
@@ -224,6 +224,7 @@ public:
 	uint64				chilledBytes;
 	int32				wantToSerializeGophers;
 	int32				serializeGophers;
+	uint64				startRecordVirtualOffset;
 
 	TableSpaceInfo		*tableSpaces[SLT_HASH_SIZE];
 	TableSpaceInfo		*tableSpaceInfo;

=== modified file 'storage/falcon/SerialLogControl.cpp'
--- a/storage/falcon/SerialLogControl.cpp	2008-03-11 16:15:47 +0000
+++ b/storage/falcon/SerialLogControl.cpp	2008-11-11 22:33:27 +0000
@@ -337,6 +337,7 @@ SerialLogRecord* SerialLogControl::nextR
 	ASSERT(version > 0);
 	ASSERT(type < srlMax);
 	SerialLogRecord *record = records[type];
+	record->type = type;
 	record->read();
 	
 	if (debug)

=== modified file 'storage/falcon/SerialLogFile.cpp'
--- a/storage/falcon/SerialLogFile.cpp	2008-10-16 02:53:35 +0000
+++ b/storage/falcon/SerialLogFile.cpp	2008-11-03 00:34:05 +0000
@@ -367,10 +367,10 @@ void SerialLogFile::zap()
 	// The error is supposedly related to the file size being less than 
 	// page size, so initial size is made 8K just in case we'll ever run on IA64
 	size_t initialSize = MAX(sectorSize, 8192); 
-	UCHAR *junk = new UCHAR[initialSize +sectorSize];
+	UCHAR *junk = new UCHAR[initialSize + sectorSize];
 	UCHAR *buffer = ALIGN(junk, sectorSize);
-	memset(buffer, 0, sectorSize);
-	write(0, sectorSize, (SerialLogBlock*) buffer);
+	memset(buffer, 0, initialSize);
+	write(0, (uint32) initialSize, (SerialLogBlock*) buffer);
 	delete junk;
 }
 

=== modified file 'storage/falcon/SerialLogRecord.cpp'
--- a/storage/falcon/SerialLogRecord.cpp	2008-04-09 01:36:46 +0000
+++ b/storage/falcon/SerialLogRecord.cpp	2008-11-11 22:33:27 +0000
@@ -100,6 +100,7 @@ int init()
 SerialLogRecord::SerialLogRecord()
 {
 	transactionId = 0;
+	type = 0;
 }
 
 SerialLogRecord::~SerialLogRecord()

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

=== modified file 'storage/falcon/Serialize.cpp'
--- a/storage/falcon/Serialize.cpp	2008-02-25 22:27:17 +0000
+++ b/storage/falcon/Serialize.cpp	2008-10-31 15:42:42 +0000
@@ -82,7 +82,7 @@ void Serialize::putInt(int value)
 		*p++ = (value >> (lengthShifts [count])) & 0x7f;
 
 	*p++ = value | LOW_BYTE_FLAG;
-	release(p - data);
+	release((uint)(p - data));
 }
 
 void Serialize::putInt64(int64 value)
@@ -95,7 +95,7 @@ void Serialize::putInt64(int64 value)
 		*p++ = (UCHAR) (value >> (lengthShifts [count])) & 0x7f;
 
 	*p++ = ((UCHAR) value) | LOW_BYTE_FLAG;
-	release(p - data);
+	release((uint)(p - data));
 }
 
 void Serialize::putData(uint length, const UCHAR* data)

=== modified file 'storage/falcon/StorageHandler.cpp'
--- a/storage/falcon/StorageHandler.cpp	2008-10-01 03:13:44 +0000
+++ b/storage/falcon/StorageHandler.cpp	2008-11-13 13:27:13 +0000
@@ -36,8 +36,6 @@
 #include "CmdGen.h"
 #include "Dbb.h"
 #include "Database.h"
-#include "TableSpaceManager.h"
-#include "IOx.h"
 
 #define DICTIONARY_ACCOUNT		"mysql"
 #define DICTIONARY_PW			"mysql"
@@ -505,12 +503,6 @@ int StorageHandler::createTablespace(con
 		return StorageErrorTableSpaceExist;
 		}
 
-	TableSpaceManager *tableSpaceManager =
-		dictionaryConnection->database->tableSpaceManager;
-
-	if (!tableSpaceManager->waitForPendingDrop(filename, 10))
-		// file still exists after waiting for 10 seconds
-		return  StorageErrorTableSpaceDataFileExist;

 
 	try
 		{
@@ -1006,6 +998,8 @@ void StorageHandler::initialize(void)
 
 		try
 			{
+			Log::log(LogMysqlInfo, "Falcon: unable to open system data files.");
+			Log::log(LogMysqlInfo, "Falcon: creating new system data files.");
 			createDatabase();
 			}
 		catch(SQLException &e2)

=== modified file 'storage/falcon/StorageTableShare.cpp'
--- a/storage/falcon/StorageTableShare.cpp	2008-10-22 20:44:09 +0000
+++ b/storage/falcon/StorageTableShare.cpp	2008-11-05 14:51:37 +0000
@@ -262,7 +262,7 @@ int StorageTableShare::truncateTable(Sto
 	return res;
 }
 
-const char* StorageTableShare::cleanupFieldName(const char* name, char* buffer, int bufferLength)
+const char* StorageTableShare::cleanupFieldName(const char* name, char* buffer, int bufferLength, bool doubleQuotes)
 {
 	char *q = buffer;
 	char *end = buffer + bufferLength - 1;
@@ -273,7 +273,11 @@ const char* StorageTableShare::cleanupFi
 		{
 		if (*p == '"')
 			{
-			*q++ = UPPER(*p);
+			if (doubleQuotes)
+				{
+				*q++ = UPPER(*p);
+				}
+
 			quotes = !quotes;
 			}
 	
@@ -321,7 +325,7 @@ char* StorageTableShare::createIndexName
 	else
 		{
 		char nameBuffer[indexNameSize];
-		cleanupFieldName(rawName, nameBuffer, sizeof(nameBuffer));
+		cleanupFieldName(rawName, nameBuffer, sizeof(nameBuffer), true);
 		sprintf(indexName, "%s$%s", name.getString(), nameBuffer);
 		}
 	

=== modified file 'storage/falcon/StorageTableShare.h'
--- a/storage/falcon/StorageTableShare.h	2008-10-22 20:44:09 +0000
+++ b/storage/falcon/StorageTableShare.h	2008-11-05 14:51:37 +0000
@@ -123,7 +123,7 @@ public:
 	virtual INT64		getSequenceValue(int delta);
 	virtual int			setSequenceValue(INT64 value);
 	virtual int			haveIndexes(int indexCount);
-	virtual const char*	cleanupFieldName(const char* name, char* buffer, int bufferLength);
+	virtual const char*	cleanupFieldName(const char* name, char* buffer, int bufferLength, bool doubleQuotes);
 	virtual void		setTablePath(const char* path, bool tempTable);
 	virtual void		registerCollation(const char* collationName, void* arg);
 

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

=== modified file 'storage/falcon/TableSpaceManager.cpp'
--- a/storage/falcon/TableSpaceManager.cpp	2008-09-22 09:24:39 +0000
+++ b/storage/falcon/TableSpaceManager.cpp	2008-11-05 17:58:43 +0000
@@ -58,7 +58,6 @@ TableSpaceManager::TableSpaceManager(Dat
 	memset(nameHash, 0, sizeof(nameHash));
 	memset(idHash, 0, sizeof(nameHash));
 	tableSpaces = NULL;
-	pendingDrops = 0;
 	syncObject.setName("TableSpaceManager::syncObject");
 }
 
@@ -156,7 +155,7 @@ TableSpace* TableSpaceManager::getTableS
 TableSpace* TableSpaceManager::createTableSpace(const char *name, const char *fileName, bool repository, TableSpaceInit *tsInit)
 {
 	Sync syncDDL(&database->syncSysDDL, "TableSpaceManager::createTableSpace");
-	syncDDL.lock(Shared);
+	syncDDL.lock(Exclusive);
 	Sequence *sequence = database->sequenceManager->getSequence(database->getSymbol("SYSTEM"), database->getSymbol("TABLESPACE_IDS"));
 	int type = (repository) ? TABLESPACE_TYPE_REPOSITORY : TABLESPACE_TYPE_TABLESPACE;
 	int id = (int) sequence->update(1, database->getSystemTransaction());
@@ -169,26 +168,26 @@ TableSpace* TableSpaceManager::createTab
 		throw SQLError(TABLESPACE_DATAFILE_EXIST_ERROR, "table space file name \"%s\" already exists\n", fileName);
 		}
 		
+	bool createdFile = false;
 	try
 		{
 		tableSpace->save();
 		
 		if (!repository)
 			tableSpace->create();
-			
-		syncDDL.unlock();
-		database->commitSystemTransaction();
+		createdFile = true;
 		add(tableSpace);
+		database->serialLog->logControl->createTableSpace.append(tableSpace);
 		}
 	catch (...)
 		{
+		if (createdFile)
+			IO::deleteFile(fileName);
+		database->rollbackSystemTransaction();
 		delete tableSpace;
-
 		throw;
 		}
-
-	database->serialLog->logControl->createTableSpace.append(tableSpace);
-	
+	database->commitSystemTransaction();
 	return tableSpace;
 }
 
@@ -298,13 +297,14 @@ void TableSpaceManager::dropTableSpace(T
 			break;
 			}
 			
-	pendingDrops++;
 	syncObj.unlock();
+	tableSpace->active = false;
+	JString filename = tableSpace->dbb->fileName;
 
 	database->serialLog->logControl->dropTableSpace.append(tableSpace, transaction);
 	database->commitSystemTransaction();
+	IO::deleteFile(filename);
 
-	tableSpace->active = false;
 }
 
 void TableSpaceManager::reportStatistics(void)
@@ -370,12 +370,10 @@ void TableSpaceManager::expungeTableSpac
 			}
 
 	sync.unlock();
-	tableSpace->dropTableSpace();
+	//File already deleted, just close the file descriptor
+	tableSpace->close();
 	delete tableSpace;
 
-	sync.lock(Exclusive);
-	if(pendingDrops >0)
-		pendingDrops--;
 }
 
 void TableSpaceManager::reportWrites(void)
@@ -565,26 +563,3 @@ void TableSpaceManager::getTableSpaceFil
 		}
 }
 
-
-// Wait for specified amount of time for a  file to be deleted.
-// Don't wait if pendingDrops count is 0.
-//
-// The function returns true, if wait was successfull, i.e file does not exist
-//(anymore)
-bool TableSpaceManager::waitForPendingDrop(const char  *filename, int seconds)
-{
-	bool fileExists;
-
-	do
-		{
-		fileExists = IO::doesFileExist(filename);
-		if (fileExists && pendingDrops > 0 && seconds-- > 0)
-			Thread::getThread("TransactionManager::waitForPendingDrop")->sleep(1000);
-		else
-			break;
-		}
-	while(true);
-
-	return !fileExists;
-}
-

=== modified file 'storage/falcon/TableSpaceManager.h'
--- a/storage/falcon/TableSpaceManager.h	2008-09-22 09:24:39 +0000
+++ b/storage/falcon/TableSpaceManager.h	2008-10-31 00:29:13 +0000
@@ -63,7 +63,6 @@ public:
 	void			reportWrites(void);
 	void			redoCreateTableSpace(int id, int nameLength, const char* name, int fileNameLength, const char* fileName, int type, TableSpaceInit* tsInit);
 	void			initialize(void);
-	bool			waitForPendingDrop(const char *filename, int seconds);
 
 	Database	*database;
 	TableSpace	*tableSpaces;
@@ -71,7 +70,6 @@ public:
 	TableSpace	*idHash[TS_HASH_SIZE];
 	SyncObject	syncObject;
 	void postRecovery(void);
-	int pendingDrops;
 };
 
 #endif // !defined(AFX_TABLESPACEMANAGER_H__BD1D39F6_2201_4136_899C_7CB106E99B8C__INCLUDED_)

=== modified file 'storage/falcon/Transaction.cpp'
--- a/storage/falcon/Transaction.cpp	2008-10-24 05:06:52 +0000
+++ b/storage/falcon/Transaction.cpp	2008-11-07 01:09:04 +0000
@@ -250,7 +250,8 @@ void Transaction::commit()
 
 	TransactionManager *transactionManager = database->transactionManager;
 	addRef();
-	Log::log(LogXARecovery, "%d: Commit transaction %d\n", database->deltaTime, transactionId);
+	Log::log(LogXARecovery, "%d: Commit %sTransaction %d\n", 
+		database->deltaTime, (systemTransaction ? "System " : ""),  transactionId);
 
 	if (state == Active)
 		{
@@ -340,6 +341,7 @@ void Transaction::commitNoUpdates(void)
 	TransactionManager *transactionManager = database->transactionManager;
 	addRef();
 	ASSERT(!deferredIndexes);
+	Log::log(LogXARecovery, "%d: CommitNoUpdates transaction %d\n", database->deltaTime, transactionId);
 	++transactionManager->committed;
 	
 	if (deferredIndexes)
@@ -384,6 +386,8 @@ void Transaction::rollback()
 	if (!isActive())
 		throw SQLEXCEPTION (RUNTIME_ERROR, "transaction is not active");
 
+	Log::log(LogXARecovery, "%d: Rollback transaction %d\n", database->deltaTime, transactionId);
+
 	if (deferredIndexes)
 		releaseDeferredIndexes();
 		
@@ -534,8 +538,19 @@ void Transaction::chillRecords()
 		
 	uint32 chilledBefore = chilledRecords;
 	uint64 totalDataBefore = totalRecordData;
+	
 	database->dbb->logUpdatedRecords(this, *chillPoint, true);
 	
+	// At the start of a chill operation, all savepoints are updated with the id of the
+	// savepoint being chilled. This ensures that each savepoint in a transaction always
+	// has a bitmap of savepoints that were chilled after it.
+
+	// When a savepoint is rolled back, those newer savepoints for which records have also
+	// been chilled are recorded in the serial log.
+
+	// The idea is that if savepoint N is rolled back, then chilled records attached to
+	// savepoints >= N	are ignored and not committed to the database.
+	
 	for (SavePoint *savePoint = savePoints; savePoint; savePoint = savePoint->next)
 		if (savePoint->id != curSavePointId)
 			savePoint->setIncludedSavepoint(curSavePointId);
@@ -951,6 +966,9 @@ void Transaction::writeComplete(void)
 	if (dependencies == 0)
 		commitRecords();
 
+//	Log::log(LogXARecovery, "%d: WriteComplete %sTransaction %d\n", 
+// 	database->deltaTime, (systemTransaction ? "System " : ""),  transactionId);
+
 	writePending = false;
 }
 
@@ -1093,6 +1111,8 @@ int Transaction::createSavepoint()
 	else
 		savePoint = new SavePoint;
 	
+	// The savepoint begins with the next record added to the transaction
+	
 	savePoint->records = (lastRecord) ? &lastRecord->nextInTrans : &firstRecord;
 	savePoint->id = ++curSavePointId;
 	savePoint->next = savePoints;
@@ -1117,10 +1137,13 @@ void Transaction::releaseSavepoint(int s
 	for (SavePoint **ptr = &savePoints, *savePoint; (savePoint = *ptr); ptr = &savePoint->next)
 		if (savePoint->id == savePointId)
 			{
+			
+			// Savepoints are linked in descending order, so the next lower id is next on the list
+			
 			int nextLowerSavePointId = (savePoint->next) ? savePoint->next->id : 0;
 			*ptr = savePoint->next;
 			
-			// If we have backed logged records, merge them in to the previous savepoint or the transaction itself.
+			// If we have backed logged records, merge them in to the previous savepoint or the transaction itself
 			
 			if (savePoint->backloggedRecords)
 				{
@@ -1148,7 +1171,8 @@ void Transaction::releaseSavepoint(int s
 			if (savePoint->savepoints)
 				savePoint->clear();
 
-			// commit pending record versions to the next pending savepoint
+			// This savepoint is no longer needed, so commit pending record versions to the next pending savepoint
+			// Scavenge prior record versions having 1) the same transaction and 2) savepoint >= the savepoint being released
 			
 			for (RecordVersion *record = *savePoint->records; record && record->savePointId == savePointId; record = record->nextInTrans)
 				{
@@ -1218,12 +1242,19 @@ void Transaction::rollbackSavepoint(int 
 	if ((savePoint) && (savePoint->id != savePointId))
 		throw SQLError(RUNTIME_ERROR, "invalid savepoint");
 
+	// Records within this savepoint or later may have been chilled and are
+	// already in the serial log, but they are now obsolete. To ensure that those
+	// records are not committed to the database, append the serial log with a SRLSavepointRollback
+	// record for this savepoint and for any greater savepoint that has been chilled.
+	
 	if (chilledRecords)
 		{
 		database->serialLog->logControl->savepointRollback.append(transactionId, savePointId);
 		
+		// SavePoint::savepoints is a bitmap of other savepoints that have been chilled
+		
 		if (savePoint->savepoints)
-			for (int n = 0; (n = savePoint->savepoints->nextSet(n)) >= 0; ++n)
+			for (int n = savePointId; (n = savePoint->savepoints->nextSet(n)) >= savePointId; ++n)
 				database->serialLog->logControl->savepointRollback.append(transactionId, n);
 		}				
 
@@ -1285,10 +1316,9 @@ void Transaction::rollbackSavepoint(int 
 		if (savePoint->backloggedRecords)
 			database->backLog->rollbackRecords(savePoint->backloggedRecords, this);
 				
-		// Move skipped savepoints object to the free list
-		// Leave the target savepoint empty, but connected to the transaction.
+		// Move skipped savepoint objects to the free list
 		
-		if (savePoint->id > savePointId)
+		if (savePoint->id >= savePointId)
 			{
 			savePoints = savePoint->next;
 			savePoint->next = freeSavePoints;

=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp	2008-10-26 08:45:22 +0000
+++ b/storage/falcon/ha_falcon.cpp	2008-11-13 13:27:13 +0000
@@ -35,6 +35,7 @@
 #include "InfoTable.h"
 #include "Format.h"
 #include "Error.h"
+#include "Log.h"
 
 #ifdef _WIN32
 #define I64FORMAT			"%I64d"
@@ -227,7 +228,9 @@ int StorageInterface::falcon_init(void *
 	falcon_hton->fill_is_table = StorageInterface::fill_is_table;
 	//falcon_hton->show_status  = StorageInterface::show_status;
 	falcon_hton->flags = HTON_NO_FLAGS;
+	falcon_debug_mask&= ~(LogMysqlInfo|LogMysqlWarning|LogMysqlError);
 	storageHandler->addNfsLogger(falcon_debug_mask, StorageInterface::logger, NULL);
+	storageHandler->addNfsLogger(LogMysqlInfo|LogMysqlWarning|LogMysqlError, StorageInterface::mysqlLogger, NULL);
 
 	if (falcon_debug_server)
 		storageHandler->startNfsServer();
@@ -344,7 +347,7 @@ uint falcon_strnxfrmlen(void *cs, const 
 	uint chrLen = falcon_strnchrlen(cs, s, srcLen);
 	int maxChrLen = partialKey ? min(chrLen, partialKey / charset->mbmaxlen) : chrLen;
 
-	return min(charset->coll->strnxfrmlen(charset, maxChrLen * charset->mbmaxlen), (uint) bufSize);
+	return (uint)min(charset->coll->strnxfrmlen(charset, maxChrLen * charset->mbmaxlen), (uint) bufSize);
 }
 
 // Return the number of bytes used in s to hold a certain number of characters.
@@ -372,7 +375,7 @@ uint falcon_strntrunc(void *cs, int part
 		charLimit--;
 		}
 
-	return ch - (uchar *) s;
+	return (uint)(ch - (uchar *) s);
 }
 
 int falcon_strnncoll(void *cs, const char *s1, uint l1, const char *s2, uint l2, char flag)
@@ -536,6 +539,10 @@ int StorageInterface::open(const char *n
 
 	int ret = storageTable->open();
 
+	if (ret == StorageErrorTableNotFound)
+		sql_print_error("Server is attempting to access a table %s,\n"
+				"which doesn't exist in Falcon.", name);
+
 	if (ret)
 		DBUG_RETURN(error(ret));
 
@@ -1025,6 +1032,10 @@ int StorageInterface::delete_table(const
 	storageTable->deleteStorageTable();
 	storageTable = NULL;
 
+	if (res == StorageErrorTableNotFound)
+		sql_print_error("Server is attempting to drop a table %s,\n"
+				"which doesn't exist in Falcon.", tableName);
+
 	// (hk) Fix for Bug#31465 Running Falcon test suite leads
 	//                        to warnings about temp tables
 	// This fix could affect other DROP TABLE scenarios.
@@ -1561,7 +1572,7 @@ int StorageInterface::rename_table(const
 	ret = storageShare->renameTable(storageConnection, to);
 	
 	if (!ret)
-	remapIndexes(table);
+		remapIndexes(table);
 	
 	storageShare->unlock();
 	storageShare->unlockIndexes();
@@ -1805,6 +1816,10 @@ int StorageInterface::error(int storageE
 			                    "Falcon does not support READ UNCOMMITTED ISOLATION, using REPEATABLE READ instead.");
 			break;
 
+		case StorageErrorIndexOverflow:
+			my_error(ER_TOO_LONG_KEY, MYF(0), max_key_length());
+			break;
+
 		default:
 			;
 		}
@@ -2397,6 +2412,16 @@ void StorageInterface::logger(int mask, 
 		}
 }
 
+void StorageInterface::mysqlLogger(int mask, const char* text, void* arg)
+{
+	if (mask & LogMysqlError)
+		sql_print_error("%s", text);
+	else if (mask & LogMysqlWarning)
+		sql_print_warning("%s", text);
+	else if (mask & LogMysqlInfo)
+		sql_print_information("%s", text);
+}
+
 int StorageInterface::setIndex(TABLE *table, int indexId)
 {
 	StorageIndexDesc indexDesc;
@@ -2482,7 +2507,7 @@ int StorageInterface::genTable(TABLE* ta
 		if (charset)
 			storageShare->registerCollation(charset->name, charset);
 
-		storageShare->cleanupFieldName(field->field_name, nameBuffer, sizeof(nameBuffer));
+		storageShare->cleanupFieldName(field->field_name, nameBuffer, sizeof(nameBuffer), true);
 		gen->gen("%s  \"%s\" ", sep, nameBuffer);
 		int ret = genType(field, gen);
 
@@ -2628,7 +2653,7 @@ void StorageInterface::genKeyFields(KEY*
 		{
 		KEY_PART_INFO *part = key->key_part + n;
 		Field *field = part->field;
-		storageShare->cleanupFieldName(field->field_name, nameBuffer, sizeof(nameBuffer));
+		storageShare->cleanupFieldName(field->field_name, nameBuffer, sizeof(nameBuffer), true);
 
 		if (part->key_part_flag & HA_PART_KEY_SEG)
 			gen->gen("%s\"%s\"(%d)", sep, nameBuffer, part->length);
@@ -3006,10 +3031,10 @@ bool StorageInterface::get_error_message
 	if (storageConnection)
 		{
 		const char *text = storageConnection->getLastErrorString();
-		buf->set(text, strlen(text), system_charset_info);
+		buf->set(text, (uint32)strlen(text), system_charset_info);
 		}
 	else if (errorText)
-		buf->set(errorText, strlen(errorText), system_charset_info);
+		buf->set(errorText, (uint32)strlen(errorText), system_charset_info);
 
 	return false;
 }
@@ -3516,6 +3541,7 @@ void StorageInterface::updateRecordScave
 void StorageInterface::updateDebugMask(MYSQL_THD thd, struct st_mysql_sys_var* variable, void* var_ptr, const void* save)
 {
 	falcon_debug_mask = *(uint*) save;
+	falcon_debug_mask&= ~(LogMysqlInfo|LogMysqlWarning|LogMysqlError);
 	storageHandler->deleteNfsLogger(StorageInterface::logger, NULL);
 	storageHandler->addNfsLogger(falcon_debug_mask, StorageInterface::logger, NULL);
 }
@@ -3553,7 +3579,7 @@ void StorageInterface::mapFields(TABLE *
 	for (uint n = 0; n < table->s->fields; ++n)
 		{
 		Field *field = table->field[n];
-		storageShare->cleanupFieldName(field->field_name, nameBuffer, sizeof(nameBuffer));
+		storageShare->cleanupFieldName(field->field_name, nameBuffer, sizeof(nameBuffer), false);
 		int id = storageShare->getFieldId(nameBuffer);
 		
 		if (id >= 0)

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

=== modified file 'storage/falcon/plug.in'
--- a/storage/falcon/plug.in	2008-09-23 09:08:59 +0000
+++ b/storage/falcon/plug.in	2008-11-03 08:56:28 +0000
@@ -4,6 +4,9 @@ MYSQL_PLUGIN_DIRECTORY(falcon, [storage/
 MYSQL_PLUGIN_STATIC(falcon,    [libfalcon.a])
 MYSQL_PLUGIN_DYNAMIC(falcon,   [ha_falcon.la])
 
+# Check if we have the atomic_* functions on Solaris
+AC_CHECK_FUNC(atomic_cas_32, AC_DEFINE([HAVE_SOLARIS_ATOMIC], [1], [Define to 1 if Solaris support atomic functions.]))
+
 # Check for supported machine types.
 AC_CACHE_CHECK([if Falcon Storage Engine is supported on $MACHINE_TYPE],
   			   falcon_supported_by_machine,[

Thread
bzr push into mysql-6.0 branch (vvaintroub:2681 to 2683)Vladislav Vaintroub5 Dec