Commit 6686a3ee authored by unknown's avatar unknown

After merge fixes

Read blocks through page cache in check_block_record()
Don't read first bitmap on ma_open()
Don't require that a files block_size is equal to maria_block_size, if page cache is not setup yet.
Changed ma_test1, ma_test2, maria_chk and maria_pack to always create a page cache.
The above fixes so that ma_test_all now works again



BitKeeper/etc/ignore:
  added storage/maria/unittest/ma_pagecache_consist_1k-t-big storage/maria/unittest/ma_pagecache_consist_1kHC-t-big storage/maria/unittest/ma_pagecache_consist_1kRD-t-big storage/maria/unittest/ma_pagecache_consist_1kWR-t-big storage/maria/unittest/ma_pagecache_consist_64k-t-big storage/maria/unittest/ma_pagecache_consist_64kHC-t-big storage/maria/unittest/ma_pagecache_consist_64kRD-t-big storage/maria/unittest/ma_pagecache_consist_64kWR-t-big storage/maria/unittest/ma_pagecache_single_64k-t-big
include/maria.h:
  Added MARIA_MIN_PAGE_CACHE_SIZE
include/pagecache.h:
  Filedescriptors should be of type File
storage/maria/ma_bitmap.c:
  After merge fixes
  Create dummy bitmap on startup (can't read first bitmap becasue page cache may not be set up yet)
storage/maria/ma_blockrec.c:
  After merge fixes
storage/maria/ma_check.c:
  Use page cache to read rows-in-block rows.
  Don't initialize page cache; It's now done in maria_chk
storage/maria/ma_dynrec.c:
  Trivial code reorganization
storage/maria/ma_open.c:
  Don't give error for conflicting block size if page cache is not initalized.
  (Needed for maria_chk to be able to work on tables with different page sizes)
  After merge fixes
storage/maria/ma_page.c:
  Fix compiler warning
  Remove net needed asserts (Guranteed by ma_create())
storage/maria/ma_pagecache.c:
  Allow one to create a page cache with just one block
  (For trivail scan of table)
  Trivial code simplication
storage/maria/ma_test1.c:
  Always create a page cache (Maria now requires a page cache to work)
storage/maria/ma_test2.c:
  Always create a page cache (Maria now requires a page cache to work)
storage/maria/maria_chk.c:
  Remove command line options --maria_block_size and --pagecache_block_size.
  Set the global maria_block_size from the data file. This allows maria_chk to work with tables of different block sizes.
  Simply DESCRIPT handling; Allows us to remove one indentation level in maria_chk().
  Always initialize page cache if we are doing check/repair.
  (Most of the patch is reindentation of the code)
storage/maria/maria_def.h:
  After merge fix
storage/maria/maria_pack.c:
  Set maria_block_size based on the files block_size.
  Initalize page cache (needed for getting rows-in-blocks to works)
parent ac0f98dd
...@@ -2989,3 +2989,12 @@ win/vs71cache.txt ...@@ -2989,3 +2989,12 @@ win/vs71cache.txt
win/vs8cache.txt win/vs8cache.txt
zlib/*.ds? zlib/*.ds?
zlib/*.vcproj zlib/*.vcproj
storage/maria/unittest/ma_pagecache_consist_1k-t-big
storage/maria/unittest/ma_pagecache_consist_1kHC-t-big
storage/maria/unittest/ma_pagecache_consist_1kRD-t-big
storage/maria/unittest/ma_pagecache_consist_1kWR-t-big
storage/maria/unittest/ma_pagecache_consist_64k-t-big
storage/maria/unittest/ma_pagecache_consist_64kHC-t-big
storage/maria/unittest/ma_pagecache_consist_64kRD-t-big
storage/maria/unittest/ma_pagecache_consist_64kWR-t-big
storage/maria/unittest/ma_pagecache_single_64k-t-big
...@@ -54,6 +54,8 @@ extern "C" { ...@@ -54,6 +54,8 @@ extern "C" {
#define MARIA_KEY_BLOCK_LENGTH 8192 /* default key block length */ #define MARIA_KEY_BLOCK_LENGTH 8192 /* default key block length */
#define MARIA_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */ #define MARIA_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */
#define MARIA_MAX_KEY_BLOCK_LENGTH 32768 #define MARIA_MAX_KEY_BLOCK_LENGTH 32768
/* Minimal page cache when we only want to be able to scan a table */
#define MARIA_MIN_PAGE_CACHE_SIZE 65536
/* /*
In the following macros '_keyno_' is 0 .. keys-1. In the following macros '_keyno_' is 0 .. keys-1.
......
...@@ -75,7 +75,7 @@ typedef void *PAGECACHE_PAGE_LINK; ...@@ -75,7 +75,7 @@ typedef void *PAGECACHE_PAGE_LINK;
/* file descriptor for Maria */ /* file descriptor for Maria */
typedef struct st_pagecache_file typedef struct st_pagecache_file
{ {
int file; /* it is for debugging purposes then it will be uint32 file_no */ File file;
} PAGECACHE_FILE; } PAGECACHE_FILE;
/* page number for maria */ /* page number for maria */
......
...@@ -131,7 +131,7 @@ static inline my_bool write_changed_bitmap(MARIA_SHARE *share, ...@@ -131,7 +131,7 @@ static inline my_bool write_changed_bitmap(MARIA_SHARE *share,
{ {
DBUG_ASSERT(share->pagecache->block_size == bitmap->block_size); DBUG_ASSERT(share->pagecache->block_size == bitmap->block_size);
return (pagecache_write(share->pagecache, return (pagecache_write(share->pagecache,
(PAGECACHE_FILE*)&bitmap->file, bitmap->page, 0, &bitmap->file, bitmap->page, 0,
(byte*) bitmap->map, PAGECACHE_PLAIN_PAGE, (byte*) bitmap->map, PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_LOCK_LEFT_UNLOCKED,
PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_PIN_LEFT_UNPINNED,
...@@ -168,7 +168,7 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file) ...@@ -168,7 +168,7 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file)
if (!(bitmap->map= (uchar*) my_malloc(size, MYF(MY_WME)))) if (!(bitmap->map= (uchar*) my_malloc(size, MYF(MY_WME))))
return 1; return 1;
bitmap->file= file; bitmap->file.file= file;
bitmap->changed= 0; bitmap->changed= 0;
bitmap->block_size= share->block_size; bitmap->block_size= share->block_size;
/* Size needs to be alligned on 6 */ /* Size needs to be alligned on 6 */
...@@ -195,10 +195,15 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file) ...@@ -195,10 +195,15 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file)
pthread_mutex_init(&share->bitmap.bitmap_lock, MY_MUTEX_INIT_SLOW); pthread_mutex_init(&share->bitmap.bitmap_lock, MY_MUTEX_INIT_SLOW);
/* /*
Start by reading first page (assume table scan) We can't read a page yet, as in some case we don't have an active
Later code is simpler if it can assume we always have an active bitmap. page cache yet.
Pretend we have a dummy, full and not changed bitmap page in memory.
*/ */
return _ma_read_bitmap_page(share, bitmap, (ulonglong) 0);
bitmap->page= ~(ulonglong) 0;
bitmap->used_size= bitmap->total_size;
bfill(bitmap->map, share->block_size, 255);
return 0;
} }
......
...@@ -374,21 +374,20 @@ my_bool _ma_once_init_block_record(MARIA_SHARE *share, File data_file) ...@@ -374,21 +374,20 @@ my_bool _ma_once_init_block_record(MARIA_SHARE *share, File data_file)
my_bool _ma_once_end_block_record(MARIA_SHARE *share) my_bool _ma_once_end_block_record(MARIA_SHARE *share)
{ {
int res= _ma_bitmap_end(share); int res= _ma_bitmap_end(share);
if (share->bitmap.file >= 0) if (share->bitmap.file.file >= 0)
{ {
if (flush_pagecache_blocks(share->pagecache, (PAGECACHE_FILE*)&share->bitmap, if (flush_pagecache_blocks(share->pagecache, &share->bitmap.file,
if (flush_key_blocks(share->key_cache, share->bitmap.file, share->temporary ? FLUSH_IGNORE_CHANGED :
share->temporary ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE))
FLUSH_RELEASE))
res= 1; res= 1;
if (my_close(share->bitmap.file, MYF(MY_WME))) if (my_close(share->bitmap.file.file, MYF(MY_WME)))
res= 1; res= 1;
/* /*
Trivial assignment to guard against multiple invocations Trivial assignment to guard against multiple invocations
(May happen if file are closed but we want to keep the maria object (May happen if file are closed but we want to keep the maria object
around a bit longer) around a bit longer)
*/ */
share->bitmap.file= -1; share->bitmap.file.file= -1;
} }
return res; return res;
} }
...@@ -450,7 +449,7 @@ void _ma_end_block_record(MARIA_HA *info) ...@@ -450,7 +449,7 @@ void _ma_end_block_record(MARIA_HA *info)
The following protects us from doing an extra, not allowed, close The following protects us from doing an extra, not allowed, close
in maria_close() in maria_close()
*/ */
info->dfile= -1; info->dfile.file= -1;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -1599,8 +1599,12 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend, ...@@ -1599,8 +1599,12 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend,
if (((pos / block_size) % info->s->bitmap.pages_covered) == 0) if (((pos / block_size) % info->s->bitmap.pages_covered) == 0)
{ {
/* Bitmap page */ /* Bitmap page */
if (_ma_read_cache(&param->read_cache, bitmap_buff, pos, if (pagecache_read(info->s->pagecache,
block_size, READING_NEXT)) &info->dfile,
(pos / block_size), 1,
bitmap_buff,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED, 0) == 0)
{ {
_ma_check_print_error(param, _ma_check_print_error(param,
"Page %9s: Got error: %d when reading datafile", "Page %9s: Got error: %d when reading datafile",
...@@ -1624,8 +1628,12 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend, ...@@ -1624,8 +1628,12 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend,
continue; continue;
} }
if (_ma_read_cache(&param->read_cache, page_buff, pos, if (pagecache_read(info->s->pagecache,
block_size, READING_NEXT)) &info->dfile,
(pos / block_size), 1,
page_buff,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED, 0) == 0)
{ {
_ma_check_print_error(param, _ma_check_print_error(param,
"Page %9s: Got error: %d when reading datafile", "Page %9s: Got error: %d when reading datafile",
...@@ -1935,10 +1943,6 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info, ...@@ -1935,10 +1943,6 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
param->testflag|=T_CALC_CHECKSUM; param->testflag|=T_CALC_CHECKSUM;
if (!param->using_global_keycache)
VOID(init_pagecache(maria_pagecache, param->use_buffers, 0, 0,
param->pagecache_block_size));
if (init_io_cache(&param->read_cache, info->dfile.file, if (init_io_cache(&param->read_cache, info->dfile.file,
(uint) param->read_buffer_length, (uint) param->read_buffer_length,
READ_CACHE,share->pack.header_length,1,MYF(MY_WME))) READ_CACHE,share->pack.header_length,1,MYF(MY_WME)))
...@@ -2308,8 +2312,6 @@ int _ma_flush_blocks(HA_CHECK *param, PAGECACHE *pagecache, ...@@ -2308,8 +2312,6 @@ int _ma_flush_blocks(HA_CHECK *param, PAGECACHE *pagecache,
_ma_check_print_error(param,"%d when trying to write bufferts",my_errno); _ma_check_print_error(param,"%d when trying to write bufferts",my_errno);
return(1); return(1);
} }
if (!param->using_global_keycache)
end_pagecache(pagecache,1);
return 0; return 0;
} /* _ma_flush_blocks */ } /* _ma_flush_blocks */
...@@ -3602,7 +3604,6 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param) ...@@ -3602,7 +3604,6 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
int parallel_flag; int parallel_flag;
uint found_record,b_type,left_length; uint found_record,b_type,left_length;
my_off_t pos; my_off_t pos;
byte *to;
MARIA_BLOCK_INFO block_info; MARIA_BLOCK_INFO block_info;
MARIA_SORT_INFO *sort_info=sort_param->sort_info; MARIA_SORT_INFO *sort_info=sort_param->sort_info;
HA_CHECK *param=sort_info->param; HA_CHECK *param=sort_info->param;
...@@ -3652,6 +3653,8 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param) ...@@ -3652,6 +3653,8 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
} }
} }
case DYNAMIC_RECORD: case DYNAMIC_RECORD:
{
byte *to;
LINT_INIT(to); LINT_INIT(to);
pos=sort_param->pos; pos=sort_param->pos;
searching=(sort_param->fix_datafile && (param->testflag & T_EXTEND)); searching=(sort_param->fix_datafile && (param->testflag & T_EXTEND));
...@@ -3948,6 +3951,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param) ...@@ -3948,6 +3951,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
pos=(sort_param->start_recpos+=MARIA_DYN_ALIGN_SIZE); pos=(sort_param->start_recpos+=MARIA_DYN_ALIGN_SIZE);
searching=1; searching=1;
} }
}
case COMPRESSED_RECORD: case COMPRESSED_RECORD:
for (searching=0 ;; searching=1, sort_param->pos++) for (searching=0 ;; searching=1, sort_param->pos++)
{ {
......
...@@ -1372,13 +1372,15 @@ int _ma_read_dynamic_record(MARIA_HA *info, byte *buf, ...@@ -1372,13 +1372,15 @@ int _ma_read_dynamic_record(MARIA_HA *info, byte *buf,
{ {
int block_of_record; int block_of_record;
uint b_type,left_length; uint b_type,left_length;
byte *to;
MARIA_BLOCK_INFO block_info; MARIA_BLOCK_INFO block_info;
File file; File file;
DBUG_ENTER("_ma_read_dynamic_record"); DBUG_ENTER("_ma_read_dynamic_record");
if (filepos != HA_OFFSET_ERROR) if (filepos != HA_OFFSET_ERROR)
{ {
byte *to;
uint left_length;
LINT_INIT(to); LINT_INIT(to);
LINT_INIT(left_length); LINT_INIT(left_length);
file= info->dfile.file; file= info->dfile.file;
...@@ -1390,13 +1392,14 @@ int _ma_read_dynamic_record(MARIA_HA *info, byte *buf, ...@@ -1390,13 +1392,14 @@ int _ma_read_dynamic_record(MARIA_HA *info, byte *buf,
if (filepos == HA_OFFSET_ERROR) if (filepos == HA_OFFSET_ERROR)
goto panic; goto panic;
if (info->opt_flag & WRITE_CACHE_USED && if (info->opt_flag & WRITE_CACHE_USED &&
info->rec_cache.pos_in_file < filepos + MARIA_BLOCK_INFO_HEADER_LENGTH && (info->rec_cache.pos_in_file < filepos +
MARIA_BLOCK_INFO_HEADER_LENGTH) &&
flush_io_cache(&info->rec_cache)) flush_io_cache(&info->rec_cache))
goto err; goto err;
info->rec_cache.seek_not_done=1; info->rec_cache.seek_not_done=1;
if ((b_type= _ma_get_block_info(&block_info, file, filepos)) if ((b_type= _ma_get_block_info(&block_info, file, filepos)) &
& (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR | (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
BLOCK_FATAL_ERROR)) BLOCK_FATAL_ERROR))
{ {
if (b_type & (BLOCK_SYNC_ERROR | BLOCK_DELETED)) if (b_type & (BLOCK_SYNC_ERROR | BLOCK_DELETED))
my_errno=HA_ERR_RECORD_DELETED; my_errno=HA_ERR_RECORD_DELETED;
......
...@@ -239,7 +239,12 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -239,7 +239,12 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
my_errno=HA_ERR_UNSUPPORTED; my_errno=HA_ERR_UNSUPPORTED;
goto err; goto err;
} }
if (share->base.block_size != maria_block_size) /*
If page cache is not initialized, then assume we will create it
after the table is opened!
*/
if (share->base.block_size != maria_block_size &&
share_buff.pagecache->inited != 0)
{ {
DBUG_PRINT("error", ("Wrong block size %u; Expected %u", DBUG_PRINT("error", ("Wrong block size %u; Expected %u",
(uint) share->base.block_size, (uint) share->base.block_size,
...@@ -301,7 +306,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -301,7 +306,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
strmov(share->index_file_name, index_name); strmov(share->index_file_name, index_name);
strmov(share->data_file_name, data_name); strmov(share->data_file_name, data_name);
share->block_size= maria_block_size; share->block_size= share->base.block_size;
{ {
HA_KEYSEG *pos=share->keyparts; HA_KEYSEG *pos=share->keyparts;
for (i=0 ; i < keys ; i++) for (i=0 ; i < keys ; i++)
...@@ -553,7 +558,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -553,7 +558,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
goto err; goto err;
} }
if (share->data_file_type == BLOCK_RECORD) if (share->data_file_type == BLOCK_RECORD)
info.dfile.file= share->bitmap.file; info.dfile= share->bitmap.file;
else if (_ma_open_datafile(&info, share, old_info->dfile.file)) else if (_ma_open_datafile(&info, share, old_info->dfile.file))
goto err; goto err;
errpos= 5; errpos= 5;
......
...@@ -21,15 +21,15 @@ ...@@ -21,15 +21,15 @@
byte *_ma_fetch_keypage(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, byte *_ma_fetch_keypage(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
my_off_t page, int level, my_off_t page, int level,
byte *buff, int return_buffer) byte *buff,
int return_buffer __attribute__ ((unused)))
{ {
byte *tmp; byte *tmp;
uint page_size; uint page_size;
DBUG_ENTER("_ma_fetch_keypage"); DBUG_ENTER("_ma_fetch_keypage");
DBUG_PRINT("enter",("page: %ld", (long) page)); DBUG_PRINT("enter",("page: %ld", (long) page));
DBUG_ASSERT(info->s->pagecache->block_size == keyinfo->block_length && DBUG_ASSERT(info->s->pagecache->block_size == keyinfo->block_length);
info->s->pagecache->block_size == info->s->block_size);
/* /*
TODO: replace PAGECACHE_PLAIN_PAGE with PAGECACHE_LSN_PAGE when TODO: replace PAGECACHE_PLAIN_PAGE with PAGECACHE_LSN_PAGE when
LSN on the pages will be implemented LSN on the pages will be implemented
...@@ -88,7 +88,6 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -88,7 +88,6 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
#endif #endif
DBUG_ASSERT(info->s->pagecache->block_size == keyinfo->block_length); DBUG_ASSERT(info->s->pagecache->block_size == keyinfo->block_length);
DBUG_ASSERT(info->s->pagecache->block_size == info->s->block_size);
/* /*
TODO: replace PAGECACHE_PLAIN_PAGE with PAGECACHE_LSN_PAGE when TODO: replace PAGECACHE_PLAIN_PAGE with PAGECACHE_LSN_PAGE when
LSN on the pages will be implemented LSN on the pages will be implemented
......
...@@ -675,8 +675,11 @@ int init_pagecache(PAGECACHE *pagecache, my_size_t use_mem, ...@@ -675,8 +675,11 @@ int init_pagecache(PAGECACHE *pagecache, my_size_t use_mem,
2 * sizeof(PAGECACHE_HASH_LINK) + 2 * sizeof(PAGECACHE_HASH_LINK) +
sizeof(PAGECACHE_HASH_LINK*) * sizeof(PAGECACHE_HASH_LINK*) *
5/4 + block_size)); 5/4 + block_size));
/* It doesn't make sense to have too few blocks (less than 8) */ /*
if (blocks >= 8 && pagecache->disk_blocks < 0) We need to support page cache with just one block to be able to do
scanning of rows-in-block files
*/
if (blocks >= 1)
{ {
for ( ; ; ) for ( ; ; )
{ {
...@@ -3768,7 +3771,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, ...@@ -3768,7 +3771,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
LEX_STRING *str, LEX_STRING *str,
LSN *max_lsn) LSN *max_lsn)
{ {
my_bool error; my_bool error= 0;
ulong stored_list_size= 0; ulong stored_list_size= 0;
uint file_hash; uint file_hash;
char *ptr; char *ptr;
...@@ -3836,7 +3839,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, ...@@ -3836,7 +3839,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
ptr= str->str; ptr= str->str;
int8store(ptr, stored_list_size); int8store(ptr, stored_list_size);
ptr+= 8; ptr+= 8;
if (0 == stored_list_size) if (!stored_list_size)
goto end; goto end;
for (file_hash= 0; file_hash < PAGECACHE_CHANGED_BLOCKS_HASH; file_hash++) for (file_hash= 0; file_hash < PAGECACHE_CHANGED_BLOCKS_HASH; file_hash++)
{ {
...@@ -3858,13 +3861,13 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, ...@@ -3858,13 +3861,13 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
set_if_bigger(*max_lsn, block->rec_lsn); set_if_bigger(*max_lsn, block->rec_lsn);
} }
} }
error= 0;
goto end;
err:
error= 1;
end: end:
pagecache_pthread_mutex_unlock(&pagecache->cache_lock); pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
DBUG_RETURN(error); DBUG_RETURN(error);
err:
error= 1;
goto end;
} }
......
...@@ -51,8 +51,8 @@ int main(int argc,char *argv[]) ...@@ -51,8 +51,8 @@ int main(int argc,char *argv[])
my_init(); my_init();
maria_init(); maria_init();
get_options(argc,argv); get_options(argc,argv);
if (pagecacheing) /* Maria requires that we always have a page cache */
init_pagecache(maria_pagecache, IO_SIZE*16, 0, 0, MARIA_KEY_BLOCK_LENGTH); init_pagecache(maria_pagecache, IO_SIZE*16, 0, 0, maria_block_size);
exit(run_test("test1")); exit(run_test("test1"));
} }
......
...@@ -50,7 +50,6 @@ static int verbose=0,testflag=0, ...@@ -50,7 +50,6 @@ static int verbose=0,testflag=0,
static int pack_seg=HA_SPACE_PACK,pack_type=HA_PACK_KEY,remove_count=-1; static int pack_seg=HA_SPACE_PACK,pack_type=HA_PACK_KEY,remove_count=-1;
static int create_flag= 0, srand_arg= 0; static int create_flag= 0, srand_arg= 0;
static ulong pagecache_size=IO_SIZE*16; static ulong pagecache_size=IO_SIZE*16;
static uint pagecache_block_size= MARIA_KEY_BLOCK_LENGTH;
static enum data_file_type record_type= DYNAMIC_RECORD; static enum data_file_type record_type= DYNAMIC_RECORD;
static uint keys=MARIA_KEYS,recant=1000; static uint keys=MARIA_KEYS,recant=1000;
...@@ -219,8 +218,8 @@ int main(int argc, char *argv[]) ...@@ -219,8 +218,8 @@ int main(int argc, char *argv[])
goto err; goto err;
if (!silent) if (!silent)
printf("- Writing key:s\n"); printf("- Writing key:s\n");
if (pagecacheing) /* Maria requires that we always have a page cache */
init_pagecache(maria_pagecache, pagecache_size, 0, 0, pagecache_block_size); init_pagecache(maria_pagecache, pagecache_size, 0, 0, maria_block_size);
if (locking) if (locking)
maria_lock_database(file,F_WRLCK); maria_lock_database(file,F_WRLCK);
if (write_cacheing) if (write_cacheing)
...@@ -282,12 +281,11 @@ int main(int argc, char *argv[]) ...@@ -282,12 +281,11 @@ int main(int argc, char *argv[])
goto end; goto end;
} }
} }
/* #ifdef REMOVE_WHEN_WE_HAVE_RESIZE
TODO: uncomment when resize will be implemented
if (pagecacheing) if (pagecacheing)
resize_pagecache(maria_pagecache, pagecache_block_size, resize_pagecache(maria_pagecache, maria_block_size,
pagecache_size * 2, 0, 0); pagecache_size * 2, 0, 0);
*/ #endif
if (!silent) if (!silent)
printf("- Delete\n"); printf("- Delete\n");
if (srand_arg) if (srand_arg)
...@@ -862,13 +860,8 @@ int main(int argc, char *argv[]) ...@@ -862,13 +860,8 @@ int main(int argc, char *argv[])
if (rec_pointer_size) if (rec_pointer_size)
printf("Record pointer size: %d\n",rec_pointer_size); printf("Record pointer size: %d\n",rec_pointer_size);
printf("maria_block_size: %lu\n", maria_block_size); printf("maria_block_size: %lu\n", maria_block_size);
if (pagecacheing) if (write_cacheing)
{ puts("Key cache resized");
puts("Key cache used");
printf("pagecache_block_size: %u\n", pagecache_block_size);
if (write_cacheing)
puts("Key cache resized");
}
if (write_cacheing) if (write_cacheing)
puts("Write cacheing used"); puts("Write cacheing used");
if (write_cacheing) if (write_cacheing)
...@@ -960,6 +953,7 @@ static void get_options(int argc, char **argv) ...@@ -960,6 +953,7 @@ static void get_options(int argc, char **argv)
} }
break; break;
case 'e': /* maria_block_length */ case 'e': /* maria_block_length */
case 'E':
if ((maria_block_size= atoi(++pos)) < MARIA_MIN_KEY_BLOCK_LENGTH || if ((maria_block_size= atoi(++pos)) < MARIA_MIN_KEY_BLOCK_LENGTH ||
maria_block_size > MARIA_MAX_KEY_BLOCK_LENGTH) maria_block_size > MARIA_MAX_KEY_BLOCK_LENGTH)
{ {
...@@ -968,15 +962,6 @@ static void get_options(int argc, char **argv) ...@@ -968,15 +962,6 @@ static void get_options(int argc, char **argv)
} }
maria_block_size= my_round_up_to_next_power(maria_block_size); maria_block_size= my_round_up_to_next_power(maria_block_size);
break; break;
case 'E': /* maria_block_length */
if ((pagecache_block_size=atoi(++pos)) < MARIA_MIN_KEY_BLOCK_LENGTH ||
pagecache_block_size > MARIA_MAX_KEY_BLOCK_LENGTH)
{
fprintf(stderr,"Wrong pagecache_block_size\n");
exit(1);
}
pagecache_block_size= my_round_up_to_next_power(pagecache_block_size);
break;
case 'f': case 'f':
if ((first_key=atoi(++pos)) < 0 || first_key >= MARIA_KEYS) if ((first_key=atoi(++pos)) < 0 || first_key >= MARIA_KEYS)
first_key=0; first_key=0;
......
...@@ -39,8 +39,6 @@ static char **default_argv; ...@@ -39,8 +39,6 @@ static char **default_argv;
static const char *load_default_groups[]= { "maria_chk", 0 }; static const char *load_default_groups[]= { "maria_chk", 0 };
static const char *set_collation_name, *opt_tmpdir; static const char *set_collation_name, *opt_tmpdir;
static CHARSET_INFO *set_collation; static CHARSET_INFO *set_collation;
static long opt_maria_block_size;
static long opt_pagecache_block_size;
static const char *my_progname_short; static const char *my_progname_short;
static int stopwords_inited= 0; static int stopwords_inited= 0;
static MY_TMPDIR maria_chk_tmpdir; static MY_TMPDIR maria_chk_tmpdir;
...@@ -301,15 +299,6 @@ static struct my_option my_long_options[] = ...@@ -301,15 +299,6 @@ static struct my_option my_long_options[] =
(gptr*) &check_param.use_buffers, (gptr*) &check_param.use_buffers, 0, (gptr*) &check_param.use_buffers, (gptr*) &check_param.use_buffers, 0,
GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD, GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD,
(long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0}, (long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0},
{ "pagecache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "",
(gptr*) &opt_pagecache_block_size,
(gptr*) &opt_pagecache_block_size, 0,
GET_LONG, REQUIRED_ARG, MARIA_KEY_BLOCK_LENGTH, MARIA_MIN_KEY_BLOCK_LENGTH,
MARIA_MAX_KEY_BLOCK_LENGTH, 0, MARIA_MIN_KEY_BLOCK_LENGTH, 0},
{ "maria_block_size", OPT_MARIA_BLOCK_SIZE, "",
(gptr*) &opt_maria_block_size, (gptr*) &opt_maria_block_size, 0,
GET_LONG, REQUIRED_ARG, MARIA_KEY_BLOCK_LENGTH, MARIA_MIN_KEY_BLOCK_LENGTH,
MARIA_MAX_KEY_BLOCK_LENGTH, 0, MARIA_MIN_KEY_BLOCK_LENGTH, 0},
{ "read_buffer_size", OPT_READ_BUFFER_SIZE, "", { "read_buffer_size", OPT_READ_BUFFER_SIZE, "",
(gptr*) &check_param.read_buffer_length, (gptr*) &check_param.read_buffer_length,
(gptr*) &check_param.read_buffer_length, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &check_param.read_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
...@@ -793,14 +782,12 @@ static void get_options(register int *argc,register char ***argv) ...@@ -793,14 +782,12 @@ static void get_options(register int *argc,register char ***argv)
exit(1); exit(1);
check_param.tmpdir=&maria_chk_tmpdir; check_param.tmpdir=&maria_chk_tmpdir;
check_param.pagecache_block_size= opt_pagecache_block_size;
if (set_collation_name) if (set_collation_name)
if (!(set_collation= get_charset_by_name(set_collation_name, if (!(set_collation= get_charset_by_name(set_collation_name,
MYF(MY_WME)))) MYF(MY_WME))))
exit(1); exit(1);
maria_block_size=(uint) 1 << my_bit_log2(opt_maria_block_size);
return; return;
} /* get options */ } /* get options */
...@@ -873,6 +860,7 @@ static int maria_chk(HA_CHECK *param, my_string filename) ...@@ -873,6 +860,7 @@ static int maria_chk(HA_CHECK *param, my_string filename)
share->options&= ~HA_OPTION_READ_ONLY_DATA; /* We are modifing it */ share->options&= ~HA_OPTION_READ_ONLY_DATA; /* We are modifing it */
share->tot_locks-= share->r_locks; share->tot_locks-= share->r_locks;
share->r_locks=0; share->r_locks=0;
maria_block_size= share->base.block_size;
if (share->data_file_type == BLOCK_RECORD && if (share->data_file_type == BLOCK_RECORD &&
(param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_FAST | T_STATISTICS | (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_FAST | T_STATISTICS |
...@@ -944,8 +932,7 @@ static int maria_chk(HA_CHECK *param, my_string filename) ...@@ -944,8 +932,7 @@ static int maria_chk(HA_CHECK *param, my_string filename)
maria_test_if_almost_full(info) || maria_test_if_almost_full(info) ||
info->s->state.header.file_version[3] != maria_file_magic[3] || info->s->state.header.file_version[3] != maria_file_magic[3] ||
(set_collation && (set_collation &&
set_collation->number != share->state.header.language) || set_collation->number != share->state.header.language)))
maria_block_size != MARIA_KEY_BLOCK_LENGTH))
{ {
if (set_collation) if (set_collation)
param->language= set_collation->number; param->language= set_collation->number;
...@@ -975,211 +962,217 @@ static int maria_chk(HA_CHECK *param, my_string filename) ...@@ -975,211 +962,217 @@ static int maria_chk(HA_CHECK *param, my_string filename)
param->total_records+=info->state->records; param->total_records+=info->state->records;
param->total_deleted+=info->state->del; param->total_deleted+=info->state->del;
descript(param, info, filename); descript(param, info, filename);
maria_close(info); /* Should always succeed */
return(0);
} }
if (!stopwords_inited++)
ft_init_stopwords();
if (!(param->testflag & T_READONLY))
lock_type = F_WRLCK; /* table is changed */
else else
lock_type= F_RDLCK;
if (info->lock_type == F_RDLCK)
info->lock_type=F_UNLCK; /* Read only table */
if (_ma_readinfo(info,lock_type,0))
{
_ma_check_print_error(param,"Can't lock indexfile of '%s', error: %d",
filename,my_errno);
param->error_printed=0;
error= 1;
goto end2;
}
/*
_ma_readinfo() has locked the table.
We mark the table as locked (without doing file locks) to be able to
use functions that only works on locked tables (like row caching).
*/
maria_lock_database(info, F_EXTRA_LCK);
datafile= info->dfile.file;
if (init_pagecache(maria_pagecache, param->use_buffers, 0, 0,
maria_block_size) == 0)
{ {
if (!stopwords_inited++) _ma_check_print_error(param, "Can't initialize page cache with %lu memory",
ft_init_stopwords(); (ulong) param->use_buffers);
error= 1;
goto end2;
}
if (!(param->testflag & T_READONLY)) if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX))
lock_type = F_WRLCK; /* table is changed */ {
else if (param->testflag & T_REP_ANY)
lock_type= F_RDLCK;
if (info->lock_type == F_RDLCK)
info->lock_type=F_UNLCK; /* Read only table */
if (_ma_readinfo(info,lock_type,0))
{ {
_ma_check_print_error(param,"Can't lock indexfile of '%s', error: %d", ulonglong tmp=share->state.key_map;
filename,my_errno); maria_copy_keys_active(share->state.key_map, share->base.keys,
param->error_printed=0; param->keys_in_use);
error= 1; if (tmp != share->state.key_map)
goto end2; info->update|=HA_STATE_CHANGED;
} }
/* if (rep_quick &&
_ma_readinfo() has locked the table. maria_chk_del(param, info, param->testflag & ~T_VERBOSE))
We mark the table as locked (without doing file locks) to be able to
use functions that only works on locked tables (like row caching).
*/
maria_lock_database(info, F_EXTRA_LCK);
datafile= info->dfile.file;
if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX))
{ {
if (param->testflag & T_REP_ANY) if (param->testflag & T_FORCE_CREATE)
{
ulonglong tmp=share->state.key_map;
maria_copy_keys_active(share->state.key_map, share->base.keys,
param->keys_in_use);
if (tmp != share->state.key_map)
info->update|=HA_STATE_CHANGED;
}
if (rep_quick &&
maria_chk_del(param, info, param->testflag & ~T_VERBOSE))
{
if (param->testflag & T_FORCE_CREATE)
{
rep_quick=0;
_ma_check_print_info(param,"Creating new data file\n");
}
else
{
error=1;
_ma_check_print_error(param,
"Quick-recover aborted; Run recovery without switch 'q'");
}
}
if (!error)
{ {
if ((param->testflag & (T_REP_BY_SORT | T_REP_PARALLEL)) && rep_quick=0;
(maria_is_any_key_active(share->state.key_map) || _ma_check_print_info(param,"Creating new data file\n");
(rep_quick && !param->keys_in_use && !recreate)) &&
maria_test_if_sort_rep(info, info->state->records,
info->s->state.key_map,
param->force_sort))
{
if (param->testflag & T_REP_BY_SORT)
error=maria_repair_by_sort(param,info,filename,rep_quick);
else
error=maria_repair_parallel(param,info,filename,rep_quick);
state_updated=1;
}
else if (param->testflag & T_REP_ANY)
error=maria_repair(param, info,filename,rep_quick);
} }
if (!error && param->testflag & T_SORT_RECORDS) else
{ {
/* error=1;
The data file is nowadays reopened in the repair code so we should _ma_check_print_error(param,
soon remove the following reopen-code "Quick-recover aborted; Run recovery without switch 'q'");
*/
#ifndef TO_BE_REMOVED
if (param->out_flag & O_NEW_DATA)
{ /* Change temp file to org file */
VOID(my_close(info->dfile.file, MYF(MY_WME))); /* Close new file */
error|=maria_change_to_newfile(filename,MARIA_NAME_DEXT,DATA_TMP_EXT,
MYF(0));
if (_ma_open_datafile(info,info->s, -1))
error=1;
param->out_flag&= ~O_NEW_DATA; /* We are using new datafile */
param->read_cache.file= info->dfile.file;
}
#endif
if (! error)
{
uint key;
/*
We can't update the index in maria_sort_records if we have a
prefix compressed or fulltext index
*/
my_bool update_index=1;
for (key=0 ; key < share->base.keys; key++)
if (share->keyinfo[key].flag & (HA_BINARY_PACK_KEY|HA_FULLTEXT))
update_index=0;
error=maria_sort_records(param,info,filename,param->opt_sort_key,
/* what is the following parameter for ? */
(my_bool) !(param->testflag & T_REP),
update_index);
datafile= info->dfile.file; /* This is now locked */
if (!error && !update_index)
{
if (param->verbose)
puts("Table had a compressed index; We must now recreate the index");
error=maria_repair_by_sort(param,info,filename,1);
}
}
} }
if (!error && param->testflag & T_SORT_INDEX)
error=maria_sort_index(param,info,filename);
if (!error)
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR);
else
maria_mark_crashed(info);
} }
else if ((param->testflag & T_CHECK) || !(param->testflag & T_AUTO_INC)) if (!error)
{ {
if (!(param->testflag & T_SILENT) || param->testflag & T_INFO) if ((param->testflag & (T_REP_BY_SORT | T_REP_PARALLEL)) &&
printf("Checking MARIA file: %s\n",filename); (maria_is_any_key_active(share->state.key_map) ||
if (!(param->testflag & T_SILENT)) (rep_quick && !param->keys_in_use && !recreate)) &&
printf("Data records: %7s Deleted blocks: %7s\n", maria_test_if_sort_rep(info, info->state->records,
llstr(info->state->records,llbuff), info->s->state.key_map,
llstr(info->state->del,llbuff2)); param->force_sort))
error =maria_chk_status(param,info);
maria_intersect_keys_active(share->state.key_map, param->keys_in_use);
error =maria_chk_size(param,info);
if (!error || !(param->testflag & (T_FAST | T_FORCE_CREATE)))
error|=maria_chk_del(param, info,param->testflag);
if ((!error || (!(param->testflag & (T_FAST | T_FORCE_CREATE)) &&
!param->start_check_pos)))
{ {
error|=maria_chk_key(param, info); if (param->testflag & T_REP_BY_SORT)
if (!error && (param->testflag & (T_STATISTICS | T_AUTO_INC))) error=maria_repair_by_sort(param,info,filename,rep_quick);
error=maria_update_state_info(param, info, else
((param->testflag & T_STATISTICS) ? error=maria_repair_parallel(param,info,filename,rep_quick);
UPDATE_STAT : 0) | state_updated=1;
((param->testflag & T_AUTO_INC) ?
UPDATE_AUTO_INC : 0));
} }
if ((!rep_quick && !error) || else if (param->testflag & T_REP_ANY)
!(param->testflag & (T_FAST | T_FORCE_CREATE))) error=maria_repair(param, info,filename,rep_quick);
{ }
if (param->testflag & (T_EXTEND | T_MEDIUM)) if (!error && param->testflag & T_SORT_RECORDS)
VOID(init_pagecache(maria_pagecache, param->use_buffers, 0, 0, {
opt_pagecache_block_size)); /*
VOID(init_io_cache(&param->read_cache,datafile, The data file is nowadays reopened in the repair code so we should
(uint) param->read_buffer_length, soon remove the following reopen-code
READ_CACHE, */
(param->start_check_pos ? #ifndef TO_BE_REMOVED
param->start_check_pos : if (param->out_flag & O_NEW_DATA)
share->pack.header_length), { /* Change temp file to org file */
1, VOID(my_close(info->dfile.file, MYF(MY_WME))); /* Close new file */
MYF(MY_WME))); error|=maria_change_to_newfile(filename,MARIA_NAME_DEXT,DATA_TMP_EXT,
maria_lock_memory(param); MYF(0));
if ((info->s->data_file_type != STATIC_RECORD) || if (_ma_open_datafile(info,info->s, -1))
(param->testflag & (T_EXTEND | T_MEDIUM))) error=1;
error|=maria_chk_data_link(param, info, param->testflag & T_EXTEND); param->out_flag&= ~O_NEW_DATA; /* We are using new datafile */
error|=_ma_flush_blocks(param, share->pagecache, &share->kfile); param->read_cache.file= info->dfile.file;
VOID(end_io_cache(&param->read_cache));
} }
if (!error) #endif
if (! error)
{ {
if ((share->state.changed & STATE_CHANGED) && uint key;
(param->testflag & T_UPDATE_STATE)) /*
info->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; We can't update the index in maria_sort_records if we have a
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED | prefix compressed or fulltext index
STATE_CRASHED_ON_REPAIR); */
} my_bool update_index=1;
else if (!maria_is_crashed(info) && for (key=0 ; key < share->base.keys; key++)
(param->testflag & T_UPDATE_STATE)) if (share->keyinfo[key].flag & (HA_BINARY_PACK_KEY|HA_FULLTEXT))
{ /* Mark crashed */ update_index=0;
maria_mark_crashed(info);
info->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; error=maria_sort_records(param,info,filename,param->opt_sort_key,
/* what is the following parameter for ? */
(my_bool) !(param->testflag & T_REP),
update_index);
datafile= info->dfile.file; /* This is now locked */
if (!error && !update_index)
{
if (param->verbose)
puts("Table had a compressed index; We must now recreate the index");
error=maria_repair_by_sort(param,info,filename,1);
}
} }
} }
if (!error && param->testflag & T_SORT_INDEX)
error=maria_sort_index(param,info,filename);
if (!error)
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR);
else
maria_mark_crashed(info);
}
else if ((param->testflag & T_CHECK) || !(param->testflag & T_AUTO_INC))
{
if (!(param->testflag & T_SILENT) || param->testflag & T_INFO)
printf("Checking MARIA file: %s\n",filename);
if (!(param->testflag & T_SILENT))
printf("Data records: %7s Deleted blocks: %7s\n",
llstr(info->state->records,llbuff),
llstr(info->state->del,llbuff2));
error =maria_chk_status(param,info);
maria_intersect_keys_active(share->state.key_map, param->keys_in_use);
error =maria_chk_size(param,info);
if (!error || !(param->testflag & (T_FAST | T_FORCE_CREATE)))
error|=maria_chk_del(param, info,param->testflag);
if ((!error || (!(param->testflag & (T_FAST | T_FORCE_CREATE)) &&
!param->start_check_pos)))
{
error|=maria_chk_key(param, info);
if (!error && (param->testflag & (T_STATISTICS | T_AUTO_INC)))
error=maria_update_state_info(param, info,
((param->testflag & T_STATISTICS) ?
UPDATE_STAT : 0) |
((param->testflag & T_AUTO_INC) ?
UPDATE_AUTO_INC : 0));
}
if ((!rep_quick && !error) ||
!(param->testflag & (T_FAST | T_FORCE_CREATE)))
{
VOID(init_io_cache(&param->read_cache,datafile,
(uint) param->read_buffer_length,
READ_CACHE,
(param->start_check_pos ?
param->start_check_pos :
share->pack.header_length),
1,
MYF(MY_WME)));
maria_lock_memory(param);
if ((info->s->data_file_type != STATIC_RECORD) ||
(param->testflag & (T_EXTEND | T_MEDIUM)))
error|=maria_chk_data_link(param, info, param->testflag & T_EXTEND);
error|=_ma_flush_blocks(param, share->pagecache, &share->kfile);
VOID(end_io_cache(&param->read_cache));
}
if (!error)
{
if ((share->state.changed & STATE_CHANGED) &&
(param->testflag & T_UPDATE_STATE))
info->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR);
}
else if (!maria_is_crashed(info) &&
(param->testflag & T_UPDATE_STATE))
{ /* Mark crashed */
maria_mark_crashed(info);
info->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
}
} }
if ((param->testflag & T_AUTO_INC) || if ((param->testflag & T_AUTO_INC) ||
((param->testflag & T_REP_ANY) && info->s->base.auto_key)) ((param->testflag & T_REP_ANY) && info->s->base.auto_key))
_ma_update_auto_increment_key(param, info, _ma_update_auto_increment_key(param, info,
(my_bool) !test(param->testflag & T_AUTO_INC)); (my_bool) !test(param->testflag & T_AUTO_INC));
if (!(param->testflag & T_DESCRIPT)) if (info->update & HA_STATE_CHANGED && ! (param->testflag & T_READONLY))
{ error|=maria_update_state_info(param, info,
if (info->update & HA_STATE_CHANGED && ! (param->testflag & T_READONLY)) UPDATE_OPEN_COUNT |
error|=maria_update_state_info(param, info, (((param->testflag & T_REP_ANY) ?
UPDATE_OPEN_COUNT | UPDATE_TIME : 0) |
(((param->testflag & T_REP_ANY) ? (state_updated ? UPDATE_STAT : 0) |
UPDATE_TIME : 0) | ((param->testflag & T_SORT_RECORDS) ?
(state_updated ? UPDATE_STAT : 0) | UPDATE_SORT : 0)));
((param->testflag & T_SORT_RECORDS) ? info->update&= ~HA_STATE_CHANGED;
UPDATE_SORT : 0)));
info->update&= ~HA_STATE_CHANGED;
}
maria_lock_database(info, F_UNLCK); maria_lock_database(info, F_UNLCK);
end2: end2:
end_pagecache(maria_pagecache, 1);
if (maria_close(info)) if (maria_close(info))
{ {
_ma_check_print_error(param,"%d when closing MARIA-table '%s'",my_errno,filename); _ma_check_print_error(param,"%d when closing MARIA-table '%s'",
my_errno,filename);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (error == 0) if (error == 0)
...@@ -1533,8 +1526,6 @@ static int maria_sort_records(HA_CHECK *param, ...@@ -1533,8 +1526,6 @@ static int maria_sort_records(HA_CHECK *param,
if (share->state.key_root[sort_key] == HA_OFFSET_ERROR) if (share->state.key_root[sort_key] == HA_OFFSET_ERROR)
DBUG_RETURN(0); /* Nothing to do */ DBUG_RETURN(0); /* Nothing to do */
init_pagecache(maria_pagecache, param->use_buffers,
0, 0, opt_pagecache_block_size);
if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length,
WRITE_CACHE,share->pack.header_length,1, WRITE_CACHE,share->pack.header_length,1,
MYF(MY_WME | MY_WAIT_IF_FULL))) MYF(MY_WME | MY_WAIT_IF_FULL)))
......
...@@ -190,9 +190,9 @@ typedef struct st_maria_file_bitmap ...@@ -190,9 +190,9 @@ typedef struct st_maria_file_bitmap
{ {
uchar *map; uchar *map;
ulonglong page; /* Page number for current bitmap */ ulonglong page; /* Page number for current bitmap */
PAGECACHE_FILE page_cache;
uint used_size; /* Size of bitmap head that is not 0 */ uint used_size; /* Size of bitmap head that is not 0 */
my_bool changed; /* Set to 1 if page needs to be flushed */ my_bool changed; /* 1 if page needs to be flushed */
PAGECACHE_FILE file; /* datafile where bitmap is stored */
#ifdef THREAD #ifdef THREAD
pthread_mutex_t bitmap_lock; pthread_mutex_t bitmap_lock;
......
...@@ -505,13 +505,21 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table) ...@@ -505,13 +505,21 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
trees=fields=0; trees=fields=0;
huff_trees=0; huff_trees=0;
huff_counts=0; huff_counts=0;
maria_block_size= isam_file->s->block_size;
/* Create temporary or join file */ /* Create temporary or join file */
if (backup) if (backup)
VOID(fn_format(org_name,isam_file->filename,"",MARIA_NAME_DEXT,2)); VOID(fn_format(org_name,isam_file->filename,"",MARIA_NAME_DEXT,2));
else else
VOID(fn_format(org_name,isam_file->filename,"",MARIA_NAME_DEXT,2+4+16)); VOID(fn_format(org_name,isam_file->filename,"",MARIA_NAME_DEXT,2+4+16));
if (init_pagecache(maria_pagecache, MARIA_MIN_PAGE_CACHE_SIZE, 0, 0,
maria_block_size) == 0)
{
fprintf(stderr, "Can't initialize page cache\n");
goto err;
}
if (!test_only && result_table) if (!test_only && result_table)
{ {
/* Make a new indexfile based on first file in list */ /* Make a new indexfile based on first file in list */
...@@ -681,7 +689,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table) ...@@ -681,7 +689,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
{ {
error|=my_close(isam_file->dfile.file, MYF(MY_WME)); error|=my_close(isam_file->dfile.file, MYF(MY_WME));
isam_file->dfile.file= -1; /* Tell maria_close file is closed */ isam_file->dfile.file= -1; /* Tell maria_close file is closed */
isam_file->s->bitmap.file= -1; isam_file->s->bitmap.file.file= -1;
} }
} }
...@@ -751,6 +759,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table) ...@@ -751,6 +759,7 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
end_pagecache(maria_pagecache, 1);
free_counts_and_tree_and_queue(huff_trees,trees,huff_counts,fields); free_counts_and_tree_and_queue(huff_trees,trees,huff_counts,fields);
if (new_file >= 0) if (new_file >= 0)
VOID(my_close(new_file,MYF(0))); VOID(my_close(new_file,MYF(0)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment