MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Andrei Elkin Date:November 24 2008 2:05pm
Subject:bzr commit into mysql-6.0-rpl branch (aelkin:2736)
View as plain text  
#At file:///home/andrei/MySQL/BZR/MERGE/mysql-6.0-rpl/

 2736 Andrei Elkin	2008-11-24 [merge]
      merge 6.0 main -> rpl
removed:
  mysql-test/suite/falcon_team/r/falcon_bug_28095_II.result
  mysql-test/suite/falcon_team/t/falcon_bug_28095_II-master.opt
  mysql-test/suite/falcon_team/t/falcon_bug_28095_II.test
added:
  mysql-test/include/restart_mysqld.inc
  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
renamed:
  mysql-test/include/restart_mysqld.inc => mysql-test/include/restart_mysqld.inc.moved
  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.cc
  configure.in
  mysql-test/include/wait_until_connected_again.inc
  mysql-test/suite/backup/t/disabled.def
  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
  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

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2008-11-14 20:47:02 +0000
+++ b/client/mysqltest.cc	2008-11-24 14:05:43 +0000
@@ -276,8 +276,8 @@ enum enum_commands {
   Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST,
   Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, Q_SKIP,
   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_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.   */

=== modified file 'configure.in'
--- a/configure.in	2008-11-19 17:29:41 +0000
+++ b/configure.in	2008-11-24 14:05:43 +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
+

=== renamed file 'mysql-test/include/restart_mysqld.inc' => 'mysql-test/include/restart_mysqld.inc.moved'
=== modified file 'mysql-test/include/wait_until_connected_again.inc'
--- a/mysql-test/include/wait_until_connected_again.inc	2008-07-22 18:08:06 +0000
+++ b/mysql-test/include/wait_until_connected_again.inc	2008-11-24 14:05:43 +0000
@@ -4,7 +4,7 @@
 # You should have done --enable_reconnect first
 --disable_result_log
 --disable_query_log
-let $counter= 300;
+let $counter= 600;
 let $mysql_errno= 9999;
 while ($mysql_errno)
 {
@@ -19,7 +19,7 @@ while ($mysql_errno)
   {
     --die Server failed to restart
   }
-  --sleep 0.1
+  --real_sleep 0.1
 }
 --enable_query_log
 --enable_result_log

=== 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-18 21:10:05 +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

=== 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;

=== 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;

=== 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;

=== removed file 'mysql-test/suite/falcon_team/r/falcon_bug_28095_II.result'
--- a/mysql-test/suite/falcon_team/r/falcon_bug_28095_II.result	2008-06-10 22:27:52 +0000
+++ b/mysql-test/suite/falcon_team/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;

=== removed file 'mysql-test/suite/falcon_team/t/falcon_bug_28095_II-master.opt'
--- a/mysql-test/suite/falcon_team/t/falcon_bug_28095_II-master.opt	2008-06-10 22:27:52 +0000
+++ b/mysql-test/suite/falcon_team/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_team/t/falcon_bug_28095_II.test'
--- a/mysql-test/suite/falcon_team/t/falcon_bug_28095_II.test	2008-06-10 22:27:52 +0000
+++ b/mysql-test/suite/falcon_team/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;

=== 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 commit into mysql-6.0-rpl branch (aelkin:2736) Andrei Elkin24 Nov