List:Maria Storage Engine« Previous MessageNext Message »
From:Michael Widenius Date:June 26 2008 9:32am
Subject:bzr commit into MySQL/Maria:mysql-maria branch (monty:2645)
View as plain text  
#At bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/

 2645 Michael Widenius	2008-06-26 [merge]
      Merge; No notable changes
added:
  mysql-test/r/maria-no-logging.result
  mysql-test/r/maria2.result
  mysql-test/t/maria-no-logging.test
  mysql-test/t/maria2.test
modified:
  .bzr-mysql/default.conf
  config/ac-macros/plugins.m4
  configure.in
  include/my_global.h
  mysql-test/include/maria_empty_logs.inc
  mysql-test/r/maria-page-checksum.result
  mysql-test/r/maria-recover.result
  mysql-test/t/maria-page-checksum.test
  mysql-test/t/maria-purge.test
  mysql-test/t/maria-recover.test
  sql/sql_table.cc
  storage/maria/CMakeLists.txt
  storage/maria/ma_ft_parser.c
  storage/maria/ma_loghandler.c
  storage/maria/ma_recovery.c
  storage/maria/ma_rt_test.c
  storage/maria/ma_state.c
  storage/maria/ma_test_force_start.pl
  storage/maria/plug.in
  storage/maria/unittest/CMakeLists.txt
  storage/maria/unittest/Makefile.am
  storage/maria/unittest/ma_test_all-t
  storage/maria/unittest/ma_test_loghandler_multithread-t.c
  storage/maria/unittest/ma_test_recovery.pl
  storage/myisam/rt_test.c

per-file comments:
  .bzr-mysql/default.conf
    Automatic merge
  config/ac-macros/plugins.m4
    Automatic merge
  configure.in
    Automatic merge
  include/my_global.h
    Automatic merge
  mysql-test/include/maria_empty_logs.inc
    Use Guilmhems version, but don't echo use database
  mysql-test/r/maria-no-logging.result
    Automatic merge
  mysql-test/r/maria-page-checksum.result
    Automatic merge
  mysql-test/r/maria-recover.result
    Automatic merge
  mysql-test/r/maria2.result
    Automatic merge
  mysql-test/t/maria-no-logging.test
    Automatic merge
  mysql-test/t/maria-page-checksum.test
    Automatic merge
  mysql-test/t/maria-purge.test
    Automatic merge
  mysql-test/t/maria-recover.test
    Automatic merge
  mysql-test/t/maria2.test
    Automatic merge
  sql/sql_table.cc
    Automatic merge
  storage/maria/CMakeLists.txt
    Automatic merge
  storage/maria/ma_ft_parser.c
    Automatic merge
  storage/maria/ma_loghandler.c
    Automatic merge
  storage/maria/ma_recovery.c
    Automatic merge
  storage/maria/ma_rt_test.c
    Manual merge
  storage/maria/ma_state.c
    Automatic merge
  storage/maria/ma_test_force_start.pl
    Automatic merge
  storage/maria/plug.in
    Automatic merge
  storage/maria/unittest/CMakeLists.txt
    Automatic merge
  storage/maria/unittest/Makefile.am
    Automatic merge
  storage/maria/unittest/ma_test_all-t
    Automatic merge
  storage/maria/unittest/ma_test_loghandler_multithread-t.c
    Automatic merge
  storage/maria/unittest/ma_test_recovery.pl
    Automatic merge
  storage/myisam/rt_test.c
    Automatic merge
=== modified file '.bzr-mysql/default.conf'
--- a/.bzr-mysql/default.conf	2008-06-02 21:13:27 +0000
+++ b/.bzr-mysql/default.conf	2008-06-10 20:21:08 +0000
@@ -1,6 +1,6 @@
 [MYSQL]
 tree_location = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/
-post_commit_to = maria-private@stripped
+post_commit_to = maria@stripped
 post_commit_url = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/
 tree_name = mysql-maria
 project_name = MySQL/Maria

=== modified file 'config/ac-macros/plugins.m4'
--- a/config/ac-macros/plugins.m4	2007-12-16 15:03:44 +0000
+++ b/config/ac-macros/plugins.m4	2008-06-05 19:48:43 +0000
@@ -280,7 +280,7 @@ dnl ------------------------------------
 dnl Macro: MYSQL_CONFIGURE_PLUGINS
 dnl
 dnl SYNOPSIS
-dnl   MYSQL_PLUGIN_DEPENDS([name,name...])
+dnl   MYSQL_CONFIGURE_PLUGINS([name,name...])
 dnl
 dnl DESCRIPTION
 dnl   Used last, emits all required shell code to configure the plugins
@@ -735,13 +735,13 @@ dnl   Emits shell script for checking co
 dnl   Arguments to this macro is default value for selected plugins
 
 AC_DEFUN([_MYSQL_CHECK_PLUGIN_ARGS],[
- __MYSQL_CHECK_PLUGIN_ARGS(m4_default([$1], [none]))
+ __MYSQL_CHECK_PLUGIN_ARGS(m4_default([$1], [default]))
 ])
 
 AC_DEFUN([__MYSQL_CHECK_PLUGIN_ARGS],[
  AC_ARG_WITH([plugins],
 AS_HELP_STRING([--with-plugins=PLUGIN[[[[[,PLUGIN..]]]]]],
-               [Plugins to include in mysqld. (default is: $1) Must be a
+               [Plugins to include in mysqld. Must be a
                 configuration name or a comma separated list of plugins.])
 AS_HELP_STRING([],
                [Available configurations are:] dnl

=== modified file 'configure.in'
--- a/configure.in	2008-05-14 06:51:30 +0000
+++ b/configure.in	2008-06-05 19:48:43 +0000
@@ -2387,7 +2387,7 @@ MYSQL_STORAGE_ENGINE(partition, partitio
 
 dnl -- ndbcluster requires partition to be enabled
 
-MYSQL_CONFIGURE_PLUGINS([none])
+MYSQL_CONFIGURE_PLUGINS([default])
 
 # Only build client code?
 AC_ARG_WITH(server,

=== modified file 'include/my_global.h'
--- a/include/my_global.h	2008-04-28 16:24:05 +0000
+++ b/include/my_global.h	2008-06-10 14:44:44 +0000
@@ -156,9 +156,14 @@
 #define __builtin_expect(x, expected_value) (x)
 #endif
 
-#define likely(x)	__builtin_expect((x),1)
-#define unlikely(x)	__builtin_expect((x),0)
-
+/**
+  The semantics of builtin_expect() are that
+  1) its two arguments are long
+  2) it's likely that they are ==
+  Those of our likely(x) are that x can be bool/int/longlong/pointer.
+*/
+#define likely(x)	__builtin_expect(((x) != 0),1)
+#define unlikely(x)	__builtin_expect(((x) != 0),0)
 
 /*
   The macros below are useful in optimising places where it has been

=== modified file 'mysql-test/include/maria_empty_logs.inc'
--- a/mysql-test/include/maria_empty_logs.inc	2008-06-26 05:18:28 +0000
+++ b/mysql-test/include/maria_empty_logs.inc	2008-06-26 09:32:22 +0000
@@ -4,10 +4,10 @@
 # API: set mel_keep_control_file=1 if want to keep control file;
 # uses vardir, port and socket.
 
-connection admin;
-
-let $current_database= `select database()`;
+connection default;
+let $default_db=`select database()`;
 
+connection admin;
 -- echo * shut down mysqld, removed logs, restarted it
 append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
 wait-maria_empty_logs.inc
@@ -73,5 +73,5 @@ EOF
 connection default;
 # Restore current database as the effect of "use" was lost after restart
 --disable_query_log
-eval use $current_database;
+eval use $default_db;
 --enable_query_log

=== added file 'mysql-test/r/maria-no-logging.result'
--- a/mysql-test/r/maria-no-logging.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/maria-no-logging.result	2008-06-26 09:32:22 +0000
@@ -0,0 +1,51 @@
+set global maria_log_file_size=4294967295;
+drop database if exists mysqltest;
+create database mysqltest;
+use mysqltest;
+set global maria_checkpoint_interval=0;
+create table t2 (a varchar(100)) engine=myisam;
+insert into t2 select repeat('z',100);
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+* shut down mysqld, removed logs, restarted it
+create table t1 (a varchar(100)) engine=maria transactional=1;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(100) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+show engine maria logs;
+Type	Name	Status
+MARIA	Size        16384 maria_log.00000001	unknown
+insert into t1 values('a');
+insert into t1 select * from t2;
+show engine maria logs;
+Type	Name	Status
+MARIA	Size        24576 maria_log.00000001	unknown
+* shut down mysqld, removed logs, restarted it
+truncate table t1;
+insert into t1 select * from t2;
+show engine maria logs;
+Type	Name	Status
+MARIA	Size        16384 maria_log.00000001	unknown
+drop table t1;
+* shut down mysqld, removed logs, restarted it
+create table t1 (a varchar(100)) engine=maria transactional=1;
+insert into t1 values('a');
+create table if not exists t1 select * from t2;
+Warnings:
+Note	1050	Table 't1' already exists
+show engine maria logs;
+Type	Name	Status
+MARIA	Size        24576 maria_log.00000001	unknown
+* shut down mysqld, removed logs, restarted it
+drop table t1;
+create table t1 engine=maria transactional=1 select * from t2;
+show engine maria logs;
+Type	Name	Status
+MARIA	Size        16384 maria_log.00000001	unknown
+drop database mysqltest;

=== modified file 'mysql-test/r/maria-page-checksum.result'
--- a/mysql-test/r/maria-page-checksum.result	2008-04-10 02:26:36 +0000
+++ b/mysql-test/r/maria-page-checksum.result	2008-06-11 20:45:14 +0000
@@ -650,3 +650,291 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
 Page checksums are used
 drop table t1;
+# iteration 1
+create table t1(a int) engine=maria  ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+Crashsafe:           yes
+alter table t1 modify a bigint ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` bigint(20) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+Crashsafe:           yes
+drop table t1;
+# iteration 2
+create table t1(a int) engine=maria  ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+Crashsafe:           yes
+alter table t1  transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+drop table t1;
+# iteration 3
+create table t1(a int) engine=maria  ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+Crashsafe:           yes
+alter table t1  transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+drop table t1;
+# iteration 4
+create table t1(a int) engine=maria  ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+Crashsafe:           yes
+alter table t1 engine=maria  ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+Crashsafe:           yes
+drop table t1;
+# iteration 5
+create table t1(a int) engine=maria  ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+Crashsafe:           yes
+alter table t1 engine=maria transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+drop table t1;
+# iteration 6
+create table t1(a int) engine=maria  ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+Crashsafe:           yes
+alter table t1 engine=maria transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+drop table t1;
+# iteration 7
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+alter table t1 modify a bigint ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` bigint(20) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+drop table t1;
+# iteration 8
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+alter table t1  transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+drop table t1;
+# iteration 9
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+alter table t1  transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+drop table t1;
+# iteration 10
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+alter table t1 engine=maria  ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+drop table t1;
+# iteration 11
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+alter table t1 engine=maria transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+drop table t1;
+# iteration 12
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+alter table t1 engine=maria transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+drop table t1;
+# iteration 13
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+alter table t1 modify a bigint ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` bigint(20) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+drop table t1;
+# iteration 14
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+alter table t1  transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+drop table t1;
+# iteration 15
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+alter table t1  transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+drop table t1;
+# iteration 16
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+alter table t1 engine=maria  ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+drop table t1;
+# iteration 17
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+alter table t1 engine=maria transactional=0 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=0
+Crashsafe:           no
+drop table t1;
+# iteration 18
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+alter table t1 engine=maria transactional=1 ;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
+Crashsafe:           yes
+drop table t1;

=== modified file 'mysql-test/r/maria-recover.result'
--- a/mysql-test/r/maria-recover.result	2008-06-04 08:43:12 +0000
+++ b/mysql-test/r/maria-recover.result	2008-06-16 08:57:25 +0000
@@ -24,7 +24,7 @@ select * from t_corrupted2;
 a
 ThursdayMorningsMarket
 Warnings:
-Error	145	Table './mysqltest/t_corrupted2' is marked as crashed and should be repaired
+Error	145	Table '.t_corrupted2' is marked as crashed and should be repaired
 Error	1194	Table 't_corrupted2' is marked as crashed and should be repaired
 Error	1034	1 client is using or hasn't closed the table properly
 Error	1034	Wrong base information on indexpage at page: 1

=== added file 'mysql-test/r/maria2.result'
--- a/mysql-test/r/maria2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/maria2.result	2008-06-10 14:44:44 +0000
@@ -0,0 +1,18 @@
+CREATE TABLE t1 (
+line BLOB,
+kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po',
+name VARCHAR(32)
+) transactional=0 row_format=page engine=maria;
+select count(*) from t1;
+count(*)
+810
+delete from t1 limit 1000;
+select count(*) from t1;
+count(*)
+0
+select name from t1;
+name
+check table t1 extended;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+drop table t1;

=== added file 'mysql-test/t/maria-no-logging.test'
--- a/mysql-test/t/maria-no-logging.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/maria-no-logging.test	2008-06-06 13:37:16 +0000
@@ -0,0 +1,81 @@
+# test of cases where we can safely disable logging
+
+--source include/have_maria.inc
+
+set global maria_log_file_size=4294967295;
+
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+create database mysqltest;
+
+connect (admin, 127.0.0.1, root,,mysqltest,,);
+--enable_reconnect
+
+connection default;
+use mysqltest;
+--enable_reconnect
+
+# checkpoints can make log unrepeatable
+let $def_checkinterval=`select @@global.maria_checkpoint_interval`;
+set global maria_checkpoint_interval=0;
+
+# Prepare table to help for big load
+create table t2 (a varchar(100)) engine=myisam;
+insert into t2 select repeat('z',100);
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+
+# INSERT SELECT
+
+# no optimization because table not empty
+
+# SHOW ENGINE MARIA LOGS could be influenced by older logs
+-- source include/maria_empty_logs.inc
+create table t1 (a varchar(100)) engine=maria transactional=1;
+show create table t1;
+--replace_regex /; .+maria_log/maria_log/
+show engine maria logs;
+
+insert into t1 values('a');
+insert into t1 select * from t2;
+--replace_regex /; .+maria_log/maria_log/
+show engine maria logs;
+
+# optimization because table is empty
+-- source include/maria_empty_logs.inc
+truncate table t1;
+insert into t1 select * from t2;
+--replace_regex /; .+maria_log/maria_log/
+show engine maria logs;
+
+drop table t1;
+
+# same for CREATE SELECT
+
+# no optimization because table not empty
+-- source include/maria_empty_logs.inc
+create table t1 (a varchar(100)) engine=maria transactional=1;
+insert into t1 values('a');
+create table if not exists t1 select * from t2;
+--replace_regex /; .+maria_log/maria_log/
+show engine maria logs;
+
+# optimization because table is empty
+-- source include/maria_empty_logs.inc
+drop table t1;
+create table t1 engine=maria transactional=1 select * from t2;
+--replace_regex /; .+maria_log/maria_log/
+show engine maria logs;
+
+drop database mysqltest;
+
+--disable_result_log
+--disable_query_log
+eval set global maria_checkpoint_interval=$def_checkinterval;
+--enable_result_log
+--enable_query_log

=== modified file 'mysql-test/t/maria-page-checksum.test'
--- a/mysql-test/t/maria-page-checksum.test	2008-05-29 15:33:33 +0000
+++ b/mysql-test/t/maria-page-checksum.test	2008-06-11 20:45:14 +0000
@@ -1,7 +1,5 @@
-#
-# This can't be run with --extern as we are acccessing the tables in the
-# database directly
-#
+# Tests for two bugs related to ALTER TABLE and maria-specific alter
+# options (PAGE_CHECKSUM and TRANSACTIONAL).
 
 -- source include/have_maria.inc
 
@@ -9,8 +7,16 @@
 drop table if exists t1;
 --enable_warnings
 
+#
+# Test for BUG#35441 "Cannot change PAGE_CHECKSUM table option"
+#
+
 select @@global.maria_page_checksum;
 
+# we scan through combinations in the cartesian product of
+# (first value of maria_page_checksum) x (clauses in CREATE TABLE) x
+# (second value of maria_page_checksum) x (clauses in ALTER TABLE).
+
 --echo # iteration 1
 set global maria_page_checksum = 0 ;
 create table t1(a int) engine=maria  ;
@@ -1054,3 +1060,498 @@ perl;
     close FILE;
 EOF
 drop table t1;
+
+#
+# Test for BUG#37005
+# "Maria: ALTER TABLE TRANSACTIONAL=0 leaves table transactional inside Maria"
+#
+
+# we scan through combinations in the cartesian product of
+# (clauses in CREATE TABLE) x (clauses in ALTER TABLE).
+
+--echo # iteration 1
+create table t1(a int) engine=maria  ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 modify a bigint ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 2
+create table t1(a int) engine=maria  ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1  transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 3
+create table t1(a int) engine=maria  ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1  transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 4
+create table t1(a int) engine=maria  ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 engine=maria  ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 5
+create table t1(a int) engine=maria  ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 engine=maria transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 6
+create table t1(a int) engine=maria  ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 engine=maria transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 7
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 modify a bigint ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 8
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1  transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 9
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1  transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 10
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 engine=maria  ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 11
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 engine=maria transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 12
+create table t1(a int) engine=maria transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 engine=maria transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 13
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 modify a bigint ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 14
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1  transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 15
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1  transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 16
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 engine=maria  ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 17
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 engine=maria transactional=0 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+
+--echo # iteration 18
+create table t1(a int) engine=maria transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+
+alter table t1 engine=maria transactional=1 ;
+show create table t1;
+--exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/test/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
+perl;
+    use strict;
+    use warnings;
+    my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/mariachk.txt";
+    open(FILE, "<", $fname) or die;
+    print grep(/Crashsafe/, <FILE>);
+    close FILE;
+EOF
+drop table t1;
+
+

=== modified file 'mysql-test/t/maria-purge.test'
--- a/mysql-test/t/maria-purge.test	2008-06-26 05:18:28 +0000
+++ b/mysql-test/t/maria-purge.test	2008-06-26 09:32:22 +0000
@@ -1,13 +1,18 @@
 -- source include/have_maria.inc
 -- source include/big_test.inc
 
-#
-# Empty logs to get log file numbers repeatable
+# pre-requisites for maria_empty_logs
+connect (admin, 127.0.0.1, root,,test,,);
 #
 --enable_reconnect
-connect (admin, localhost, root,,);
+connection default;
 --enable_reconnect
---source include/maria_empty_logs.inc
+# end of pre-requisites
+
+# SHOW ENGINE MARIA LOGS could be influenced by older logs
+# Also, possibly automatic checkpoints (see if that happens in
+# practice)
+-- source include/maria_empty_logs.inc
 
 let $default=`select @@global.storage_engine`;
 set global storage_engine=maria;
@@ -56,6 +61,7 @@ insert into t2 select * from t1;
 insert into t1 select * from t2;
 
 set global maria_log_file_size=16777216;
+# force a checkpoint to allow log purge
 eval set global maria_checkpoint_interval=$def_checkinterval;
 --replace_regex /Size +[0-9]+ ; .+master-data/master-data/
 SHOW ENGINE maria logs;

=== modified file 'mysql-test/t/maria-recover.test'
--- a/mysql-test/t/maria-recover.test	2008-06-04 08:43:12 +0000
+++ b/mysql-test/t/maria-recover.test	2008-06-16 08:57:25 +0000
@@ -48,6 +48,7 @@ EOF
 
 # line below will be removed
 disable_ps_protocol;
+replace_regex /.mysqltest.t_corrupted2/t_corrupted2/ ;
 select * from t_corrupted2; # should show corruption and repair messages
 enable_ps_protocol;
 select * from t_corrupted2; # should show just rows

=== added file 'mysql-test/t/maria2.test'
--- a/mysql-test/t/maria2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/maria2.test	2008-06-10 14:44:44 +0000
@@ -0,0 +1,66 @@
+--source include/have_maria.inc
+
+# Test for BUG#36319
+# "Maria: table is not empty but DELETE and SELECT find no rows"
+
+CREATE TABLE t1 (
+  line BLOB,
+  kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po',
+  name VARCHAR(32)
+) transactional=0 row_format=page engine=maria;
+
+let $query=   INSERT INTO t1 (name, kind, line) VALUES 
+  ("Aadaouane", "pp", GeomFromText("POINT(32.816667 35.983333)")),
+  ("Aadassiye", "pp", GeomFromText("POINT(35.816667 36.216667)")),
+  ("Aadbel", "pp", GeomFromText("POINT(34.533333 36.100000)")),
+  ("Aadchit", "pp", GeomFromText("POINT(33.347222 35.423611)")),
+  ("Aadchite", "pp", GeomFromText("POINT(33.347222 35.423611)")),
+  ("Aadchit el Qoussair", "pp", GeomFromText("POINT(33.283333 35.483333)")),
+  ("Aaddaye", "pp", GeomFromText("POINT(36.716667 40.833333)")),
+  ("'Aadeissa", "pp", GeomFromText("POINT(32.823889 35.698889)")),
+  ("Aaderup", "pp", GeomFromText("POINT(55.216667 11.766667)")),
+  ("Qalaat Aades", "pp", GeomFromText("POINT(33.503333 35.377500)")),
+  ("A ad'ino", "pp", GeomFromText("POINT(54.812222 38.209167)")),
+  ("Aadi Noia", "pp", GeomFromText("POINT(13.800000 39.833333)")),
+  ("Aad La Macta", "pp", GeomFromText("POINT(35.779444 -0.129167)")),
+  ("Aadland", "pp", GeomFromText("POINT(60.366667 5.483333)")),
+  ("Aadliye", "pp", GeomFromText("POINT(33.366667 36.333333)")),
+  ("Aadloun", "pp", GeomFromText("POINT(33.403889 35.273889)")),
+  ("Aadma", "pp", GeomFromText("POINT(58.798333 22.663889)")),
+  ("Aadma Asundus", "pp", GeomFromText("POINT(58.798333 22.663889)")),
+  ("Aadmoun", "pp", GeomFromText("POINT(34.150000 35.650000)")),
+  ("Aadneram", "pp", GeomFromText("POINT(59.016667 6.933333)")),
+  ("Aadneskaar", "pp", GeomFromText("POINT(58.083333 6.983333)")),
+  ("Aadorf", "pp", GeomFromText("POINT(47.483333 8.900000)")),
+  ("Aadorp", "pp", GeomFromText("POINT(52.366667 6.633333)")),
+  ("Aadouane", "pp", GeomFromText("POINT(32.816667 35.983333)")),
+  ("Aadoui", "pp", GeomFromText("POINT(34.450000 35.983333)")),
+  ("Aadouiye", "pp", GeomFromText("POINT(34.583333 36.183333)")),
+  ("Aadouss", "pp", GeomFromText("POINT(33.512500 35.601389)")),
+  ("Aadra", "pp", GeomFromText("POINT(33.616667 36.500000)")),
+  ("Aadzi", "pp", GeomFromText("POINT(38.100000 64.850000)"));
+
+--disable_query_log
+let $1=90;
+while($1)
+{
+  eval $query;
+  dec $1;
+}
+let $1=90;
+while($1)
+{
+  delete from t1 limit 1;
+  delete from t1 limit 10;
+  delete from t1 limit 7;
+  delete from t1 limit 2;
+  dec $1;
+}
+--enable_query_log
+
+select count(*) from t1;
+delete from t1 limit 1000;
+select count(*) from t1;
+select name from t1;
+check table t1 extended;
+drop table t1;

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2008-05-29 18:39:25 +0000
+++ b/sql/sql_table.cc	2008-06-11 20:45:14 +0000
@@ -5229,6 +5229,7 @@ compare_tables(TABLE *table,
       create_info->used_fields & HA_CREATE_USED_DEFAULT_CHARSET ||
       create_info->used_fields & HA_CREATE_USED_ROW_FORMAT ||
       create_info->used_fields & HA_CREATE_USED_PAGE_CHECKSUM ||
+      create_info->used_fields & HA_CREATE_USED_TRANSACTIONAL ||
       (alter_info->flags & (ALTER_RECREATE | ALTER_FOREIGN_KEY)) ||
       order_num ||
       !table->s->mysql_version ||

=== modified file 'storage/maria/CMakeLists.txt'
--- a/storage/maria/CMakeLists.txt	2008-04-22 10:04:18 +0000
+++ b/storage/maria/CMakeLists.txt	2008-06-09 09:06:06 +0000
@@ -24,7 +24,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/
 SET(MARIA_SOURCES ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c 
             ma_rnext.c ma_rnext_same.c 
             ma_search.c ma_page.c ma_key_recover.c ma_key.c 
-            ma_locking.c 
+            ma_locking.c ma_state.c
             ma_rrnd.c ma_scan.c ma_cache.c 
             ma_statrec.c ma_packrec.c ma_dynrec.c 
             ma_blockrec.c ma_bitmap.c 

=== modified file 'storage/maria/ma_ft_parser.c'
--- a/storage/maria/ma_ft_parser.c	2008-04-03 13:40:25 +0000
+++ b/storage/maria/ma_ft_parser.c	2008-06-24 14:14:56 +0000
@@ -114,7 +114,8 @@ uchar maria_ft_get_word(CHARSET_INFO *cs
 {
   uchar *doc=*start;
   int ctype;
-  uint mwc, length, mbl;
+  uint mwc, length;
+  int mbl;
 
   param->yesno=(FTB_YES==' ') ? 1 : (param->quot != 0);
   param->weight_adjust= param->wasign= 0;
@@ -122,7 +123,7 @@ uchar maria_ft_get_word(CHARSET_INFO *cs
 
   while (doc<end)
   {
-    for (; doc < end; doc+= (mbl > 0 ? mbl : 1))
+    for (; doc < end; doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1)))
     {
       mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
       if (true_word_char(ctype, *doc))
@@ -140,7 +141,8 @@ uchar maria_ft_get_word(CHARSET_INFO *cs
         {
           /* param->prev=' '; */
           *start=doc+1;
-          if (*doc == FTB_LQUOT) param->quot= (char *) *start;
+          if (*doc == FTB_LQUOT)
+            param->quot= (char *) *start;
           param->type= (*doc == FTB_RBR ? FT_TOKEN_RIGHT_PAREN : FT_TOKEN_LEFT_PAREN);
           goto ret;
         }
@@ -160,7 +162,8 @@ uchar maria_ft_get_word(CHARSET_INFO *cs
     }
 
     mwc=length=0;
-    for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : 1))
+    for (word->pos= doc; doc < end; length++,
+         doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1)))
     {
       mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
       if (true_word_char(ctype, *doc))
@@ -205,13 +208,13 @@ uchar maria_ft_simple_get_word(CHARSET_I
                                my_bool skip_stopwords)
 {
   uchar *doc= *start;
-  uint mwc, length, mbl;
-  int ctype;
+  uint mwc, length;
+  int ctype, mbl;
   DBUG_ENTER("maria_ft_simple_get_word");
 
   do
   {
-    for (;; doc+= (mbl > 0 ? mbl : 1))
+    for (;; doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1)))
     {
       if (doc >= end)
         DBUG_RETURN(0);
@@ -221,7 +224,8 @@ uchar maria_ft_simple_get_word(CHARSET_I
     }
 
     mwc= length= 0;
-    for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : 1))
+    for (word->pos= doc; doc < end; length++,
+         doc+= (mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1)))
     {
       mbl= cs->cset->ctype(cs, &ctype, doc, end);
       if (true_word_char(ctype, *doc))
@@ -393,7 +397,9 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_cal
        mysql_add_word == 0 - parser is not initialized
        mysql_add_word != 0 - parser is initialized, or no
                              initialization needed. */
-    info->ftparser_param[ftparser_nr].mysql_add_word= (void *)1;
+    info->ftparser_param[ftparser_nr].mysql_add_word=
+      (int (*)(struct st_mysql_ftparser_param *, char *, int,
+               MYSQL_FTPARSER_BOOLEAN_INFO *)) 1;
     if (parser->init && parser->init(&info->ftparser_param[ftparser_nr]))
       return 0;
   }

=== modified file 'storage/maria/ma_loghandler.c'
--- a/storage/maria/ma_loghandler.c	2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_loghandler.c	2008-06-26 09:32:22 +0000
@@ -77,9 +77,12 @@ typedef union
   normal circumstances (less then half of one and full other, or just
   switched one and other), But if we met end of the file in the middle and
   have to switch buffer it will be 3.  + 1 buffer for flushing/writing.
-  We have a bigger number here for higher concurrency.
+  We have a bigger number here for higher concurrency and to make division
+  faster.
+
+  The number should be power of 2 to be fast.
 */
-#define TRANSLOG_BUFFERS_NO 5
+#define TRANSLOG_BUFFERS_NO 8
 /* number of bytes (+ header) which can be unused on first page in sequence */
 #define TRANSLOG_MINCHUNK_CONTENT 1
 /* version of log file */
@@ -100,7 +103,13 @@ struct st_translog_buffer
     pagecache_inject()
   */
   uchar buffer[TRANSLOG_WRITE_BUFFER];
+  /*
+    Maximum LSN of records which ends in this buffer (or IMPOSSIBLE_LSN
+    if no LSNs ends here)
+  */
   LSN last_lsn;
+  /* last_lsn of previous buffer or IMPOSSIBLE_LSN if it is very first one */
+  LSN prev_last_lsn;
   /* This buffer offset in the file */
   TRANSLOG_ADDRESS offset;
   /*
@@ -128,9 +137,7 @@ struct st_translog_buffer
     content of page which present in both buffers)
   */
   struct st_translog_buffer *overlay;
-#ifndef DBUG_OFF
   uint buffer_no;
-#endif
   /*
     Lock for the buffer.
 
@@ -197,6 +204,8 @@ struct st_buffer_cursor
 };
 
 
+typedef uint8 dirty_buffer_mask_t;
+
 struct st_translog_descriptor
 {
   /* *** Parameters of the log handler *** */
@@ -245,6 +254,10 @@ struct st_translog_descriptor
   File directory_fd;
   /* buffers for log writing */
   struct st_translog_buffer buffers[TRANSLOG_BUFFERS_NO];
+  /* Mask where 1 in position N mean that buffer N is not flushed */
+  dirty_buffer_mask_t dirty_buffer_mask;
+  /* The above variable protection */
+  pthread_mutex_t dirty_buffer_mask_lock;
   /*
      horizon - visible end of the log (here is absolute end of the log:
      position where next chunk can start
@@ -276,6 +289,7 @@ struct st_translog_descriptor
     be removed in v1.5
   */
   pthread_mutex_t log_flush_lock;
+  pthread_cond_t log_flush_cond;
 
   /* Protects changing of headers of finished files (max_lsn) */
   pthread_mutex_t file_header_lock;
@@ -303,6 +317,11 @@ struct st_translog_descriptor
     is generated.
   */
   my_bool is_everything_flushed;
+  /* True when flush pass is in progress */
+  my_bool flush_in_progress;
+  /* Next flush pass variables */
+  TRANSLOG_ADDRESS next_pass_max_lsn;
+  pthread_t max_lsn_requester;
 };
 
 static struct st_translog_descriptor log_descriptor;
@@ -785,6 +804,7 @@ void translog_stop_writing()
   translog_status= (translog_status == TRANSLOG_SHUTDOWN ?
                     TRANSLOG_UNINITED :
                     TRANSLOG_READONLY);
+  log_descriptor.is_everything_flushed= 1;
   log_descriptor.open_flags= O_BINARY | O_RDONLY;
   DBUG_ASSERT(0);
   DBUG_VOID_RETURN;
@@ -1373,7 +1393,9 @@ LSN translog_get_file_max_lsn_stored(uin
 static my_bool translog_buffer_init(struct st_translog_buffer *buffer)
 {
   DBUG_ENTER("translog_buffer_init");
-  buffer->last_lsn= LSN_IMPOSSIBLE;
+  buffer->prev_last_lsn= buffer->last_lsn= LSN_IMPOSSIBLE;
+  DBUG_PRINT("info", ("last_lsn  and prev_last_lsn set to 0  buffer: 0x%lx",
+                      (ulong) buffer));
   /* This Buffer File */
   buffer->file= NULL;
   buffer->overlay= 0;
@@ -1972,7 +1994,9 @@ static void translog_start_buffer(struct
               (ulong) LSN_OFFSET(log_descriptor.horizon),
               (ulong) LSN_OFFSET(log_descriptor.horizon)));
   DBUG_ASSERT(buffer_no == buffer->buffer_no);
-  buffer->last_lsn= LSN_IMPOSSIBLE;
+  buffer->prev_last_lsn= buffer->last_lsn= LSN_IMPOSSIBLE;
+  DBUG_PRINT("info", ("last_lsn and prev_last_lsn set to 0  buffer: 0x%lx",
+                      (ulong) buffer));
   buffer->offset= log_descriptor.horizon;
   buffer->next_buffer_offset= LSN_IMPOSSIBLE;
   buffer->file= get_current_logfile();
@@ -1987,6 +2011,10 @@ static void translog_start_buffer(struct
                       cursor->chaser, (ulong) cursor->buffer->size,
                       (ulong) (cursor->ptr - cursor->buffer->buffer)));
   translog_check_cursor(cursor);
+  pthread_mutex_lock(&log_descriptor.dirty_buffer_mask_lock);
+  log_descriptor.dirty_buffer_mask|= (1 << buffer->buffer_no);
+  pthread_mutex_unlock(&log_descriptor.dirty_buffer_mask_lock);
+
   DBUG_VOID_RETURN;
 }
 
@@ -2046,7 +2074,6 @@ static my_bool translog_buffer_next(TRAN
 
   if (new_file)
   {
-
     /* move the horizon to the next file and its header page */
     (*horizon)+= LSN_ONE_FILE;
     (*horizon)= LSN_REPLACE_OFFSET(*horizon, TRANSLOG_PAGE_SIZE);
@@ -2065,6 +2092,13 @@ static my_bool translog_buffer_next(TRAN
     translog_start_buffer(new_buffer, cursor, new_buffer_no);
   }
   log_descriptor.buffers[old_buffer_no].next_buffer_offset= new_buffer->offset;
+  new_buffer->prev_last_lsn=
+    ((log_descriptor.buffers[old_buffer_no].last_lsn != LSN_IMPOSSIBLE) ?
+     log_descriptor.buffers[old_buffer_no].last_lsn :
+     log_descriptor.buffers[old_buffer_no].prev_last_lsn);
+  DBUG_PRINT("info", ("prev_last_lsn set to (%lu,0x%lx)  buffer: 0x%lx",
+                      LSN_IN_PARTS(new_buffer->prev_last_lsn),
+                      (ulong) new_buffer));
   translog_new_page_header(horizon, cursor);
   DBUG_RETURN(0);
 }
@@ -2179,6 +2213,7 @@ static LSN translog_get_sent_to_disk()
   DBUG_ENTER("translog_get_sent_to_disk");
   pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
   lsn= log_descriptor.sent_to_disk;
+  DBUG_PRINT("info", ("sent to disk up to (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
   pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
   DBUG_RETURN(lsn);
 }
@@ -2392,7 +2427,6 @@ static my_bool translog_buffer_flush(str
   TRANSLOG_FILE *file= buffer->file;
   uint8 ver= buffer->ver;
   DBUG_ENTER("translog_buffer_flush");
-  DBUG_ASSERT(buffer->file != NULL);
   DBUG_PRINT("enter",
              ("Buffer: #%u 0x%lx file: %d  offset: (%lu,0x%lx)  size: %lu",
               (uint) buffer->buffer_no, (ulong) buffer,
@@ -2401,6 +2435,9 @@ static my_bool translog_buffer_flush(str
               (ulong) buffer->size));
   translog_buffer_lock_assert_owner(buffer);
 
+  if (buffer->file == NULL)
+    DBUG_RETURN(0);
+
   translog_wait_for_writers(buffer);
 
   if (buffer->file != file || buffer->offset != offset || buffer->ver != ver)
@@ -2460,6 +2497,11 @@ static my_bool translog_buffer_flush(str
   {
     TRANSLOG_ADDRESS addr= (buffer->offset + i);
     TRANSLOG_VALIDATOR_DATA data;
+    DBUG_PRINT("info", ("send log form %lu till %lu  address: (%lu,0x%lx)  "
+                        "page #: %lu  buffer size: %lu  buffer: 0x%lx",
+                        (ulong) i, (ulong) (i + TRANSLOG_PAGE_SIZE),
+                        LSN_IN_PARTS(addr), (ulong) pg, (ulong) buffer->size,
+                        (ulong) buffer));
     data.addr= &addr;
     DBUG_ASSERT(log_descriptor.pagecache->block_size == TRANSLOG_PAGE_SIZE);
     DBUG_ASSERT(i + TRANSLOG_PAGE_SIZE <= buffer->size);
@@ -2511,6 +2553,9 @@ static my_bool translog_buffer_flush(str
   buffer->file= NULL;
   buffer->overlay= 0;
   buffer->ver++;
+  pthread_mutex_lock(&log_descriptor.dirty_buffer_mask_lock);
+  log_descriptor.dirty_buffer_mask&= ~(1 << buffer->buffer_no);
+  pthread_mutex_unlock(&log_descriptor.dirty_buffer_mask_lock);
   pthread_cond_broadcast(&buffer->waiting_filling_buffer);
   DBUG_RETURN(0);
 }
@@ -3352,9 +3397,12 @@ my_bool translog_init_with_table(const c
   id_to_share= NULL;
   log_descriptor.directory_fd= -1;
   log_descriptor.is_everything_flushed= 1;
+  log_descriptor.next_pass_max_lsn= LSN_IMPOSSIBLE;
 
   (*init_table_func)();
-
+  compile_time_assert(sizeof(log_descriptor.dirty_buffer_mask) * 8 >=
+                      TRANSLOG_BUFFERS_NO);
+  log_descriptor.dirty_buffer_mask= 0;
   if (readonly)
     log_descriptor.open_flags= O_BINARY | O_RDONLY;
   else
@@ -3369,6 +3417,9 @@ my_bool translog_init_with_table(const c
                          MY_MUTEX_INIT_FAST) ||
       pthread_mutex_init(&log_descriptor.log_flush_lock,
                          MY_MUTEX_INIT_FAST) ||
+      pthread_mutex_init(&log_descriptor.dirty_buffer_mask_lock,
+                         MY_MUTEX_INIT_FAST) ||
+      pthread_cond_init(&log_descriptor.log_flush_cond, 0) ||
       my_rwlock_init(&log_descriptor.open_files_lock,
                      NULL) ||
       my_init_dynamic_array(&log_descriptor.open_files,
@@ -3441,9 +3492,7 @@ my_bool translog_init_with_table(const c
   {
     if (translog_buffer_init(log_descriptor.buffers + i))
       goto err;
-#ifndef DBUG_OFF
     log_descriptor.buffers[i].buffer_no= (uint8) i;
-#endif
     DBUG_PRINT("info", ("translog_buffer buffer #%u: 0x%lx",
                         i, (ulong) log_descriptor.buffers + i));
   }
@@ -4016,6 +4065,8 @@ void translog_destroy()
   pthread_mutex_destroy(&log_descriptor.unfinished_files_lock);
   pthread_mutex_destroy(&log_descriptor.purger_lock);
   pthread_mutex_destroy(&log_descriptor.log_flush_lock);
+  pthread_mutex_destroy(&log_descriptor.dirty_buffer_mask_lock);
+  pthread_cond_destroy(&log_descriptor.log_flush_cond);
   rwlock_destroy(&log_descriptor.open_files_lock);
   delete_dynamic(&log_descriptor.open_files);
   delete_dynamic(&log_descriptor.unfinished_files);
@@ -4686,10 +4737,13 @@ static translog_size_t translog_get_curr
 
 static inline void set_lsn(LSN *lsn, LSN value)
 {
+  DBUG_ENTER("set_lsn");
   translog_lock_assert_owner();
   *lsn= value;
   /* we generate LSN so something is not flushed in log */
   log_descriptor.is_everything_flushed= 0;
+  DBUG_PRINT("info", ("new LSN appeared: (%lu,0x%lx)", LSN_IN_PARTS(value)));
+  DBUG_VOID_RETURN;
 }
 
 
@@ -4779,6 +4833,9 @@ translog_write_variable_record_1group(LS
   rc|= translog_advance_pointer((int)(full_pages + additional_chunk3_page),
                                 (record_rest ? record_rest + 3 : 0));
   log_descriptor.bc.buffer->last_lsn= *lsn;
+  DBUG_PRINT("info", ("last_lsn set to (%lu,0x%lx)  buffer: 0x%lx",
+                      LSN_IN_PARTS(log_descriptor.bc.buffer->last_lsn),
+                      (ulong) log_descriptor.bc.buffer));
 
   translog_unlock();
 
@@ -4902,6 +4959,9 @@ translog_write_variable_record_1chunk(LS
                                    &log_descriptor.bc,
                                    parts->total_record_length, parts);
   log_descriptor.bc.buffer->last_lsn= *lsn;
+  DBUG_PRINT("info", ("last_lsn set to (%lu,0x%lx)  buffer: 0x%lx",
+                      LSN_IN_PARTS(log_descriptor.bc.buffer->last_lsn),
+                      (ulong) log_descriptor.bc.buffer));
   translog_unlock();
 
   /*
@@ -5246,6 +5306,7 @@ translog_write_variable_record_mgroup(LS
   uint groups_per_page= (page_capacity - header_fixed_part) / (7 + 1);
   uint file_of_the_first_group;
   int pages_to_skip;
+  struct st_translog_buffer *buffer_of_last_lsn;
   DBUG_ENTER("translog_write_variable_record_mgroup");
   translog_lock_assert_owner();
 
@@ -5480,6 +5541,7 @@ translog_write_variable_record_mgroup(LS
                                 ((page_capacity -
                                   header_fixed_part) / (7 + 1)) *
                                 (chunk0_pages - 1)) * (7 + 1));
+  buffer_of_last_lsn= log_descriptor.bc.buffer;
   translog_unlock();
 
   if (buffer_to_flush != NULL)
@@ -5587,6 +5649,10 @@ translog_write_variable_record_mgroup(LS
       */
       translog_lock();
       set_lsn(lsn, horizon);
+      buffer_of_last_lsn->last_lsn= *lsn;
+      DBUG_PRINT("info", ("last_lsn set to (%lu,0x%lx)  buffer: 0x%lx",
+                          LSN_IN_PARTS(buffer_of_last_lsn->last_lsn),
+                          (ulong) buffer_of_last_lsn));
       if (log_record_type_descriptor[type].inwrite_hook &&
           (*log_record_type_descriptor[type].inwrite_hook) (type, trn,
                                                             tbl_info,
@@ -5642,8 +5708,6 @@ translog_write_variable_record_mgroup(LS
     *chunk0_header= (uchar) (TRANSLOG_CHUNK_LSN | TRANSLOG_CHUNK_0_CONT);
   } while (chunk0_pages != 0);
   translog_buffer_lock(cursor.buffer);
-  if (cmp_translog_addr(cursor.buffer->last_lsn, *lsn) < 0)
-    cursor.buffer->last_lsn= *lsn;
   translog_buffer_decrease_writers(cursor.buffer);
   translog_buffer_unlock(cursor.buffer);
   rc= 0;
@@ -5896,6 +5960,9 @@ static my_bool translog_write_fixed_reco
                                    parts->total_record_length, parts);
 
   log_descriptor.bc.buffer->last_lsn= *lsn;
+  DBUG_PRINT("info", ("last_lsn set to (%lu,0x%lx)  buffer: 0x%lx",
+                      LSN_IN_PARTS(log_descriptor.bc.buffer->last_lsn),
+                      (ulong) log_descriptor.bc.buffer));
 
 err:
   translog_unlock();
@@ -7300,7 +7367,8 @@ static void translog_force_current_buffe
 #endif
     /*
       Now only one thread can flush log (buffer can flush many threads but
-      log flush is serialized) so no other thread can set is_closing_buffer
+      log flush log flush where this function is used can do only one thread)
+      so no other thread can set is_closing_buffer.
     */
     DBUG_ASSERT(!old_buffer->is_closing_buffer);
     old_buffer->is_closing_buffer= 1; /* Other flushes will wait */
@@ -7362,44 +7430,70 @@ static void translog_force_current_buffe
 
 
 /**
-   @brief Flush the log up to given LSN (included)
+  @brief Waits while given lsn will be flushed
 
-   @param  lsn             log record serial number up to which (inclusive)
-                           the log has to be flushed
+  @param  lsn            log record serial number up to which (inclusive)
+                         the log has to be flushed
+*/
+
+void  translog_flush_wait_for_end(LSN lsn)
+{
+  DBUG_ENTER("translog_flush_wait_for_end");
+  DBUG_PRINT("enter", ("LSN: (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
+  safe_mutex_assert_owner(&log_descriptor.log_flush_lock);
+  while (cmp_translog_addr(log_descriptor.flushed, lsn) < 0)
+    pthread_cond_wait(&log_descriptor.log_flush_cond,
+                      &log_descriptor.log_flush_lock);
+  DBUG_VOID_RETURN;
+}
 
-   @return Operation status
-     @retval 0      OK
-     @retval 1      Error
 
-  @todo LOG: when a log write fails, we should not write to this log anymore
-  (if we add more log records to this log they will be unreadable: we will hit
-  the broken log record): all translog_flush() should be made to fail (because
-  translog_flush() is when a a transaction wants something durable and we
-  cannot make anything durable as log is corrupted). For that, a "my_bool
-  st_translog_descriptor::write_error" could be set to 1 when a
-  translog_write_record() or translog_flush() fails, and translog_flush()
-  would test this var (and translog_write_record() could also test this var if
-  it wants, though it's not absolutely needed).
-  Then, either shut Maria down immediately, or switch to a new log (but if we
-  get write error after write error, that would create too many logs).
-  A popular open-source transactional engine intentionally crashes as soon as
-  a log flush fails (we however don't want to crash the entire mysqld, but
-  stopping all engine's operations immediately would make sense).
-  Same applies to translog_write_record().
+/**
+  @brief Sets goal for the next flush pass and waits for this pass end.
+
+  @param  lsn            log record serial number up to which (inclusive)
+                         the log has to be flushed
+*/
+
+void translog_flush_set_new_goal_and_wait(TRANSLOG_ADDRESS lsn)
+{
+  DBUG_ENTER("translog_flush_set_new_goal_and_wait");
+  DBUG_PRINT("enter", ("LSN: (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
+  safe_mutex_assert_owner(&log_descriptor.log_flush_lock);
+  if (cmp_translog_addr(lsn, log_descriptor.next_pass_max_lsn) > 0)
+  {
+    log_descriptor.next_pass_max_lsn= lsn;
+    log_descriptor.max_lsn_requester= pthread_self();
+  }
+  while (log_descriptor.flush_in_progress)
+  {
+    pthread_cond_wait(&log_descriptor.log_flush_cond,
+                      &log_descriptor.log_flush_lock);
+  }
+  DBUG_VOID_RETURN;
+}
+
+
+/**
+  @brief Flush the log up to given LSN (included)
+
+  @param  lsn            log record serial number up to which (inclusive)
+                         the log has to be flushed
+
+  @return Operation status
+    @retval 0      OK
+    @retval 1      Error
 
-  @todo: remove serialization and make group commit.
 */
 
 my_bool translog_flush(TRANSLOG_ADDRESS lsn)
 {
-  LSN old_flushed, sent_to_disk;
+  LSN sent_to_disk= LSN_IMPOSSIBLE;
   TRANSLOG_ADDRESS flush_horizon;
-  int rc= 0;
-  /* We can't have more different files then buffers */
-  TRANSLOG_FILE *file_handlers[TRANSLOG_BUFFERS_NO];
-  int current_file_handler= -1;
-  uint32 prev_file= 0;
-  my_bool full_circle= 0;
+  uint fn, i;
+  dirty_buffer_mask_t dirty_buffer_mask;
+  uint8 last_buffer_no, start_buffer_no;
+  my_bool rc= 0;
   DBUG_ENTER("translog_flush");
   DBUG_PRINT("enter", ("Flush up to LSN: (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
   DBUG_ASSERT(translog_status == TRANSLOG_OK ||
@@ -7407,125 +7501,123 @@ my_bool translog_flush(TRANSLOG_ADDRESS 
   LINT_INIT(sent_to_disk);
 
   pthread_mutex_lock(&log_descriptor.log_flush_lock);
+  DBUG_PRINT("info", ("Everything is flushed up to (%lu,0x%lx)",
+                      LSN_IN_PARTS(log_descriptor.flushed)));
+  if (cmp_translog_addr(log_descriptor.flushed, lsn) >= 0)
+  {
+    pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+    DBUG_RETURN(0);
+  }
+  if (log_descriptor.flush_in_progress)
+  {
+    translog_flush_set_new_goal_and_wait(lsn);
+    if (!pthread_equal(log_descriptor.max_lsn_requester, pthread_self()))
+    {
+      /* fix lsn if it was horizon */
+      if (cmp_translog_addr(lsn, log_descriptor.bc.buffer->last_lsn) > 0)
+          lsn= log_descriptor.bc.buffer->last_lsn;
+      translog_flush_wait_for_end(lsn);
+      pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+      DBUG_RETURN(0);
+    }
+    log_descriptor.next_pass_max_lsn= LSN_IMPOSSIBLE;
+  }
+  log_descriptor.flush_in_progress= 1;
+  flush_horizon= log_descriptor.previous_flush_horizon;
+  DBUG_PRINT("info", ("flush_in_progress is set"));
+  pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+
   translog_lock();
   if (log_descriptor.is_everything_flushed)
   {
     DBUG_PRINT("info", ("everything is flushed"));
+    rc= (translog_status == TRANSLOG_READONLY);
     translog_unlock();
     goto out;
   }
-  flush_horizon= LSN_IMPOSSIBLE;
-  old_flushed= log_descriptor.flushed;
-  for (;;)
+
+  /*
+    We will recheck information when will lock buffers one by
+    one so we can use unprotected read here (this is just for
+    speed up buffers processing)
+  */
+  dirty_buffer_mask= log_descriptor.dirty_buffer_mask;
+  DBUG_PRINT("info", ("Dirty buffer mask: %lx  current buffer: %u",
+                      (ulong) dirty_buffer_mask,
+                      (uint) log_descriptor.bc.buffer_no));
+  for (i= (log_descriptor.bc.buffer_no + 1) % TRANSLOG_BUFFERS_NO;
+       i != log_descriptor.bc.buffer_no && !(dirty_buffer_mask & (1 << i));
+       i= (i + 1) % TRANSLOG_BUFFERS_NO) {}
+  start_buffer_no= i;
+
+  /* if we have to flush last buffer then we will finish it */
+  if (cmp_translog_addr(lsn, log_descriptor.bc.buffer->prev_last_lsn) > 0)
   {
-    uint16 buffer_no= log_descriptor.bc.buffer_no;
-    uint16 buffer_start= buffer_no;
-    struct st_translog_buffer *buffer_unlock= log_descriptor.bc.buffer;
     struct st_translog_buffer *buffer= log_descriptor.bc.buffer;
-    if (cmp_translog_addr(log_descriptor.flushed, lsn) >= 0)
-    {
-      DBUG_PRINT("info", ("already flushed: (%lu,0x%lx)",
-                          LSN_IN_PARTS(log_descriptor.flushed)));
-      translog_unlock();
-      goto out;
-    }
-    /* send to the file if it is not sent */
-    if (translog_status != TRANSLOG_OK)
-    {
-      rc= 1;
-      goto out;
-    }
-    sent_to_disk= translog_get_sent_to_disk();
-    if (cmp_translog_addr(sent_to_disk, lsn) >= 0 || full_circle)
-      break;
+    lsn= log_descriptor.bc.buffer->last_lsn; /* fix lsn if it was horizon */
+    last_buffer_no= log_descriptor.bc.buffer_no;
+    log_descriptor.is_everything_flushed= 1;
+    translog_force_current_buffer_to_finish();
+    translog_buffer_unlock(buffer);
+  }
+  else
+  {
+    last_buffer_no= ((log_descriptor.bc.buffer_no + TRANSLOG_BUFFERS_NO -1) %
+                     TRANSLOG_BUFFERS_NO);
+    translog_unlock();
+  }
+  sent_to_disk= translog_get_sent_to_disk();
+  if (cmp_translog_addr(lsn, sent_to_disk) > 0)
+  {
 
+    DBUG_PRINT("info", ("Start buffer #: %u  last buffer #: %u",
+                        (uint) start_buffer_no, (uint) last_buffer_no));
+    last_buffer_no= (last_buffer_no + 1) % TRANSLOG_BUFFERS_NO;
+    i= start_buffer_no;
     do
     {
-      buffer_no= (buffer_no + 1) % TRANSLOG_BUFFERS_NO;
-      buffer= log_descriptor.buffers + buffer_no;
+      struct st_translog_buffer *buffer= log_descriptor.buffers + i;
       translog_buffer_lock(buffer);
-      translog_buffer_unlock(buffer_unlock);
-      buffer_unlock= buffer;
-      if (buffer->file != NULL)
-      {
-        buffer_unlock= NULL;
-        if (buffer_start == buffer_no)
-        {
-          /* we made a circle */
-          full_circle= 1;
-          /*
-            If buffer from which we started still current we have to
-            finish it (we will not flush intentionally more records
-            then was at the moment of start flushing);
-          */
-          if (buffer_start == log_descriptor.bc.buffer_no)
-          {
-            translog_lock_assert_owner();
-            /*
-              Here we have loghandler locked.
-
-              We are going to flush last buffer, and will not release
-              log_flush_lock until it happened, so we can set the flag here
-              and other process which going to flush will not be able read
-              it and return earlier then we finish the flush process. (But
-              other process can drop the flag if new LSN appeared (only
-              after translog_force_current_buffer_to_finish() call and
-              transaction log unlock of course))
-            */
-            log_descriptor.is_everything_flushed= 1;
-            translog_force_current_buffer_to_finish();
-          }
-        }
-        break;
-      }
-    } while ((buffer_start != buffer_no) &&
-             cmp_translog_addr(log_descriptor.flushed, lsn) < 0);
-    if (buffer_unlock != NULL && buffer_unlock != buffer)
-      translog_buffer_unlock(buffer_unlock);
-
-    if (prev_file != LSN_FILE_NO(buffer->offset))
-    {
-      TRANSLOG_FILE *file;
-      uint32 fn= LSN_FILE_NO(buffer->offset);
-      prev_file= fn;
-      file= get_logfile_by_number(fn);
-      DBUG_ASSERT(file != NULL);
-      if (!file->is_sync)
+      DBUG_PRINT("info", ("Check buffer: 0x%lx  #: %u  "
+                          "prev last LSN: (%lu,0x%lx)  "
+                          "last LSN: (%lu,0x%lx)  status: %s",
+                          (ulong)(buffer),
+                          (uint) i,
+                          LSN_IN_PARTS(buffer->prev_last_lsn),
+                          LSN_IN_PARTS(buffer->last_lsn),
+                          (buffer->file ?
+                           "dirty" : "closed")));
+      if (buffer->prev_last_lsn <= lsn &&
+          buffer->file != NULL)
       {
-        current_file_handler++;
-        file_handlers[current_file_handler]= file;
+        DBUG_ASSERT(flush_horizon <= buffer->offset + buffer->size);
+        flush_horizon= buffer->offset + buffer->size;
+        translog_buffer_flush(buffer);
       }
-      /* We sync file when we are closing it => do nothing if file closed */
-    }
-    DBUG_ASSERT(flush_horizon <= buffer->offset + buffer->size);
-    flush_horizon= buffer->offset + buffer->size;
-    rc= translog_buffer_flush(buffer);
-    translog_buffer_unlock(buffer);
-    if (rc)
-      goto out;                                 /* rc is 1 */
-    translog_lock();
+      translog_buffer_unlock(buffer);
+      i= (i + 1) % TRANSLOG_BUFFERS_NO;
+    } while (i != last_buffer_no);
+    sent_to_disk= translog_get_sent_to_disk();
   }
-  translog_unlock();
 
+  /* sync files from previous flush till current one */
+  for (fn= LSN_FILE_NO(log_descriptor.flushed); fn <= LSN_FILE_NO(lsn); fn++)
   {
-    TRANSLOG_FILE **cur= file_handlers;
-    TRANSLOG_FILE **end= file_handlers + current_file_handler;
-    for (; cur <= end; cur++)
+    TRANSLOG_FILE *file= get_logfile_by_number(fn);
+    DBUG_ASSERT(file != NULL);
+    if (!file->is_sync)
     {
-      (*cur)->is_sync= 1;
-      if (my_sync((*cur)->handler.file, MYF(MY_WME)))
+      if (my_sync(file->handler.file, MYF(MY_WME)))
       {
         rc= 1;
         translog_stop_writing();
+        sent_to_disk= LSN_IMPOSSIBLE;
         goto out;
       }
+      file->is_sync= 1;
     }
   }
-  log_descriptor.flushed= sent_to_disk;
-  /*
-    If we should flush (due to directory flush mode) and
-    previous flush horizon was not within one page border with this one.
-  */
+
   if (sync_log_dir >= TRANSLOG_SYNC_DIR_ALWAYS &&
       (LSN_FILE_NO(log_descriptor.previous_flush_horizon) !=
        LSN_FILE_NO(flush_horizon) ||
@@ -7535,7 +7627,13 @@ my_bool translog_flush(TRANSLOG_ADDRESS 
     rc|= sync_dir(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD));
   log_descriptor.previous_flush_horizon= flush_horizon;
 out:
-  pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+  pthread_mutex_lock(&log_descriptor.log_flush_lock);
+  if (sent_to_disk != LSN_IMPOSSIBLE)
+    log_descriptor.flushed= sent_to_disk;
+  log_descriptor.flush_in_progress= 0;
+  DBUG_PRINT("info", ("flush_in_progress is dropped"));
+  pthread_mutex_unlock(&log_descriptor.log_flush_lock);\
+  pthread_cond_broadcast(&log_descriptor.log_flush_cond);
   DBUG_RETURN(rc);
 }
 

=== modified file 'storage/maria/ma_recovery.c'
--- a/storage/maria/ma_recovery.c	2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_recovery.c	2008-06-26 09:32:22 +0000
@@ -3063,7 +3063,8 @@ static LSN parse_checkpoint_record(LSN l
     Find LSN higher or equal to this TRANSLOG_ADDRESS, suitable for
     translog_read_record() functions.
   */
-  checkpoint_start= translog_next_LSN(start_address, LSN_IMPOSSIBLE);
+  start_address= checkpoint_start=
+    translog_next_LSN(start_address, LSN_IMPOSSIBLE);
   if (checkpoint_start == LSN_IMPOSSIBLE)
   {
     /*

=== modified file 'storage/maria/ma_rt_test.c'
--- a/storage/maria/ma_rt_test.c	2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_rt_test.c	2008-06-26 09:32:22 +0000
@@ -86,8 +86,9 @@ static double rt_data[]=
   -1
 };
 
-static int silent= 0, testflag= 0, transactional= 0,
-  die_in_middle_of_transaction= 0, checkpoint= 0, create_flag= 0;
+static int testflag, checkpoint, create_flag;
+static my_bool silent, transactional, die_in_middle_of_transaction,
+  opt_versioning;
 static enum data_file_type record_type= DYNAMIC_RECORD;
 
 int main(int argc, char *argv[])
@@ -141,7 +142,11 @@ static int run_test(const char *filename
   int upd= 10;
   ha_rows hrows;
 
-  bzero((char*) recinfo,sizeof(recinfo));
+  bzero(&uniquedef, sizeof(uniquedef));
+  bzero(&create_info, sizeof(create_info));
+  bzero(recinfo, sizeof(recinfo));
+  bzero(keyinfo, sizeof(keyinfo));
+  bzero(keyseg, sizeof(keyseg));
 
   /* Define a column for NULLs and DEL markers*/
 
@@ -179,7 +184,6 @@ static int run_test(const char *filename
   if (!silent)
     printf("- Creating isam-file\n");
 
-  bzero((char*) &create_info,sizeof(create_info));
   create_info.max_rows=10000000;
   create_info.transactional= transactional;
 
@@ -197,6 +201,8 @@ static int run_test(const char *filename
   if (!(file=maria_open(filename,2,HA_OPEN_ABORT_IF_LOCKED)))
     goto err;
   maria_begin(file);
+  if (opt_versioning)
+    maria_versioning(file, 1);
   if (testflag == 1)
     goto end;
   if (checkpoint == 1 && ma_checkpoint_execute(CHECKPOINT_MEDIUM, FALSE))
@@ -215,13 +221,19 @@ static int run_test(const char *filename
     }
     else
     {
-      printf("maria_write: %d\n", error);
+      fprintf(stderr, "maria_write: %d\n", error);
       goto err;
     }
   }
 
+  if (maria_scan_init(file))
+  {
+    fprintf(stderr, "maria_scan_init failed\n");
+    goto err;
+  }
   if ((error=read_with_pos(file)))
     goto err;
+  maria_scan_end(file);
 
   if (!silent)
     printf("- Reading rows with key\n");
@@ -236,7 +248,7 @@ static int run_test(const char *filename
 
     if (error && error!=HA_ERR_KEY_NOT_FOUND)
     {
-      printf("     maria_rkey: %3d  errno: %3d\n",error,my_errno);
+      fprintf(stderr,"     maria_rkey: %3d  errno: %3d\n",error,my_errno);
       goto err;
     }
     if (error == HA_ERR_KEY_NOT_FOUND)
@@ -268,7 +280,8 @@ static int run_test(const char *filename
     error=maria_scan(file,read_record);
     if (error)
     {
-      printf("pos: %2d  maria_rrnd: %3d  errno: %3d\n",i,error,my_errno);
+      fprintf(stderr, "pos: %2d  maria_rrnd: %3d  errno: %3d\n", i, error,
+              my_errno);
       goto err;
     }
     print_record(read_record,maria_position(file),"\n");
@@ -276,7 +289,8 @@ static int run_test(const char *filename
     error=maria_delete(file,read_record);
     if (error)
     {
-      printf("pos: %2d maria_delete: %3d errno: %3d\n",i,error,my_errno);
+      fprintf(stderr, "pos: %2d maria_delete: %3d errno: %3d\n", i, error,
+              my_errno);
       goto err;
     }
   }
@@ -305,7 +319,8 @@ static int run_test(const char *filename
     {
       if (error==HA_ERR_RECORD_DELETED)
       {
-        printf("found deleted record\n");
+        if (!silent)
+          printf("found deleted record\n");
         /*
           In BLOCK_RECORD format, maria_scan() never returns deleted records,
           while in DYNAMIC format it can. Don't count such record:
@@ -313,17 +328,20 @@ static int run_test(const char *filename
         max_i++;
         continue;
       }
-      printf("pos: %2d  maria_rrnd: %3d  errno: %3d\n",i,error,my_errno);
+      fprintf(stderr, "pos: %2d  maria_rrnd: %3d  errno: %3d\n",i , error,
+              my_errno);
       goto err;
     }
     print_record(read_record,maria_position(file),"");
     create_record1(record,i+nrecords*upd);
-    printf("\t-> ");
+    if (!silent)
+      printf("\t-> ");
     print_record(record,maria_position(file),"\n");
     error=maria_update(file,read_record,record);
     if (error)
     {
-      printf("pos: %2d  maria_update: %3d  errno: %3d\n",i,error,my_errno);
+      fprintf(stderr, "pos: %2d  maria_update: %3d  errno: %3d\n",i, error,
+              my_errno);
       goto err;
     }
   }
@@ -351,7 +369,7 @@ static int run_test(const char *filename
   if ((error=maria_rkey(file,read_record,0,record+1,HA_WHOLE_KEY,
                         HA_READ_MBR_INTERSECT)))
   {
-    printf("maria_rkey: %3d  errno: %3d\n",error,my_errno);
+    fprintf(stderr, "maria_rkey: %3d  errno: %3d\n",error,my_errno);
     goto err;
   }
   print_record(read_record,maria_position(file),"  maria_rkey\n");
@@ -363,13 +381,14 @@ static int run_test(const char *filename
     {
       if (error==HA_ERR_END_OF_FILE)
         break;
-      printf("maria_next: %3d  errno: %3d\n",error,my_errno);
+      fprintf(stderr, "maria_next: %3d  errno: %3d\n",error,my_errno);
       goto err;
     }
     print_record(read_record,maria_position(file),"  maria_rnext_same\n");
       row_count++;
   }
-  printf("     %d rows\n",row_count);
+  if (!silent)
+    printf("     %d rows\n",row_count);
 
   if (!silent)
     printf("- Test maria_rfirst then a sequence of maria_rnext\n");
@@ -377,7 +396,7 @@ static int run_test(const char *filename
   error=maria_rfirst(file,read_record,0);
   if (error)
   {
-    printf("maria_rfirst: %3d  errno: %3d\n",error,my_errno);
+    fprintf(stderr, "maria_rfirst: %3d  errno: %3d\n",error,my_errno);
     goto err;
   }
   row_count=1;
@@ -389,13 +408,14 @@ static int run_test(const char *filename
     {
       if (error==HA_ERR_END_OF_FILE)
         break;
-      printf("maria_next: %3d  errno: %3d\n",error,my_errno);
+      fprintf(stderr, "maria_next: %3d  errno: %3d\n",error,my_errno);
       goto err;
     }
     print_record(read_record,maria_position(file),"  maria_rnext\n");
     row_count++;
   }
-  printf("     %d rows\n",row_count);
+  if (!silent)
+    printf("     %d rows\n",row_count);
 
   if (!silent)
     printf("- Test maria_records_in_range()\n");
@@ -407,7 +427,8 @@ static int run_test(const char *filename
   range.length= 1000;                           /* Big enough */
   range.flag= HA_READ_MBR_INTERSECT;
   hrows= maria_records_in_range(file,0, &range, (key_range*) 0);
-  printf("     %ld rows\n", (long) hrows);
+  if (!silent)
+    printf("     %ld rows\n", (long) hrows);
 
 end:
   maria_scan_end(file);
@@ -432,7 +453,8 @@ end:
         goto err;
       break;
     }
-    printf("Dying on request without maria_commit()/maria_close()\n");
+    if (!silent)
+      printf("Dying on request without maria_commit()/maria_close()\n");
     exit(0);
   }
   if (maria_commit(file))
@@ -444,7 +466,7 @@ end:
   return 0;
 
 err:
-  printf("got error: %3d when using maria-database\n",my_errno);
+  fprintf(stderr, "got error: %3d when using maria-database\n",my_errno);
   return 1;           /* skip warning */
 }
 
@@ -469,7 +491,8 @@ static int read_with_pos (MARIA_HA * fil
         break;
       if (error==HA_ERR_RECORD_DELETED)
         continue;
-      printf("pos: %2d  maria_rrnd: %3d  errno: %3d\n",i,error,my_errno);
+      fprintf(stderr, "pos: %2d  maria_rrnd: %3d  errno: %3d\n", i, error,
+              my_errno);
       return error;
     }
     print_record(read_record,maria_position(file),"\n");
@@ -485,6 +508,8 @@ static void bprint_record(char * record,
 {
   int i;
   char * pos;
+  if (silent)
+    return;
   i=(unsigned char)record[0];
   printf("%02X ",i);
 
@@ -505,6 +530,8 @@ static void print_record(uchar *record,
   uchar *pos;
   double c;
 
+  if (silent)
+    return;
   printf("     rec=(%d)",(unsigned char)record[0]);
   for ( pos=record+1, i=0; i<2*ndims; i++)
    {
@@ -605,6 +632,9 @@ static struct my_option my_long_options[
    "Test in transactional mode. (Only works with block format)",
    (uchar**) &transactional, (uchar**) &transactional, 0, GET_BOOL, NO_ARG,
    0, 0, 0, 0, 0, 0},
+  {"versioning", 'C', "Use row versioning (only works with block format)",
+   (uchar**) &opt_versioning,  (uchar**) &opt_versioning, 0, GET_BOOL,
+   NO_ARG, 0, 0, 0, 0, 0, 0},
   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
 

=== modified file 'storage/maria/ma_state.c'
--- a/storage/maria/ma_state.c	2008-06-26 05:18:28 +0000
+++ b/storage/maria/ma_state.c	2008-06-26 09:32:22 +0000
@@ -28,9 +28,9 @@
      10 ended transactions since last time it was called.
 */
 
-#include <maria_def.h>
+#include "maria_def.h"
 #include "trnman.h"
-#include <ma_blockrec.h>
+#include "ma_blockrec.h"
 
 /**
    @brief Setup initial start-of-transaction state for a table

=== modified file 'storage/maria/ma_test_force_start.pl'
--- a/storage/maria/ma_test_force_start.pl	2008-06-02 20:53:25 +0000
+++ b/storage/maria/ma_test_force_start.pl	2008-06-16 08:57:25 +0000
@@ -36,24 +36,58 @@ else
 my $force_after= 3;
 my $corrupt_file= $corrupt_index ? "MAI" : "MAD";
 my $corrupt_message= 
-  "\\[ERROR\\] mysqld: Table '.\/test\/t1' is marked as crashed and should be repaired";
+  "\\[ERROR\\] mysqld(.exe)*: Table '..test.t1' is marked as crashed and should be repaired";
 
 my $sql_name= "./var/tmp/create_table.sql";
 my $error_log_name= "./var/log/master.err";
 my @cmd_output;
 my $whatever; # garbage data
-my $base_server_cmd= "perl mysql-test-run.pl --mem --mysqld=--maria-force-start-after-recovery-failures=$force_after maria-recover";
+my $base_server_cmd= "perl mysql-test-run.pl --mysqld=--maria-force-start-after-recovery-failures=$force_after maria-recover ";
+if ($^O =~ /^mswin/i)
+  {
+    print <<EOF;
+WARNING: with Activestate Perl, mysql-test-run.pl --start-and-exit has a bug:
+it does not exit; cygwin perl recommended
+EOF
+  }
+my $iswindows= ( $^O =~ /win/i  && $^O !~ /darwin/i );
+$base_server_cmd.= ($iswindows ? "--mysqld=--console" : "--mem");
 my $server_cmd;
-my $client_cmd= "../client/mysql -u root -S var/tmp/master.sock test < $sql_name";
 my $server_pid_name="./var/run/master.pid";
 my $server_pid;
 my $i; # count of server restarts
 sub kill_server;
 
+my $suffix= ($iswindows ? ".exe" : "");
+my $client_exe_path= "../client/release";
+# we use -f, sometimes -x is unexpectedly false in Cygwin
+if ( ! -f "$client_exe_path/mysql$suffix" )
+  {
+    $client_exe_path= "../client/relwithdebinfo";
+    if ( ! -f "$client_exe_path/mysql$suffix" )
+    {
+      $client_exe_path= "../client/debug";
+      if ( ! -f "$client_exe_path/mysql$suffix" )
+      {
+        $client_exe_path= "../client";
+        if ( ! -f "$client_exe_path/mysql$suffix" )
+        {
+          die("Cannot find 'mysql' executable\n");
+        }
+      }
+    }
+  }
+
 print "starting mysqld\n";
 $server_cmd= $base_server_cmd . " --start-and-exit 2>&1";
 @cmd_output=`$server_cmd`;
 die if $?;
+my $master_port= (grep (/Using MASTER_MYPORT .*= (\d+)$/, @cmd_output))[0];
+$master_port =~ s/.*= //;
+chomp $master_port;
+die unless $master_port > 0;
+
+my $client_cmd= "$client_exe_path/mysql -u root -h 127.0.0.1 -P $master_port test < $sql_name";
 
 open(FILE, ">", $sql_name) or die;
 
@@ -113,7 +147,7 @@ for($i= 1; $i <= $force_after; $i= $i + 
     open(FILE, "<", $error_log_name) or die;
     @cmd_output= <FILE>;
     close FILE;
-    die unless grep(/\[ERROR\] mysqld: Maria engine: log initialization failed/, @cmd_output);
+    die unless grep(/\[ERROR\] mysqld(.exe)*: Maria engine: log initialization failed/, @cmd_output);
     die unless grep(/\[ERROR\] Plugin 'MARIA' init function returned error./, @cmd_output);
     print "failed - ok\n";
   }
@@ -125,8 +159,8 @@ die if $?;
 open(FILE, "<", $error_log_name) or die;
 @cmd_output= <FILE>;
 close FILE;
-die unless grep(/\[Warning\] mysqld: Maria engine: removed all logs after [\d]+ consecutive failures of recovery from logs/, @cmd_output);
-die unless grep(/\[ERROR\] mysqld: File '..\/tmp\/maria_log.00000001' not found \(Errcode: 2\)/, @cmd_output);
+die unless grep(/\[Warning\] mysqld(.exe)*: Maria engine: removed all logs after [\d]+ consecutive failures of recovery from logs/, @cmd_output);
+die unless grep(/\[ERROR\] mysqld(.exe)*: File '...tmp.maria_log.00000001' not found \(Errcode: 2\)/, @cmd_output);
 print "success - ok\n";
 
 open(FILE, ">", $sql_name) or die;
@@ -151,7 +185,7 @@ open(FILE, "<", $error_log_name) or die;
 @cmd_output= <FILE>;
 close FILE;
 die unless grep(/$corrupt_message/, @cmd_output);
-die unless grep(/\[Warning\] Recovering table: '.\/test\/t1'/, @cmd_output);
+die unless grep(/\[Warning\] Recovering table: '..test.t1'/, @cmd_output);
 print "was corrupted and automatically repaired - ok\n";
 
 # remove our traces
@@ -164,14 +198,38 @@ sub kill_server
   {
     my ($sig)= @_;
     my $wait_count= 0;
+    my $kill_cmd;
+    my @kill_output;
     open(FILE, "<", $server_pid_name) or die;
     @cmd_output= <FILE>;
     close FILE;
     $server_pid= $cmd_output[0];
+    chomp $server_pid;
     die unless $server_pid > 0;
-    kill($sig, $server_pid) or die;
-    while (kill (0, $server_pid))
+    if ($iswindows)
+      {
+        # On Windows, server_pid_name is not the "main" process id
+        # so perl's kill() does not see this process id.
+        # But taskkill works, though only with /F ("-9"-style kill).
+        $kill_cmd= "taskkill /F /PID $server_pid 2>&1";
+        @kill_output= `$kill_cmd`;
+        die unless grep(/has been terminated/, @kill_output);
+      }
+    else
+      {
+        kill($sig, $server_pid) or die;
+      }
+    while (1) # wait until mysqld process gone
       {
+        if ($iswindows)
+          {
+            @kill_output= `$kill_cmd`;
+            last if grep(/not found/, @kill_output);
+          }
+        else
+          {
+            kill (0, $server_pid) or last;
+          }
         print "waiting for mysqld to die\n" if ($wait_count > 30);
         $wait_count= $wait_count + 1;
         select(undef, undef, undef, 0.1);

=== modified file 'storage/maria/plug.in'
--- a/storage/maria/plug.in	2008-01-31 22:17:50 +0000
+++ b/storage/maria/plug.in	2008-06-05 19:48:43 +0000
@@ -1,5 +1,5 @@
 MYSQL_STORAGE_ENGINE(maria,, [Maria Storage Engine],
-        [Crash-safe tables with MyISAM heritage], [max,max-no-ndb])
+        [Crash-safe tables with MyISAM heritage], [default,max,max-no-ndb])
 MYSQL_PLUGIN_DIRECTORY(maria,  [storage/maria])
 MYSQL_PLUGIN_STATIC(maria,     [libmaria.a])
 # Maria will probably go first into max builds, not all builds,

=== modified file 'storage/maria/unittest/CMakeLists.txt'
--- a/storage/maria/unittest/CMakeLists.txt	2008-04-02 15:08:30 +0000
+++ b/storage/maria/unittest/CMakeLists.txt	2008-06-13 09:47:17 +0000
@@ -22,7 +22,6 @@ LINK_LIBRARIES(maria myisam mytap mysys 
 
 ADD_EXECUTABLE(ma_control_file-t ma_control_file-t.c)
 ADD_EXECUTABLE(trnman-t trnman-t.c)
-ADD_EXECUTABLE(lockman2-t lockman2-t.c)
 ADD_EXECUTABLE(ma_test_loghandler-t  
 	ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
 ADD_EXECUTABLE(ma_test_loghandler_multigroup-t  

=== modified file 'storage/maria/unittest/Makefile.am'
--- a/storage/maria/unittest/Makefile.am	2008-05-07 04:58:13 +0000
+++ b/storage/maria/unittest/Makefile.am	2008-06-13 09:47:17 +0000
@@ -27,7 +27,7 @@ LDADD=			$(top_builddir)/unittest/mytap/
 			$(top_builddir)/mysys/libmysys.a \
 			$(top_builddir)/dbug/libdbug.a \
 			$(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-noinst_PROGRAMS =	ma_control_file-t trnman-t lockman2-t \
+noinst_PROGRAMS =	ma_control_file-t trnman-t \
 			ma_pagecache_single_1k-t ma_pagecache_single_8k-t \
 			ma_pagecache_single_64k-t \
 			ma_pagecache_consist_1k-t \
@@ -42,6 +42,7 @@ noinst_PROGRAMS =	ma_control_file-t trnm
 			ma_test_loghandler-t \
                         ma_test_loghandler_multigroup-t \
 			ma_test_loghandler_multithread-t \
+			ma_test_loghandler_multiflush-t \
 			ma_test_loghandler_pagecache-t \
 			ma_test_loghandler_long-t \
 			ma_test_loghandler_noflush-t \
@@ -54,6 +55,8 @@ noinst_PROGRAMS =	ma_control_file-t trnm
 ma_test_loghandler_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
 ma_test_loghandler_multigroup_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c sequence_storage.c sequence_storage.h
 ma_test_loghandler_multithread_t_SOURCES = ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
+ma_test_loghandler_multiflush_t_SOURCES = ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
+ma_test_loghandler_multiflush_t_CPPFLAGS = -DMULTIFLUSH_TEST
 ma_test_loghandler_pagecache_t_SOURCES = ma_test_loghandler_pagecache-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
 ma_test_loghandler_long_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
 ma_test_loghandler_long_t_CPPFLAGS = -DLONG_LOG_TEST
@@ -100,7 +103,8 @@ ma_pagecache_rwconsist_1k_t_SOURCES =	ma
 ma_pagecache_rwconsist_1k_t_CPPFLAGS = -DTEST_PAGE_SIZE=1024
 
 # the generic lock manager may not be used in the end and lockman1-t crashes,
-# so we don't build lockman-t and lockman1-t 
+# and lockman2-t takes at least quarter an hour,
+# so we don't build lockman-t and lockman1-t and lockman2-t 
 CLEANFILES =		maria_log_control page_cache_test_file_1 \
 			maria_log.????????
 

=== modified file 'storage/maria/unittest/ma_test_all-t'
--- a/storage/maria/unittest/ma_test_all-t	2008-06-26 05:18:28 +0000
+++ b/storage/maria/unittest/ma_test_all-t	2008-06-26 09:32:22 +0000
@@ -266,12 +266,15 @@ sub run_check_tests
                       ["-m10000 -e16384 -E16384 -K -L","-sm"],
                       ["-L -K -W -P -b32768", "-se"],
                       ["-c -b65000","-se"] );
+  my @ma_rt_test_opt= ( ); # (["--checksum", "-se"] );
+
 
   if ($count)
   {
     $nr_tests= 2;                # Number of tests outside loops
     for ($i= 0; defined($ma_test1_opt[$i]); $i++) { $nr_tests+=2; }
     for ($i= 0; defined($ma_test2_opt[$i]); $i++) { $nr_tests+=2; }
+    for ($i= 0; defined($ma_rt_test_opt[$i]); $i++) { $nr_tests+=2; }
     return $nr_tests;
   }
 
@@ -298,6 +301,16 @@ sub run_check_tests
     ok("$maria_exe_path/maria_chk$suffix $ma_test2_opt[$i][1] test2",
        $verbose, $i + 1);
   }
+
+  for ($i= 0; defined($ma_rt_test_opt[$i]); $i++)
+  {
+    unlink <maria_log_control maria_log.*>;
+    ok("$maria_exe_path/ma_rt_test$suffix $silent $ma_rt_test_opt[$i][0] $row_type",
+       $verbose, $i + 1);
+    ok("$maria_exe_path/maria_chk$suffix $ma_rt_test_opt[$i][1] rt_test",
+       $verbose, $i + 1);
+  }
+
   unlink <maria_log_control maria_log.*>;
 
   return 0;

=== modified file 'storage/maria/unittest/ma_test_loghandler_multithread-t.c'
--- a/storage/maria/unittest/ma_test_loghandler_multithread-t.c	2008-04-10 02:26:36 +0000
+++ b/storage/maria/unittest/ma_test_loghandler_multithread-t.c	2008-06-09 21:54:30 +0000
@@ -28,16 +28,35 @@ static const char *default_dbug_option;
 
 #define PCACHE_SIZE (1024*1024*10)
 
+#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
 /*#define LOG_FLAGS TRANSLOG_SECTOR_PROTECTION | TRANSLOG_PAGE_CRC */
 #define LOG_FLAGS 0
 /*#define LONG_BUFFER_SIZE (1024L*1024L*1024L + 1024L*1024L*512)*/
+
+#ifdef MULTIFLUSH_TEST
+
+#define LONG_BUFFER_SIZE (16384L)
+#define MIN_REC_LENGTH 10
+#define SHOW_DIVIDER 20
+#define ITERATIONS 10000
+#define FLUSH_ITERATIONS 1000
+#define WRITERS 2
+#define FLUSHERS 10
+
+#else
+
 #define LONG_BUFFER_SIZE (512L*1024L*1024L)
 #define MIN_REC_LENGTH 30
 #define SHOW_DIVIDER 10
-#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
 #define ITERATIONS 3
+#define FLUSH_ITERATIONS 0
 #define WRITERS 3
+#define FLUSHERS 0
+
+#endif
+
 static uint number_of_writers= WRITERS;
+static uint number_of_flushers= FLUSHERS;
 
 static pthread_cond_t COND_thread_count;
 static pthread_mutex_t LOCK_thread_count;
@@ -48,6 +67,9 @@ static LSN lsns1[WRITERS][ITERATIONS];
 static LSN lsns2[WRITERS][ITERATIONS];
 static uchar *long_buffer;
 
+
+static LSN last_lsn; /* For test purposes the variable allow dirty read/write */
+
 /*
   Get pseudo-random length of the field in
     limits [MIN_REC_LENGTH..LONG_BUFFER_SIZE]
@@ -177,6 +199,7 @@ void writer(int num)
       return;
     }
     lsns2[num][i]= lsn;
+    last_lsn= lsn;
     pthread_mutex_lock(&LOCK_thread_count);
     ok(1, "write records");
     pthread_mutex_unlock(&LOCK_thread_count);
@@ -205,6 +228,33 @@ static void *test_thread_writer(void *ar
 }
 
 
+static void *test_thread_flusher(void *arg)
+{
+  int param= *((int*) arg);
+  int i;
+
+  my_thread_init();
+
+  for(i= 0; i < FLUSH_ITERATIONS; i++)
+  {
+    translog_flush(last_lsn);
+    pthread_mutex_lock(&LOCK_thread_count);
+    ok(1, "-- flush %d", param);
+    pthread_mutex_unlock(&LOCK_thread_count);
+  }
+
+  pthread_mutex_lock(&LOCK_thread_count);
+  thread_count--;
+  ok(1, "flusher finished"); /* just to show progress */
+  VOID(pthread_cond_signal(&COND_thread_count));        /* Tell main we are
+                                                           ready */
+  pthread_mutex_unlock(&LOCK_thread_count);
+  free((uchar*) arg);
+  my_thread_end();
+  return(0);
+}
+
+
 int main(int argc __attribute__((unused)),
          char **argv __attribute__ ((unused)))
 {
@@ -219,7 +269,8 @@ int main(int argc __attribute__((unused)
   int *param, error;
   int rc;
 
-  plan(WRITERS + ITERATIONS * WRITERS * 3);
+  plan(WRITERS + FLUSHERS +
+       ITERATIONS * WRITERS * 3 + FLUSH_ITERATIONS * FLUSHERS );
 
   bzero(&pagecache, sizeof(pagecache));
   maria_data_root= (char *)".";
@@ -329,19 +380,36 @@ int main(int argc __attribute__((unused)
 
 
   pthread_mutex_lock(&LOCK_thread_count);
-  while (number_of_writers != 0)
+  while (number_of_writers != 0 || number_of_flushers != 0)
   {
-    param= (int*) malloc(sizeof(int));
-    *param= number_of_writers - 1;
-    if ((error= pthread_create(&tid, &thr_attr, test_thread_writer,
-                               (void*) param)))
+    if (number_of_writers)
     {
-      fprintf(stderr, "Got error: %d from pthread_create (errno: %d)\n",
-              error, errno);
-      exit(1);
+      param= (int*) malloc(sizeof(int));
+      *param= number_of_writers - 1;
+      if ((error= pthread_create(&tid, &thr_attr, test_thread_writer,
+                                 (void*) param)))
+      {
+        fprintf(stderr, "Got error: %d from pthread_create (errno: %d)\n",
+                error, errno);
+        exit(1);
+      }
+      thread_count++;
+      number_of_writers--;
+    }
+    if (number_of_flushers)
+    {
+      param= (int*) malloc(sizeof(int));
+      *param= number_of_flushers - 1;
+      if ((error= pthread_create(&tid, &thr_attr, test_thread_flusher,
+                                 (void*) param)))
+      {
+        fprintf(stderr, "Got error: %d from pthread_create (errno: %d)\n",
+                error, errno);
+        exit(1);
+      }
+      thread_count++;
+      number_of_flushers--;
     }
-    thread_count++;
-    number_of_writers--;
   }
   pthread_mutex_unlock(&LOCK_thread_count);
 

=== modified file 'storage/maria/unittest/ma_test_recovery.pl'
--- a/storage/maria/unittest/ma_test_recovery.pl	2008-05-29 18:39:25 +0000
+++ b/storage/maria/unittest/ma_test_recovery.pl	2008-06-10 13:44:41 +0000
@@ -91,7 +91,9 @@ sub main
           "ma_test2$suffix $silent -M -T -c -b65000",
           "ma_test2$suffix $silent -M -T -c -b65000 -d800",
           "ma_test1$suffix $silent -M -T -c -C",
-          "ma_test2$suffix $silent -L -K -W -P -M -T -c -d500 -C"
+          "ma_test2$suffix $silent -L -K -W -P -M -T -c -d500 -C",
+          #"ma_rt_test$suffix $silent -M -T -c -C",
+          # @todo: also add to @t2
          );
 
   foreach my $prog (@t)
@@ -103,10 +105,14 @@ sub main
     $res= my_exec("$maria_exe_path/$prog");
     print MY_LOG $res;
     # derive table's name from program's name
-    if ($prog =~ m/ma_(test[0-9]+).*/)
+    if ($prog =~ m/^ma_(\S+)\s.*/)
     {
       $table= $1;
     }
+    else
+    {
+      die("can't guess table name");
+    }
     $com=  "$maria_exe_path/maria_chk$suffix -dvv $table ";
     $com.= "| grep -v \"Creation time:\" | grep -v \"file length\" ";
     $com.= "> $tmp/maria_chk_message.good.txt 2>&1";
@@ -182,10 +188,14 @@ sub main
           $res= my_exec("$maria_exe_path/$prog $commit_run_args");
           print MY_LOG $res;
           # derive table's name from program's name
-          if ($prog =~ m/ma_(test[0-9]+).*/)
+          if ($prog =~ m/^ma_(\S+)\s.*/)
           {
             $table= $1;
           }
+          else
+          {
+            die("can't guess table name");
+          }
           $com=  "$maria_exe_path/maria_chk$suffix -dvv $table ";
           $com.= "| grep -v \"Creation time:\" | grep -v \"file length\" ";
           $com.= "> $tmp/maria_chk_message.good.txt 2>&1";

=== modified file 'storage/myisam/rt_test.c'
--- a/storage/myisam/rt_test.c	2008-04-24 15:22:51 +0000
+++ b/storage/myisam/rt_test.c	2008-06-10 13:44:41 +0000
@@ -112,7 +112,13 @@ static int run_test(const char *filename
   uchar read_record[MAX_REC_LENGTH];
   int upd= 10;
   ha_rows hrows;
-  
+
+  bzero(&uniquedef, sizeof(uniquedef));
+  bzero(&create_info, sizeof(create_info));
+  bzero(recinfo, sizeof(recinfo));
+  bzero(keyinfo, sizeof(keyinfo));
+  bzero(keyseg, sizeof(keyseg));
+
   /* Define a column for NULLs and DEL markers*/
   
   recinfo[0].type=FIELD_NORMAL;
@@ -147,7 +153,6 @@ static int run_test(const char *filename
   if (!silent)
     printf("- Creating isam-file\n");
   
-  bzero((char*) &create_info,sizeof(create_info));
   create_info.max_rows=10000000;
   
   if (mi_create(filename,

Thread
bzr commit into MySQL/Maria:mysql-maria branch (monty:2645) Michael Widenius26 Jun