From 17a9470e0897027edefc42aa6299cefa8afa1327 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 5 Jun 2008 21:48:43 +0200 Subject: [PATCH 01/15] use "default" plugin configuration by default, not "none". enable maria in the default plugin configuration config/ac-macros/plugins.m4: typo in comment fixed. change default plugin configuration to be "default" not "none". don't print default plugin configuration in the help text (as it's "default" anyway) configure.in: use "default" plugin configuration by default, not "none" storage/maria/plug.in: enable maria in the default plugin configuration --- config/ac-macros/plugins.m4 | 6 +++--- configure.in | 2 +- storage/maria/plug.in | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/ac-macros/plugins.m4 b/config/ac-macros/plugins.m4 index 8dfb698709f..62789e2fb15 100644 --- a/config/ac-macros/plugins.m4 +++ b/config/ac-macros/plugins.m4 @@ -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 configure arguments 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 diff --git a/configure.in b/configure.in index d338828c5cc..4e74c708181 100644 --- a/configure.in +++ b/configure.in @@ -2387,7 +2387,7 @@ MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support], dnl -- ndbcluster requires partition to be enabled -MYSQL_CONFIGURE_PLUGINS([none]) +MYSQL_CONFIGURE_PLUGINS([default]) # Only build client code? AC_ARG_WITH(server, diff --git a/storage/maria/plug.in b/storage/maria/plug.in index 063ad7c65e4..02a6466bddc 100644 --- a/storage/maria/plug.in +++ b/storage/maria/plug.in @@ -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, From 54b719a2c62bf81e3451336b1cfe10faff1756a6 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Fri, 6 Jun 2008 15:37:16 +0200 Subject: [PATCH 02/15] Verify that if Maria table is absent or initially empty, CREATE SELECT and INSERT SELECT with enough rows cause no logging mysql-test/include/maria_empty_logs.inc: don't assume that mysqltest is the default db mysql-test/r/maria-no-logging.result: result. Without the optimization of disabling logging in ha_maria::start_bulk_insert(), we see 24k instead of 16k, in the cases where the table is empty. mysql-test/r/maria-purge.result: side effect of change to maria_empty_logs.inc mysql-test/t/maria-purge.test: maria-purge.test used to fail when run in a group like this "--big t/*maria*.test" because SHOW ENGINE MARIA LOGS was influenced by previous tests; deleting logs to fix that. --- mysql-test/include/maria_empty_logs.inc | 5 +- mysql-test/r/maria-no-logging.result | 55 +++++++++++++++++ mysql-test/r/maria-purge.result | 2 + mysql-test/t/maria-no-logging.test | 81 +++++++++++++++++++++++++ mysql-test/t/maria-purge.test | 14 +++++ 5 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/maria-no-logging.result create mode 100644 mysql-test/t/maria-no-logging.test diff --git a/mysql-test/include/maria_empty_logs.inc b/mysql-test/include/maria_empty_logs.inc index 2a4defe7b82..c3501051fd5 100644 --- a/mysql-test/include/maria_empty_logs.inc +++ b/mysql-test/include/maria_empty_logs.inc @@ -4,6 +4,9 @@ # API: set mel_keep_control_file=1 if want to keep control file; # uses vardir, port and socket. +connection default; +let $default_db=`select database()`; + connection admin; -- echo * shut down mysqld, removed logs, restarted it @@ -71,4 +74,4 @@ EOF connection default; # the effect of "use" is lost after a restart so we are back into db "test", # because connection 'default' was created with db "test". -use mysqltest; +eval use $default_db; diff --git a/mysql-test/r/maria-no-logging.result b/mysql-test/r/maria-no-logging.result new file mode 100644 index 00000000000..5d33e61f198 --- /dev/null +++ b/mysql-test/r/maria-no-logging.result @@ -0,0 +1,55 @@ +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 +use mysqltest; +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 +use mysqltest; +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 +use mysqltest; +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 +use mysqltest; +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; diff --git a/mysql-test/r/maria-purge.result b/mysql-test/r/maria-purge.result index 8155bc6ef2a..2fd68e7b94b 100644 --- a/mysql-test/r/maria-purge.result +++ b/mysql-test/r/maria-purge.result @@ -1,3 +1,5 @@ +* shut down mysqld, removed logs, restarted it +use test; set global storage_engine=maria; set session storage_engine=maria; set global maria_log_file_size=4294967295; diff --git a/mysql-test/t/maria-no-logging.test b/mysql-test/t/maria-no-logging.test new file mode 100644 index 00000000000..8ed2dbad338 --- /dev/null +++ b/mysql-test/t/maria-no-logging.test @@ -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 diff --git a/mysql-test/t/maria-purge.test b/mysql-test/t/maria-purge.test index 025118d3296..bb1a04d639b 100644 --- a/mysql-test/t/maria-purge.test +++ b/mysql-test/t/maria-purge.test @@ -1,5 +1,18 @@ -- source include/have_maria.inc -- source include/big_test.inc + +# pre-requisites for maria_empty_logs +connect (admin, 127.0.0.1, root,,test,,); +--enable_reconnect +connection default; +--enable_reconnect +# 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; set session storage_engine=maria; @@ -47,6 +60,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; From 5f26e7384f8e921e4b9b46a73138a6a8b0c0c795 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Mon, 9 Jun 2008 11:06:06 +0200 Subject: [PATCH 03/15] Fix for build failures under Windows storage/maria/CMakeLists.txt: add missing file storage/maria/ma_state.c: two include files are in storage/maria, not in include/, so they need "" not <>, or compiler misses them. --- storage/maria/CMakeLists.txt | 2 +- storage/maria/ma_state.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/maria/CMakeLists.txt b/storage/maria/CMakeLists.txt index c83a5af07c9..cf01a6f1be1 100644 --- a/storage/maria/CMakeLists.txt +++ b/storage/maria/CMakeLists.txt @@ -24,7 +24,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib 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 diff --git a/storage/maria/ma_state.c b/storage/maria/ma_state.c index 4dae0c3cc03..85e1b23349f 100644 --- a/storage/maria/ma_state.c +++ b/storage/maria/ma_state.c @@ -28,9 +28,9 @@ 10 ended transactions since last time it was called. */ -#include +#include "maria_def.h" #include "trnman.h" -#include +#include "ma_blockrec.h" /** @brief Setup initial start-of-transaction state for a table From 3967b6cfc7ceb4acf6188621e647b22c94cf7190 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Jun 2008 00:54:30 +0300 Subject: [PATCH 04/15] WL#4401 "Maria - deserialize translog_flush() calls" storage/maria/ma_loghandler.c: New flush procedure added. storage/maria/unittest/Makefile.am: Test of many multi-thread flush added storage/maria/unittest/ma_test_loghandler_multithread-t.c: Test of many multi-thread flush added --- storage/maria/ma_loghandler.c | 373 +++++++++++------- storage/maria/unittest/Makefile.am | 3 + .../ma_test_loghandler_multithread-t.c | 92 ++++- 3 files changed, 321 insertions(+), 147 deletions(-) diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 4daef976b6e..b2b9137c7c5 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -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; /* @@ -197,6 +206,8 @@ struct st_buffer_cursor }; +typedef uint8 dirty_buffer_mask_t; + struct st_translog_descriptor { /* *** Parameters of the log handler *** */ @@ -245,6 +256,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 +291,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 +319,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 +806,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 +1395,9 @@ LSN translog_get_file_max_lsn_stored(uint32 file) 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 +1996,9 @@ static void translog_start_buffer(struct st_translog_buffer *buffer, (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 +2013,10 @@ static void translog_start_buffer(struct st_translog_buffer *buffer, 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 +2076,6 @@ static my_bool translog_buffer_next(TRANSLOG_ADDRESS *horizon, 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 +2094,13 @@ static my_bool translog_buffer_next(TRANSLOG_ADDRESS *horizon, 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 +2215,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 +2429,6 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) 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 +2437,9 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) (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 +2499,11 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) { 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 +2555,9 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) 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 +3399,12 @@ my_bool translog_init_with_table(const char *directory, 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 +3419,9 @@ my_bool translog_init_with_table(const char *directory, 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, @@ -4016,6 +4069,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 +4741,13 @@ static translog_size_t translog_get_current_group_size() 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 +4837,9 @@ translog_write_variable_record_1group(LSN *lsn, 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 +4963,9 @@ translog_write_variable_record_1chunk(LSN *lsn, &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 +5310,7 @@ translog_write_variable_record_mgroup(LSN *lsn, 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 +5545,7 @@ translog_write_variable_record_mgroup(LSN *lsn, ((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 +5653,10 @@ translog_write_variable_record_mgroup(LSN *lsn, */ 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 +5712,6 @@ translog_write_variable_record_mgroup(LSN *lsn, *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 +5964,9 @@ static my_bool translog_write_fixed_record(LSN *lsn, 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(); @@ -7301,7 +7372,8 @@ static void translog_force_current_buffer_to_finish() #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 */ @@ -7363,170 +7435,195 @@ static void translog_force_current_buffer_to_finish() /** - @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 +*/ - @return Operation status - @retval 0 OK - @retval 1 Error +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; +} - @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(). - @todo: remove serialization and make group commit. +/** + @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 + */ 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 || translog_status == TRANSLOG_READONLY); LINT_INIT(sent_to_disk); + LINT_INIT(flush_horizon); + 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; + 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 (;;) - { - 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; + /* + 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) + { + struct st_translog_buffer *buffer= log_descriptor.bc.buffer; + 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) + 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) { - 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; + DBUG_ASSERT(flush_horizon <= buffer->offset + buffer->size); + flush_horizon= buffer->offset + buffer->size; + translog_buffer_flush(buffer); } - } 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) - { - current_file_handler++; - file_handlers[current_file_handler]= file; - } - /* 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) || @@ -7536,7 +7633,13 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn) 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); } diff --git a/storage/maria/unittest/Makefile.am b/storage/maria/unittest/Makefile.am index 7563827b581..afb7ba7b22c 100644 --- a/storage/maria/unittest/Makefile.am +++ b/storage/maria/unittest/Makefile.am @@ -42,6 +42,7 @@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \ 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 trnman-t lockman2-t \ 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 diff --git a/storage/maria/unittest/ma_test_loghandler_multithread-t.c b/storage/maria/unittest/ma_test_loghandler_multithread-t.c index ba612fab6a6..45ae4c1d87a 100644 --- a/storage/maria/unittest/ma_test_loghandler_multithread-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multithread-t.c @@ -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 *arg) } +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); From f89c61f5bbb45ae056bae0aee20317a019de6f66 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Tue, 10 Jun 2008 15:44:41 +0200 Subject: [PATCH 05/15] Fix for Valgrind errors when running rt_test and ma_rt_test, and segmentation fault in ma_rt_test -M (BUG#36321); keyinfo/recinfo/keyseg had non-initialized parts. maria_scan() was not wrapped in maria_scan_init()/end() so "ma_rt_test -M" found no rows. Preparing for inclusion into ma_test_all-t and ma_test_recovery.pl (still prevented by BUG#37307 "Maria: R-tree unit test produces corrupted table"). storage/maria/ma_rt_test.c: Some members of keyinfo, recinfo, keyseg had non-initialized parts, led to Valgrind errors, and also segmentation fault when running with -M (=BLOCK_RECORD) (BUG#36321). We now bzero them like they are in mi_test1. Other problems: - maria_scan() was not wrapped in maria_scan_init()/end() so "ma_rt_test -M" found no rows. - --silent had almost no effect, now it really silences normal output. - Some errors were going to stdout, they now go to stderr. Added option for testing versioning, to fit well into ma_test_all-t. storage/maria/unittest/ma_test_all-t: preparing for running ma_rt_test when ma_rt_test remaining bugs are fixed storage/maria/unittest/ma_test_recovery.pl: preparing for running ma_rt_test when ma_rt_test remaining bugs are fixed storage/myisam/rt_test.c: Some members of keyinfo, recinfo, keyseg were not initialized, led to Valgrind errors. We now bzero them like they are in mi_test1. --- storage/maria/ma_rt_test.c | 74 ++++++++++++++++------ storage/maria/unittest/ma_test_all-t | 13 ++++ storage/maria/unittest/ma_test_recovery.pl | 16 ++++- storage/myisam/rt_test.c | 9 ++- 4 files changed, 86 insertions(+), 26 deletions(-) diff --git a/storage/maria/ma_rt_test.c b/storage/maria/ma_rt_test.c index b329254149e..de59f445672 100644 --- a/storage/maria/ma_rt_test.c +++ b/storage/maria/ma_rt_test.c @@ -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,6 +142,12 @@ static int run_test(const char *filename) 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; @@ -177,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; @@ -195,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)) @@ -213,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"); @@ -234,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) @@ -266,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"); @@ -274,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; } } @@ -303,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: @@ -311,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_record(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; } } @@ -349,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"); @@ -361,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"); @@ -375,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; @@ -387,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"); @@ -405,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); @@ -430,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)) @@ -442,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 */ } @@ -467,7 +491,8 @@ static int read_with_pos (MARIA_HA * file) 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"); @@ -483,6 +508,8 @@ static void bprint_record(char * record, { int i; char * pos; + if (silent) + return; i=(unsigned char)record[0]; printf("%02X ",i); @@ -503,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++) { @@ -603,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} }; diff --git a/storage/maria/unittest/ma_test_all-t b/storage/maria/unittest/ma_test_all-t index d64662cb9ac..54fd7352275 100755 --- a/storage/maria/unittest/ma_test_all-t +++ b/storage/maria/unittest/ma_test_all-t @@ -259,12 +259,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; } @@ -291,6 +294,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 ; + 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 ; return 0; diff --git a/storage/maria/unittest/ma_test_recovery.pl b/storage/maria/unittest/ma_test_recovery.pl index 86658572da7..676b3e4417f 100755 --- a/storage/maria/unittest/ma_test_recovery.pl +++ b/storage/maria/unittest/ma_test_recovery.pl @@ -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"; diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c index 92f329baa81..6c73c9db13c 100644 --- a/storage/myisam/rt_test.c +++ b/storage/myisam/rt_test.c @@ -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, From a0aa81f9a81e5d2fdb0170a814cfd57eefa9e915 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Tue, 10 Jun 2008 16:44:44 +0200 Subject: [PATCH 06/15] Fix for BUG#36319 "Maria: table is not empty but DELETE and SELECT find no rows": _ma_scan_block_record() has "while (likely(bits))" where bits is ulonglong, so was cast to long which lost most significant bits (32-bit linux), and test yielded false. include/my_global.h: It's too easy to think that because "if (some_longlong)" works as intended, "if (likely(longlong))" will work too, though it does not. Making likely() cast to bool. mysql-test/r/maria2.result: Result. Before fixing the bug, 810 was 812 and 0 was 812 (DELETE and SELECT found no rows though they were there). mysql-test/t/maria2.test: Testcase for the bug. maria.test is huge now, so starting a second test file instead. --- include/my_global.h | 11 +++++-- mysql-test/r/maria2.result | 18 +++++++++++ mysql-test/t/maria2.test | 66 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 mysql-test/r/maria2.result create mode 100644 mysql-test/t/maria2.test diff --git a/include/my_global.h b/include/my_global.h index 47f7243e481..34b5a21beb2 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -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 diff --git a/mysql-test/r/maria2.result b/mysql-test/r/maria2.result new file mode 100644 index 00000000000..5012e552973 --- /dev/null +++ b/mysql-test/r/maria2.result @@ -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; diff --git a/mysql-test/t/maria2.test b/mysql-test/t/maria2.test new file mode 100644 index 00000000000..0127ec388ed --- /dev/null +++ b/mysql-test/t/maria2.test @@ -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; From 7c87c307f3afdc5c8c49239eb823d367f0024763 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Jun 2008 19:14:29 +0300 Subject: [PATCH 07/15] Fixed non-debug build. storage/maria/ma_loghandler.c: Now we need buffer number to set dirty buffers mask. --- storage/maria/ma_loghandler.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index b2b9137c7c5..3dbbb3914b7 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -137,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. @@ -3494,9 +3492,7 @@ my_bool translog_init_with_table(const char *directory, { 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)); } From 8ffd03394a19a9d11c92d8a7477cc05a19544ec9 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Tue, 10 Jun 2008 22:21:08 +0200 Subject: [PATCH 08/15] public commit mails --- .bzr-mysql/default.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 4265c8085e1..ad9b1e0a259 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,6 +1,6 @@ [MYSQL] tree_location = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/ -post_commit_to = maria-private@mysql.com +post_commit_to = maria@lists.mysql.com post_commit_url = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/ tree_name = mysql-maria project_name = MySQL/Maria From 8ac71501fcc075f5bc37669d8294459ec7e79276 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Wed, 11 Jun 2008 22:45:14 +0200 Subject: [PATCH 09/15] Fix for BUG#37005 "Maria: ALTER TABLE TRANSACTIONAL=0 leaves table transactional inside Maria" mysql-test/r/maria-page-checksum.result: result for new test portion. Without the code fix, you would see a wrong "yes" or "no" in the "Crashsafe" line for iterations 2,9,14. mysql-test/t/maria-page-checksum.test: Adding test for BUG#37005 "Maria: ALTER TABLE TRANSACTIONAL=0 leaves table transactional inside Maria" sql/sql_table.cc: In ALTER TABLE, we already rebuilt the table entirely if the DEFAULT CHARSET, ROW_FORMAT or PAGE_CHECKSUM clauses were used; we have to do the same if the TRANSACTIONAL clause is used, because it affects the table inside the engine (for example, Maria makes shorter rows in non-transactional tables). Not doing so led to the BUG#37005, where ALTER TABLE TRANSACTIONAL=0 sometimes left the table transactional into Maria though not in the frm. --- mysql-test/r/maria-page-checksum.result | 288 ++++++++++++++ mysql-test/t/maria-page-checksum.test | 509 +++++++++++++++++++++++- sql/sql_table.cc | 1 + 3 files changed, 794 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/maria-page-checksum.result b/mysql-test/r/maria-page-checksum.result index d7ab1fc4ba3..0319bd9e9ca 100644 --- a/mysql-test/r/maria-page-checksum.result +++ b/mysql-test/r/maria-page-checksum.result @@ -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; diff --git a/mysql-test/t/maria-page-checksum.test b/mysql-test/t/maria-page-checksum.test index 6c7c5afc2a5..e0a0a1517b1 100644 --- a/mysql-test/t/maria-page-checksum.test +++ b/mysql-test/t/maria-page-checksum.test @@ -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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + 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/, ); + close FILE; +EOF +drop table t1; + + diff --git a/sql/sql_table.cc b/sql/sql_table.cc index fbce42fd452..5ee2ccb5a64 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -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 || From bbef67f5bd2c18e103aeb87780dafdf16ba9efff Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Thu, 12 Jun 2008 15:49:19 +0200 Subject: [PATCH 10/15] Fix for BUG#35801 "Maria: unreadable log during tests" and BUG#35823 "Maria: log handler assertion (page[page_offset] & (3 << 6)) == 0x00... fails" Both random problems can be explained by the REDO phase starting from a log horizon which is not a LSN, which is the bug fixed here. storage/maria/ma_recovery.c: In Recovery, REDO phase needs to start log reading from a LSN, not a log horizon: start_address was only guaranteed to be a horizon, not necessarily a LSN. On some machine and test, it happened that start_address was only a log horizon, and run_redo_phase() tried to read from there, and log handler naturally refused that: ma_loghandler.c:6797: translog_read_record_header_from_buffer: Assertion `translog_is_LSN_chunk(page[page_offset])' failed. And in non-debug build, just the "redo phase failed" message in the error log. This was random, because depended on amount of checkpoints which is timing-dependent; also depended on Maria tests ran or skipped (so, debug or non-debug builds)... Bad code was introduced by me end of December so it's likely to explain lots of random log handler errors we observed since. --- storage/maria/ma_recovery.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index ec679609320..4dd10b2207f 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -3060,7 +3060,8 @@ static LSN parse_checkpoint_record(LSN lsn) 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) { /* From abdda9e2d95ee9082d205c67327afbeb3d2f0e1d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Jun 2008 21:05:31 +0300 Subject: [PATCH 11/15] More safe flush_horizon variable initialization. --- storage/maria/ma_loghandler.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 3dbbb3914b7..331d3c693f2 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -7500,8 +7500,6 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn) DBUG_ASSERT(translog_status == TRANSLOG_OK || translog_status == TRANSLOG_READONLY); LINT_INIT(sent_to_disk); - LINT_INIT(flush_horizon); - pthread_mutex_lock(&log_descriptor.log_flush_lock); DBUG_PRINT("info", ("Everything is flushed up to (%lu,0x%lx)", @@ -7526,6 +7524,7 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn) 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); From 26f685e72a2d160170284c0e1ce47803f230bc9a Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Fri, 13 Jun 2008 11:47:17 +0200 Subject: [PATCH 12/15] disabling lockman2-t: takes too much time for a unit test (>=15 min), and what it tests is not used in Maria, this fixes BUG#34744 "Maria Unit test "lockman2" fails on Mac OS X 10.4 PowerPC 64-bit" storage/maria/unittest/CMakeLists.txt: disabling lockman2-t storage/maria/unittest/Makefile.am: disabling lockman2-t --- storage/maria/unittest/CMakeLists.txt | 1 - storage/maria/unittest/Makefile.am | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/maria/unittest/CMakeLists.txt b/storage/maria/unittest/CMakeLists.txt index efc9fcddaff..a24c2d673f9 100644 --- a/storage/maria/unittest/CMakeLists.txt +++ b/storage/maria/unittest/CMakeLists.txt @@ -22,7 +22,6 @@ LINK_LIBRARIES(maria myisam mytap mysys dbug strings wsock32 zlib) 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 diff --git a/storage/maria/unittest/Makefile.am b/storage/maria/unittest/Makefile.am index afb7ba7b22c..3c0d4b89735 100644 --- a/storage/maria/unittest/Makefile.am +++ b/storage/maria/unittest/Makefile.am @@ -27,7 +27,7 @@ LDADD= $(top_builddir)/unittest/mytap/libmytap.a \ $(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 \ @@ -103,7 +103,8 @@ ma_pagecache_rwconsist_1k_t_SOURCES = ma_pagecache_rwconsist.c 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.???????? From 771a66eaeee0f68f2b64743973fd5b48f73723b3 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Fri, 13 Jun 2008 17:39:45 +0200 Subject: [PATCH 13/15] Port of ma_test_force_start.pl (test program for --maria-force-start-after-recovery-failures) to Windows. storage/maria/ma_test_force_start.pl: port to Windows: detection of where 'mysql' command-line client is (debug/release/etc)), .exe suffix, --console instead of --mem, --P instead of --socket, taskkill instead of perl's kill. --- storage/maria/ma_test_force_start.pl | 76 ++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/storage/maria/ma_test_force_start.pl b/storage/maria/ma_test_force_start.pl index db97e376004..0b25ac35605 100755 --- a/storage/maria/ma_test_force_start.pl +++ b/storage/maria/ma_test_force_start.pl @@ -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 <&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 + 1) open(FILE, "<", $error_log_name) or die; @cmd_output= ; 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= ; 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= ; 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= ; 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); From 96e2ca52adfc4e58e4a08d20dcb32a6ff2f1ab2c Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Mon, 16 Jun 2008 10:57:25 +0200 Subject: [PATCH 14/15] Fix for failure of test maria-recover under Windows. mysql-test/r/maria-recover.result: result update mysql-test/t/maria-recover.test: making test independent of / or \ in file names (failed under Windows) storage/maria/ma_test_force_start.pl: indentation --- mysql-test/r/maria-recover.result | 2 +- mysql-test/t/maria-recover.test | 1 + storage/maria/ma_test_force_start.pl | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/maria-recover.result b/mysql-test/r/maria-recover.result index f470d05081b..ff66a47f68b 100644 --- a/mysql-test/r/maria-recover.result +++ b/mysql-test/r/maria-recover.result @@ -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 diff --git a/mysql-test/t/maria-recover.test b/mysql-test/t/maria-recover.test index d6604d8f94e..83729c6bd46 100644 --- a/mysql-test/t/maria-recover.test +++ b/mysql-test/t/maria-recover.test @@ -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 diff --git a/storage/maria/ma_test_force_start.pl b/storage/maria/ma_test_force_start.pl index 0b25ac35605..44a2a62afed 100755 --- a/storage/maria/ma_test_force_start.pl +++ b/storage/maria/ma_test_force_start.pl @@ -44,12 +44,12 @@ my @cmd_output; my $whatever; # garbage data 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 < Date: Tue, 24 Jun 2008 17:14:56 +0300 Subject: [PATCH 15/15] Imported fix for bug#29464 from myisam table handler to maria. --- storage/maria/ma_ft_parser.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/storage/maria/ma_ft_parser.c b/storage/maria/ma_ft_parser.c index de29d9de816..25704f1af5a 100644 --- a/storage/maria/ma_ft_parser.c +++ b/storage/maria/ma_ft_parser.c @@ -114,7 +114,8 @@ uchar maria_ft_get_word(CHARSET_INFO *cs, uchar **start, uchar *end, { 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, uchar **start, uchar *end, while (doc 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, uchar **start, uchar *end, { /* 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, uchar **start, uchar *end, } 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_INFO *cs, uchar **start, 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_INFO *cs, uchar **start, } 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_call_initializer(MARIA_HA *info, 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; }