This patch is a collection of patches from from Sanja, Sergei and Monty.
Added logging and pinning of pages to block format.
Integration of transaction manager, log handler.
Better page cache intergration
Split trnman.h into two files, so that we don't have to include my_atomic.h into C++ programs.
Renaming of structures, more comments, more debugging etc.
Fixed problem with small head block + long varchar.
Added extra argument to delete_record() and update_record() (needed for UNDO logging)
Small changes to interface of pagecache and log handler.
Change initialization of log_record_type_descriptors to not be depending on enum order.
Use array of LEX_STRING's to send data to log handler
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
include/lf.h:
Interface fixes
Rename of structures
(Patch from Sergei via Sanja)
include/my_atomic.h:
More comments
include/my_global.h:
Added MY_ERRPTR
include/pagecache.h:
Added undo LSN when unlocking pages
mysql-test/r/maria.result:
Updated results
mysql-test/t/maria.test:
Added autocommit around lock tables
(Patch from Sanja)
mysys/lf_alloc-pin.c:
Post-review fixes, simple optimizations
More comments
Struct slot renames
Check amount of memory on stack
(Patch from Sergei)
mysys/lf_dynarray.c:
More comments
mysys/lf_hash.c:
More comments
After review fixes
(Patch from Sergei)
storage/maria/ha_maria.cc:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
Move out all deferencing of the transaction structure.
Transaction manager integrated (Patch from Sergei)
storage/maria/ha_maria.h:
Added prototype for start_stmt()
storage/maria/lockman.c:
Function call rename
storage/maria/ma_bitmap.c:
Mark deleted pages free from page cache
storage/maria/ma_blockrec.c:
Offset -> rownr
More debugging
Fixed problem with small head block + long varchar
Added logging of changed pages
Added logging of undo (Including only loggging of changed fields in case of update)
Added pinning/unpinning of all changed pages
More comments
Added free_full_pages() as the same code was used in several places.
fill_rows_parts() renamed as fill_insert_undo_parts()
offset -> rownr
Added some optimization of not transactional tables
_ma_update_block_record() has new parameter, as we need original row to do efficent undo for update
storage/maria/ma_blockrec.h:
Added ROW_EXTENTS_ON_STACK
Changed prototype for update and delete of row
storage/maria/ma_check.c:
Added original row to delete_record() call
storage/maria/ma_control_file.h:
Added ifdefs for C++
storage/maria/ma_delete.c:
Added original row to delete_record() call
(Needed for efficent undo logging)
storage/maria/ma_dynrec.c:
Added extra argument to delete_record() and update_record()
Removed not used variable
storage/maria/ma_init.c:
Initialize log handler
storage/maria/ma_loghandler.c:
Removed not used variable
Change initialization of log_record_type_descriptors to not be depending on enum order
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_loghandler.h:
New defines
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_open.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
storage/maria/ma_pagecache.c:
Don't decrease number of readers when using pagecache_write()/pagecache_read()
In pagecache_write() decrement request count if page was left pinned
Added pagecache_delete_pages()
Removed some casts
Make trace output consistent with rest of code
Simplify calling of DBUG_ASSERT(0)
Only update LSN if the LSN is bigger than what's already on the page
Added LSN parameter pagecache_unpin_page(), pagecache_unpin(), and pagecache_unlock()
(Part of patch from Sanja)
storage/maria/ma_static.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Added default page cache
storage/maria/ma_statrec.c:
Added extra argument to delete_record() and update_record()
storage/maria/ma_test1.c:
Added option -T for transactions
storage/maria/ma_test2.c:
Added option -T for transactions
storage/maria/ma_test_all.sh:
Test with transactions
storage/maria/ma_update.c:
Changed prototype for update of row
storage/maria/maria_def.h:
Changed prototype for update & delete of row as block records need to access the old row
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
Added MARIA_MAX_TREE_LEVELS to allow us to calculate the number of possible pinned pages we may need.
Removed not used 'empty_bits_buffer'
Added pointer to transaction object
Added array for pinned pages
Added log_row_parts array for logging of field data.
Added MARIA_PINNED_PAGE to store pinned pages
storage/maria/trnman.c:
Added accessor functions to transaction object
Added missing DBUG_RETURN()
More debugging
More comments
Changed // comment of code to #ifdef NOT_USED
Transaction manager integrated.
Post review fixes
Part of patch originally from Sergei
storage/maria/trnman.h:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
storage/maria/unittest/ma_pagecache_single.c:
Added missing argument
Added SKIP_BIG_TESTS
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/trnman-t.c:
Stack overflow detection
(Patch from Sergei)
unittest/unit.pl:
Command-line options --big and --verbose
(Patch from Sergei)
unittest/mytap/tap.c:
Detect --big
(Patch from Sergei)
unittest/mytap/tap.h:
Skip_big_tests and SKIP_BIG_TESTS
(Patch from Sergei)
storage/maria/trnman_public.h:
New BitKeeper file ``storage/maria/trnman_public.h''
2007-05-29 20:13:56 +03:00
|
|
|
/* Copyright (C) 2006 MySQL AB
|
2006-08-10 19:19:47 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
/*
|
|
|
|
Analog of DYNAMIC_ARRAY that never reallocs
|
|
|
|
(so no pointer into the array may ever become invalid).
|
|
|
|
|
|
|
|
Memory is allocated in non-contiguous chunks.
|
2006-11-16 15:40:08 +01:00
|
|
|
This data structure is not space efficient for sparse arrays.
|
2006-08-10 19:19:47 +02:00
|
|
|
|
|
|
|
Every element is aligned to sizeof(element) boundary
|
|
|
|
(to avoid false sharing if element is big enough).
|
|
|
|
|
2006-10-27 17:09:31 +02:00
|
|
|
LF_DYNARRAY is a recursive structure. On the zero level
|
|
|
|
LF_DYNARRAY::level[0] it's an array of LF_DYNARRAY_LEVEL_LENGTH elements,
|
|
|
|
on the first level it's an array of LF_DYNARRAY_LEVEL_LENGTH pointers
|
|
|
|
to arrays of elements, on the second level it's an array of pointers
|
|
|
|
to arrays of pointers to arrays of elements. And so on.
|
|
|
|
|
This patch is a collection of patches from from Sanja, Sergei and Monty.
Added logging and pinning of pages to block format.
Integration of transaction manager, log handler.
Better page cache intergration
Split trnman.h into two files, so that we don't have to include my_atomic.h into C++ programs.
Renaming of structures, more comments, more debugging etc.
Fixed problem with small head block + long varchar.
Added extra argument to delete_record() and update_record() (needed for UNDO logging)
Small changes to interface of pagecache and log handler.
Change initialization of log_record_type_descriptors to not be depending on enum order.
Use array of LEX_STRING's to send data to log handler
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
include/lf.h:
Interface fixes
Rename of structures
(Patch from Sergei via Sanja)
include/my_atomic.h:
More comments
include/my_global.h:
Added MY_ERRPTR
include/pagecache.h:
Added undo LSN when unlocking pages
mysql-test/r/maria.result:
Updated results
mysql-test/t/maria.test:
Added autocommit around lock tables
(Patch from Sanja)
mysys/lf_alloc-pin.c:
Post-review fixes, simple optimizations
More comments
Struct slot renames
Check amount of memory on stack
(Patch from Sergei)
mysys/lf_dynarray.c:
More comments
mysys/lf_hash.c:
More comments
After review fixes
(Patch from Sergei)
storage/maria/ha_maria.cc:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
Move out all deferencing of the transaction structure.
Transaction manager integrated (Patch from Sergei)
storage/maria/ha_maria.h:
Added prototype for start_stmt()
storage/maria/lockman.c:
Function call rename
storage/maria/ma_bitmap.c:
Mark deleted pages free from page cache
storage/maria/ma_blockrec.c:
Offset -> rownr
More debugging
Fixed problem with small head block + long varchar
Added logging of changed pages
Added logging of undo (Including only loggging of changed fields in case of update)
Added pinning/unpinning of all changed pages
More comments
Added free_full_pages() as the same code was used in several places.
fill_rows_parts() renamed as fill_insert_undo_parts()
offset -> rownr
Added some optimization of not transactional tables
_ma_update_block_record() has new parameter, as we need original row to do efficent undo for update
storage/maria/ma_blockrec.h:
Added ROW_EXTENTS_ON_STACK
Changed prototype for update and delete of row
storage/maria/ma_check.c:
Added original row to delete_record() call
storage/maria/ma_control_file.h:
Added ifdefs for C++
storage/maria/ma_delete.c:
Added original row to delete_record() call
(Needed for efficent undo logging)
storage/maria/ma_dynrec.c:
Added extra argument to delete_record() and update_record()
Removed not used variable
storage/maria/ma_init.c:
Initialize log handler
storage/maria/ma_loghandler.c:
Removed not used variable
Change initialization of log_record_type_descriptors to not be depending on enum order
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_loghandler.h:
New defines
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_open.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
storage/maria/ma_pagecache.c:
Don't decrease number of readers when using pagecache_write()/pagecache_read()
In pagecache_write() decrement request count if page was left pinned
Added pagecache_delete_pages()
Removed some casts
Make trace output consistent with rest of code
Simplify calling of DBUG_ASSERT(0)
Only update LSN if the LSN is bigger than what's already on the page
Added LSN parameter pagecache_unpin_page(), pagecache_unpin(), and pagecache_unlock()
(Part of patch from Sanja)
storage/maria/ma_static.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Added default page cache
storage/maria/ma_statrec.c:
Added extra argument to delete_record() and update_record()
storage/maria/ma_test1.c:
Added option -T for transactions
storage/maria/ma_test2.c:
Added option -T for transactions
storage/maria/ma_test_all.sh:
Test with transactions
storage/maria/ma_update.c:
Changed prototype for update of row
storage/maria/maria_def.h:
Changed prototype for update & delete of row as block records need to access the old row
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
Added MARIA_MAX_TREE_LEVELS to allow us to calculate the number of possible pinned pages we may need.
Removed not used 'empty_bits_buffer'
Added pointer to transaction object
Added array for pinned pages
Added log_row_parts array for logging of field data.
Added MARIA_PINNED_PAGE to store pinned pages
storage/maria/trnman.c:
Added accessor functions to transaction object
Added missing DBUG_RETURN()
More debugging
More comments
Changed // comment of code to #ifdef NOT_USED
Transaction manager integrated.
Post review fixes
Part of patch originally from Sergei
storage/maria/trnman.h:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
storage/maria/unittest/ma_pagecache_single.c:
Added missing argument
Added SKIP_BIG_TESTS
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/trnman-t.c:
Stack overflow detection
(Patch from Sergei)
unittest/unit.pl:
Command-line options --big and --verbose
(Patch from Sergei)
unittest/mytap/tap.c:
Detect --big
(Patch from Sergei)
unittest/mytap/tap.h:
Skip_big_tests and SKIP_BIG_TESTS
(Patch from Sergei)
storage/maria/trnman_public.h:
New BitKeeper file ``storage/maria/trnman_public.h''
2007-05-29 20:13:56 +03:00
|
|
|
With four levels the number of elements is limited to 4311810304
|
|
|
|
(but as in all functions index is uint, the real limit is 2^32-1)
|
|
|
|
|
2006-08-10 19:19:47 +02:00
|
|
|
Actually, it's wait-free, not lock-free ;-)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <my_global.h>
|
2008-01-10 13:21:53 +01:00
|
|
|
#include <m_string.h>
|
2006-08-10 19:19:47 +02:00
|
|
|
#include <my_sys.h>
|
|
|
|
#include <lf.h>
|
|
|
|
|
|
|
|
void lf_dynarray_init(LF_DYNARRAY *array, uint element_size)
|
|
|
|
{
|
|
|
|
bzero(array, sizeof(*array));
|
2006-10-13 11:37:27 +02:00
|
|
|
array->size_of_element= element_size;
|
2006-08-10 19:19:47 +02:00
|
|
|
my_atomic_rwlock_init(&array->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void recursive_free(void **alloc, int level)
|
|
|
|
{
|
2006-11-16 15:40:08 +01:00
|
|
|
if (!alloc)
|
|
|
|
return;
|
2006-08-10 19:19:47 +02:00
|
|
|
|
|
|
|
if (level)
|
|
|
|
{
|
|
|
|
int i;
|
2006-10-13 11:37:27 +02:00
|
|
|
for (i= 0; i < LF_DYNARRAY_LEVEL_LENGTH; i++)
|
2006-08-10 19:19:47 +02:00
|
|
|
recursive_free(alloc[i], level-1);
|
|
|
|
my_free((void *)alloc, MYF(0));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
my_free(alloc[-1], MYF(0));
|
|
|
|
}
|
|
|
|
|
2006-08-17 15:20:58 +02:00
|
|
|
void lf_dynarray_destroy(LF_DYNARRAY *array)
|
2006-08-10 19:19:47 +02:00
|
|
|
{
|
|
|
|
int i;
|
2006-10-13 11:37:27 +02:00
|
|
|
for (i= 0; i < LF_DYNARRAY_LEVELS; i++)
|
2006-08-10 19:19:47 +02:00
|
|
|
recursive_free(array->level[i], i);
|
|
|
|
my_atomic_rwlock_destroy(&array->lock);
|
|
|
|
}
|
|
|
|
|
2006-11-16 15:40:08 +01:00
|
|
|
static const ulong dynarray_idxes_in_prev_levels[LF_DYNARRAY_LEVELS]=
|
2006-08-10 19:19:47 +02:00
|
|
|
{
|
|
|
|
0, /* +1 here to to avoid -1's below */
|
|
|
|
LF_DYNARRAY_LEVEL_LENGTH,
|
2006-10-30 16:58:18 +01:00
|
|
|
LF_DYNARRAY_LEVEL_LENGTH * LF_DYNARRAY_LEVEL_LENGTH +
|
|
|
|
LF_DYNARRAY_LEVEL_LENGTH,
|
2006-08-10 19:19:47 +02:00
|
|
|
LF_DYNARRAY_LEVEL_LENGTH * LF_DYNARRAY_LEVEL_LENGTH *
|
2006-10-30 16:58:18 +01:00
|
|
|
LF_DYNARRAY_LEVEL_LENGTH + LF_DYNARRAY_LEVEL_LENGTH *
|
|
|
|
LF_DYNARRAY_LEVEL_LENGTH + LF_DYNARRAY_LEVEL_LENGTH
|
2006-08-10 19:19:47 +02:00
|
|
|
};
|
|
|
|
|
2006-11-16 15:40:08 +01:00
|
|
|
static const ulong dynarray_idxes_in_prev_level[LF_DYNARRAY_LEVELS]=
|
|
|
|
{
|
|
|
|
0, /* +1 here to to avoid -1's below */
|
|
|
|
LF_DYNARRAY_LEVEL_LENGTH,
|
|
|
|
LF_DYNARRAY_LEVEL_LENGTH * LF_DYNARRAY_LEVEL_LENGTH,
|
|
|
|
LF_DYNARRAY_LEVEL_LENGTH * LF_DYNARRAY_LEVEL_LENGTH *
|
|
|
|
LF_DYNARRAY_LEVEL_LENGTH,
|
|
|
|
};
|
|
|
|
|
2006-10-27 17:09:31 +02:00
|
|
|
/*
|
|
|
|
Returns a valid lvalue pointer to the element number 'idx'.
|
|
|
|
Allocates memory if necessary.
|
|
|
|
*/
|
2006-08-10 19:19:47 +02:00
|
|
|
void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
|
|
|
|
{
|
2006-10-13 11:37:27 +02:00
|
|
|
void * ptr, * volatile * ptr_ptr= 0;
|
2006-08-10 19:19:47 +02:00
|
|
|
int i;
|
|
|
|
|
2006-11-16 15:40:08 +01:00
|
|
|
for (i= LF_DYNARRAY_LEVELS-1; idx < dynarray_idxes_in_prev_levels[i]; i--)
|
|
|
|
/* no-op */;
|
2006-10-13 11:37:27 +02:00
|
|
|
ptr_ptr= &array->level[i];
|
2006-11-16 15:40:08 +01:00
|
|
|
idx-= dynarray_idxes_in_prev_levels[i];
|
2006-10-13 11:37:27 +02:00
|
|
|
for (; i > 0; i--)
|
2006-08-10 19:19:47 +02:00
|
|
|
{
|
2006-10-13 11:37:27 +02:00
|
|
|
if (!(ptr= *ptr_ptr))
|
2006-08-10 19:19:47 +02:00
|
|
|
{
|
2006-10-13 11:37:27 +02:00
|
|
|
void *alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * sizeof(void *),
|
2006-11-16 15:40:08 +01:00
|
|
|
MYF(MY_WME|MY_ZEROFILL));
|
|
|
|
if (unlikely(!alloc))
|
2006-10-13 11:37:27 +02:00
|
|
|
return(NULL);
|
|
|
|
if (my_atomic_casptr(ptr_ptr, &ptr, alloc))
|
|
|
|
ptr= alloc;
|
|
|
|
else
|
|
|
|
my_free(alloc, MYF(0));
|
2006-08-10 19:19:47 +02:00
|
|
|
}
|
2006-10-13 11:37:27 +02:00
|
|
|
ptr_ptr= ((void **)ptr) + idx / dynarray_idxes_in_prev_level[i];
|
|
|
|
idx%= dynarray_idxes_in_prev_level[i];
|
2006-08-10 19:19:47 +02:00
|
|
|
}
|
2006-10-13 11:37:27 +02:00
|
|
|
if (!(ptr= *ptr_ptr))
|
2006-08-10 19:19:47 +02:00
|
|
|
{
|
2008-01-10 13:21:53 +01:00
|
|
|
uchar *alloc, *data;
|
2006-10-13 11:37:27 +02:00
|
|
|
alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * array->size_of_element +
|
2006-08-10 19:19:47 +02:00
|
|
|
max(array->size_of_element, sizeof(void *)),
|
|
|
|
MYF(MY_WME|MY_ZEROFILL));
|
2006-11-16 15:40:08 +01:00
|
|
|
if (unlikely(!alloc))
|
2006-08-10 19:19:47 +02:00
|
|
|
return(NULL);
|
|
|
|
/* reserve the space for free() address */
|
|
|
|
data= alloc + sizeof(void *);
|
|
|
|
{ /* alignment */
|
|
|
|
intptr mod= ((intptr)data) % array->size_of_element;
|
|
|
|
if (mod)
|
|
|
|
data+= array->size_of_element - mod;
|
|
|
|
}
|
2006-10-13 11:37:27 +02:00
|
|
|
((void **)data)[-1]= alloc; /* free() will need the original pointer */
|
2006-08-10 19:19:47 +02:00
|
|
|
if (my_atomic_casptr(ptr_ptr, &ptr, data))
|
|
|
|
ptr= data;
|
|
|
|
else
|
|
|
|
my_free(alloc, MYF(0));
|
|
|
|
}
|
2008-01-10 13:21:53 +01:00
|
|
|
return ((uchar*)ptr) + array->size_of_element * idx;
|
2006-08-10 19:19:47 +02:00
|
|
|
}
|
|
|
|
|
2006-10-27 17:09:31 +02:00
|
|
|
/*
|
|
|
|
Returns a pointer to the element number 'idx'
|
|
|
|
or NULL if an element does not exists
|
|
|
|
*/
|
2006-08-10 19:19:47 +02:00
|
|
|
void *_lf_dynarray_value(LF_DYNARRAY *array, uint idx)
|
|
|
|
{
|
2006-10-13 11:37:27 +02:00
|
|
|
void * ptr, * volatile * ptr_ptr= 0;
|
2006-08-10 19:19:47 +02:00
|
|
|
int i;
|
|
|
|
|
2006-11-16 15:40:08 +01:00
|
|
|
for (i= LF_DYNARRAY_LEVELS-1; idx < dynarray_idxes_in_prev_levels[i]; i--)
|
|
|
|
/* no-op */;
|
2006-10-13 11:37:27 +02:00
|
|
|
ptr_ptr= &array->level[i];
|
2006-11-16 15:40:08 +01:00
|
|
|
idx-= dynarray_idxes_in_prev_levels[i];
|
2006-10-13 11:37:27 +02:00
|
|
|
for (; i > 0; i--)
|
2006-08-10 19:19:47 +02:00
|
|
|
{
|
2006-10-13 11:37:27 +02:00
|
|
|
if (!(ptr= *ptr_ptr))
|
|
|
|
return(NULL);
|
|
|
|
ptr_ptr= ((void **)ptr) + idx / dynarray_idxes_in_prev_level[i];
|
|
|
|
idx %= dynarray_idxes_in_prev_level[i];
|
2006-08-10 19:19:47 +02:00
|
|
|
}
|
2006-10-13 11:37:27 +02:00
|
|
|
if (!(ptr= *ptr_ptr))
|
2006-08-10 19:19:47 +02:00
|
|
|
return(NULL);
|
2008-01-10 13:21:53 +01:00
|
|
|
return ((uchar*)ptr) + array->size_of_element * idx;
|
2006-08-10 19:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int recursive_iterate(LF_DYNARRAY *array, void *ptr, int level,
|
|
|
|
lf_dynarray_func func, void *arg)
|
|
|
|
{
|
|
|
|
int res, i;
|
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
|
|
|
if (!level)
|
|
|
|
return func(ptr, arg);
|
2006-10-13 11:37:27 +02:00
|
|
|
for (i= 0; i < LF_DYNARRAY_LEVEL_LENGTH; i++)
|
|
|
|
if ((res= recursive_iterate(array, ((void **)ptr)[i], level-1, func, arg)))
|
2006-08-10 19:19:47 +02:00
|
|
|
return res;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-27 17:09:31 +02:00
|
|
|
/*
|
|
|
|
Calls func(array, arg) on every array of LF_DYNARRAY_LEVEL_LENGTH elements
|
|
|
|
in lf_dynarray.
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
lf_dynarray consists of a set of arrays, LF_DYNARRAY_LEVEL_LENGTH elements
|
|
|
|
each. _lf_dynarray_iterate() calls user-supplied function on every array
|
|
|
|
from the set. It is the fastest way to scan the array, faster than
|
|
|
|
for (i=0; i < N; i++) { func(_lf_dynarray_value(dynarray, i)); }
|
This patch is a collection of patches from from Sanja, Sergei and Monty.
Added logging and pinning of pages to block format.
Integration of transaction manager, log handler.
Better page cache intergration
Split trnman.h into two files, so that we don't have to include my_atomic.h into C++ programs.
Renaming of structures, more comments, more debugging etc.
Fixed problem with small head block + long varchar.
Added extra argument to delete_record() and update_record() (needed for UNDO logging)
Small changes to interface of pagecache and log handler.
Change initialization of log_record_type_descriptors to not be depending on enum order.
Use array of LEX_STRING's to send data to log handler
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
include/lf.h:
Interface fixes
Rename of structures
(Patch from Sergei via Sanja)
include/my_atomic.h:
More comments
include/my_global.h:
Added MY_ERRPTR
include/pagecache.h:
Added undo LSN when unlocking pages
mysql-test/r/maria.result:
Updated results
mysql-test/t/maria.test:
Added autocommit around lock tables
(Patch from Sanja)
mysys/lf_alloc-pin.c:
Post-review fixes, simple optimizations
More comments
Struct slot renames
Check amount of memory on stack
(Patch from Sergei)
mysys/lf_dynarray.c:
More comments
mysys/lf_hash.c:
More comments
After review fixes
(Patch from Sergei)
storage/maria/ha_maria.cc:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
Move out all deferencing of the transaction structure.
Transaction manager integrated (Patch from Sergei)
storage/maria/ha_maria.h:
Added prototype for start_stmt()
storage/maria/lockman.c:
Function call rename
storage/maria/ma_bitmap.c:
Mark deleted pages free from page cache
storage/maria/ma_blockrec.c:
Offset -> rownr
More debugging
Fixed problem with small head block + long varchar
Added logging of changed pages
Added logging of undo (Including only loggging of changed fields in case of update)
Added pinning/unpinning of all changed pages
More comments
Added free_full_pages() as the same code was used in several places.
fill_rows_parts() renamed as fill_insert_undo_parts()
offset -> rownr
Added some optimization of not transactional tables
_ma_update_block_record() has new parameter, as we need original row to do efficent undo for update
storage/maria/ma_blockrec.h:
Added ROW_EXTENTS_ON_STACK
Changed prototype for update and delete of row
storage/maria/ma_check.c:
Added original row to delete_record() call
storage/maria/ma_control_file.h:
Added ifdefs for C++
storage/maria/ma_delete.c:
Added original row to delete_record() call
(Needed for efficent undo logging)
storage/maria/ma_dynrec.c:
Added extra argument to delete_record() and update_record()
Removed not used variable
storage/maria/ma_init.c:
Initialize log handler
storage/maria/ma_loghandler.c:
Removed not used variable
Change initialization of log_record_type_descriptors to not be depending on enum order
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_loghandler.h:
New defines
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_open.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
storage/maria/ma_pagecache.c:
Don't decrease number of readers when using pagecache_write()/pagecache_read()
In pagecache_write() decrement request count if page was left pinned
Added pagecache_delete_pages()
Removed some casts
Make trace output consistent with rest of code
Simplify calling of DBUG_ASSERT(0)
Only update LSN if the LSN is bigger than what's already on the page
Added LSN parameter pagecache_unpin_page(), pagecache_unpin(), and pagecache_unlock()
(Part of patch from Sanja)
storage/maria/ma_static.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Added default page cache
storage/maria/ma_statrec.c:
Added extra argument to delete_record() and update_record()
storage/maria/ma_test1.c:
Added option -T for transactions
storage/maria/ma_test2.c:
Added option -T for transactions
storage/maria/ma_test_all.sh:
Test with transactions
storage/maria/ma_update.c:
Changed prototype for update of row
storage/maria/maria_def.h:
Changed prototype for update & delete of row as block records need to access the old row
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
Added MARIA_MAX_TREE_LEVELS to allow us to calculate the number of possible pinned pages we may need.
Removed not used 'empty_bits_buffer'
Added pointer to transaction object
Added array for pinned pages
Added log_row_parts array for logging of field data.
Added MARIA_PINNED_PAGE to store pinned pages
storage/maria/trnman.c:
Added accessor functions to transaction object
Added missing DBUG_RETURN()
More debugging
More comments
Changed // comment of code to #ifdef NOT_USED
Transaction manager integrated.
Post review fixes
Part of patch originally from Sergei
storage/maria/trnman.h:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
storage/maria/unittest/ma_pagecache_single.c:
Added missing argument
Added SKIP_BIG_TESTS
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/trnman-t.c:
Stack overflow detection
(Patch from Sergei)
unittest/unit.pl:
Command-line options --big and --verbose
(Patch from Sergei)
unittest/mytap/tap.c:
Detect --big
(Patch from Sergei)
unittest/mytap/tap.h:
Skip_big_tests and SKIP_BIG_TESTS
(Patch from Sergei)
storage/maria/trnman_public.h:
New BitKeeper file ``storage/maria/trnman_public.h''
2007-05-29 20:13:56 +03:00
|
|
|
|
|
|
|
NOTE
|
|
|
|
if func() returns non-zero, the scan is aborted
|
2006-10-27 17:09:31 +02:00
|
|
|
*/
|
2006-08-10 19:19:47 +02:00
|
|
|
int _lf_dynarray_iterate(LF_DYNARRAY *array, lf_dynarray_func func, void *arg)
|
|
|
|
{
|
|
|
|
int i, res;
|
2006-10-13 11:37:27 +02:00
|
|
|
for (i= 0; i < LF_DYNARRAY_LEVELS; i++)
|
|
|
|
if ((res= recursive_iterate(array, array->level[i], i, func, arg)))
|
2006-08-10 19:19:47 +02:00
|
|
|
return res;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|