2006-04-11 15:45:10 +02:00
|
|
|
/* Copyright (C) 2006 MySQL AB & Alexey Botchkov & MySQL Finland AB
|
|
|
|
& TCX DataKonsult AB
|
|
|
|
|
|
|
|
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
|
2007-03-02 11:20:23 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
#include "maria_def.h"
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
#include "trnman.h"
|
|
|
|
#include "ma_key_recover.h"
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_RTREE_KEYS
|
|
|
|
|
|
|
|
#include "ma_rt_index.h"
|
|
|
|
#include "ma_rt_key.h"
|
|
|
|
#include "ma_rt_mbr.h"
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
double square;
|
|
|
|
int n_node;
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
const uchar *key;
|
2006-04-11 15:45:10 +02:00
|
|
|
double *coords;
|
|
|
|
} SplitStruct;
|
|
|
|
|
|
|
|
inline static double *reserve_coords(double **d_buffer, int n_dim)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
double *coords= *d_buffer;
|
|
|
|
(*d_buffer)+= n_dim * 2;
|
2006-04-11 15:45:10 +02:00
|
|
|
return coords;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mbr_join(double *a, const double *b, int n_dim)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
double *end= a + n_dim * 2;
|
2006-04-11 15:45:10 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (a[0] > b[0])
|
2007-10-09 20:09:50 +02:00
|
|
|
a[0]= b[0];
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
if (a[1] < b[1])
|
2007-10-09 20:09:50 +02:00
|
|
|
a[1]= b[1];
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
a+= 2;
|
|
|
|
b+= 2;
|
|
|
|
} while (a != end);
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Counts the square of mbr which is a join of a and b
|
|
|
|
*/
|
|
|
|
static double mbr_join_square(const double *a, const double *b, int n_dim)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
const double *end= a + n_dim * 2;
|
|
|
|
double square= 1.0;
|
2006-04-11 15:45:10 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
square *=
|
|
|
|
((a[1] < b[1]) ? b[1] : a[1]) - ((a[0] > b[0]) ? b[0] : a[0]);
|
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
a+= 2;
|
|
|
|
b+= 2;
|
|
|
|
} while (a != end);
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
return square;
|
|
|
|
}
|
|
|
|
|
|
|
|
static double count_square(const double *a, int n_dim)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
const double *end= a + n_dim * 2;
|
|
|
|
double square= 1.0;
|
2006-04-11 15:45:10 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
square *= a[1] - a[0];
|
2007-10-09 20:09:50 +02:00
|
|
|
a+= 2;
|
|
|
|
} while (a != end);
|
2006-04-11 15:45:10 +02:00
|
|
|
return square;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static void copy_coords(double *dst, const double *src, int n_dim)
|
|
|
|
{
|
|
|
|
memcpy(dst, src, sizeof(double) * (n_dim * 2));
|
|
|
|
}
|
|
|
|
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
/**
|
|
|
|
Select two nodes to collect group upon.
|
|
|
|
|
|
|
|
Note that such function uses 'double' arithmetic so may behave differently
|
|
|
|
on different platforms/builds. There are others in this file.
|
2006-04-11 15:45:10 +02:00
|
|
|
*/
|
|
|
|
static void pick_seeds(SplitStruct *node, int n_entries,
|
|
|
|
SplitStruct **seed_a, SplitStruct **seed_b, int n_dim)
|
|
|
|
{
|
|
|
|
SplitStruct *cur1;
|
2007-10-09 20:09:50 +02:00
|
|
|
SplitStruct *lim1= node + (n_entries - 1);
|
2006-04-11 15:45:10 +02:00
|
|
|
SplitStruct *cur2;
|
2007-10-09 20:09:50 +02:00
|
|
|
SplitStruct *lim2= node + n_entries;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
double max_d= -DBL_MAX;
|
2006-04-11 15:45:10 +02:00
|
|
|
double d;
|
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
for (cur1= node; cur1 < lim1; cur1++)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
for (cur2=cur1 + 1; cur2 < lim2; cur2++)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
d= mbr_join_square(cur1->coords, cur2->coords, n_dim) - cur1->square -
|
2006-04-11 15:45:10 +02:00
|
|
|
cur2->square;
|
|
|
|
if (d > max_d)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
max_d= d;
|
|
|
|
*seed_a= cur1;
|
|
|
|
*seed_b= cur2;
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Select next node and group where to add
|
|
|
|
*/
|
|
|
|
static void pick_next(SplitStruct *node, int n_entries, double *g1, double *g2,
|
|
|
|
SplitStruct **choice, int *n_group, int n_dim)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
SplitStruct *cur= node;
|
|
|
|
SplitStruct *end= node + n_entries;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
double max_diff= -DBL_MAX;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
for (; cur < end; cur++)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
|
|
|
double diff;
|
|
|
|
double abs_diff;
|
|
|
|
|
|
|
|
if (cur->n_node)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
diff= mbr_join_square(g1, cur->coords, n_dim) -
|
2006-04-11 15:45:10 +02:00
|
|
|
mbr_join_square(g2, cur->coords, n_dim);
|
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
abs_diff= fabs(diff);
|
2006-04-11 15:45:10 +02:00
|
|
|
if (abs_diff > max_diff)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
max_diff= abs_diff;
|
|
|
|
*n_group= 1 + (diff > 0);
|
|
|
|
*choice= cur;
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Mark not-in-group entries as n_group
|
|
|
|
*/
|
|
|
|
static void mark_all_entries(SplitStruct *node, int n_entries, int n_group)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
SplitStruct *cur= node;
|
|
|
|
SplitStruct *end= node + n_entries;
|
|
|
|
|
|
|
|
for (; cur < end; cur++)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
|
|
|
if (cur->n_node)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2007-10-09 20:09:50 +02:00
|
|
|
cur->n_node= n_group;
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int split_maria_rtree_node(SplitStruct *node, int n_entries,
|
|
|
|
int all_size, /* Total key's size */
|
|
|
|
int key_size,
|
|
|
|
int min_size, /* Minimal group size */
|
|
|
|
int size1, int size2 /* initial group sizes */,
|
|
|
|
double **d_buffer, int n_dim)
|
|
|
|
{
|
|
|
|
SplitStruct *cur;
|
|
|
|
SplitStruct *a;
|
|
|
|
SplitStruct *b;
|
2007-10-09 20:09:50 +02:00
|
|
|
double *g1= reserve_coords(d_buffer, n_dim);
|
|
|
|
double *g2= reserve_coords(d_buffer, n_dim);
|
2006-04-11 15:45:10 +02:00
|
|
|
SplitStruct *next;
|
|
|
|
int next_node;
|
|
|
|
int i;
|
2007-10-09 20:09:50 +02:00
|
|
|
SplitStruct *end= node + n_entries;
|
2007-03-01 18:23:58 +01:00
|
|
|
LINT_INIT(a);
|
|
|
|
LINT_INIT(b);
|
|
|
|
LINT_INIT(next);
|
|
|
|
LINT_INIT(next_node);
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
if (all_size < min_size * 2)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
cur= node;
|
|
|
|
for (; cur < end; cur++)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
cur->square= count_square(cur->coords, n_dim);
|
|
|
|
cur->n_node= 0;
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pick_seeds(node, n_entries, &a, &b, n_dim);
|
2007-10-09 20:09:50 +02:00
|
|
|
a->n_node= 1;
|
|
|
|
b->n_node= 2;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
copy_coords(g1, a->coords, n_dim);
|
2007-10-09 20:09:50 +02:00
|
|
|
size1+= key_size;
|
2006-04-11 15:45:10 +02:00
|
|
|
copy_coords(g2, b->coords, n_dim);
|
2007-10-09 20:09:50 +02:00
|
|
|
size2+= key_size;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
for (i=n_entries - 2; i>0; --i)
|
|
|
|
{
|
|
|
|
if (all_size - (size2 + key_size) < min_size) /* Can't write into group 2 */
|
|
|
|
{
|
|
|
|
mark_all_entries(node, n_entries, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (all_size - (size1 + key_size) < min_size) /* Can't write into group 1 */
|
|
|
|
{
|
|
|
|
mark_all_entries(node, n_entries, 2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pick_next(node, n_entries, g1, g2, &next, &next_node, n_dim);
|
|
|
|
if (next_node == 1)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
size1+= key_size;
|
2006-04-11 15:45:10 +02:00
|
|
|
mbr_join(g1, next->coords, n_dim);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
size2+= key_size;
|
2006-04-11 15:45:10 +02:00
|
|
|
mbr_join(g2, next->coords, n_dim);
|
|
|
|
}
|
2007-10-09 20:09:50 +02:00
|
|
|
next->n_node= next_node;
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Logs key reorganization done in a split page (new page is logged elsewhere).
|
|
|
|
|
|
|
|
The effect of a split on the split page is three changes:
|
|
|
|
- some piece of the page move to different places inside this page (we are
|
|
|
|
not interested here in the pieces which move to the new page)
|
|
|
|
- the key is inserted into the page or not (could be in the new page)
|
|
|
|
- page is shrunk
|
|
|
|
All this is uniquely determined by a few parameters:
|
|
|
|
- the key (starting at 'key-nod_flag', for 'full_length' bytes
|
|
|
|
(maria_rtree_split_page() seems to depend on its parameters key&key_length
|
|
|
|
but in fact it reads more (to the left: nod_flag, and to the right:
|
|
|
|
full_length)
|
|
|
|
- the binary content of the page
|
|
|
|
- some variables in the share
|
|
|
|
- double arithmetic, which is unpredictable from machine to machine and
|
|
|
|
from build to build (see pick_seeds() above: it has a comparison between
|
|
|
|
double-s 'if (d > max_d)' so the comparison can go differently from machine
|
|
|
|
to machine or build to build, it has happened in real life).
|
|
|
|
If one day we use precision-math instead of double-math, in GIS, then the
|
|
|
|
last parameter would become constant accross machines and builds and we
|
|
|
|
could some cheap logging: just log the few parameters above.
|
|
|
|
Until then, we log the list of memcpy() operations (fortunately, we often do
|
|
|
|
not have to log the source bytes, as they can be found in the page before
|
|
|
|
applying the REDO; the only source bytes to log are the key), the key if it
|
|
|
|
was inserted into this page, and the shrinking.
|
|
|
|
|
|
|
|
@param info table
|
|
|
|
@param page page's offset in the file
|
|
|
|
@param buff content of the page (post-split)
|
|
|
|
@param key_with_nod_flag pointer to key-nod_flag
|
|
|
|
@param full_length length of (key + (nod_flag (if node) or rowid (if
|
|
|
|
leaf)))
|
|
|
|
@param log_internal_copy encoded list of mempcy() operations done on
|
|
|
|
split page, having their source in the page
|
|
|
|
@param log_internal_copy_length length of above list, in bytes
|
|
|
|
@param log_key_copy operation describing the key's copy, or NULL if the
|
|
|
|
inserted key was not put into the page (was put in
|
|
|
|
new page, so does not have to be logged here)
|
|
|
|
@param length_diff by how much the page has shrunk during split
|
|
|
|
*/
|
|
|
|
|
|
|
|
static my_bool _ma_log_rt_split(MARIA_HA *info,
|
2008-04-24 23:24:21 +02:00
|
|
|
my_off_t page,
|
|
|
|
const uchar *buff __attribute__((unused)),
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
const uchar *key_with_nod_flag,
|
|
|
|
uint full_length,
|
|
|
|
const uchar *log_internal_copy,
|
|
|
|
uint log_internal_copy_length,
|
|
|
|
const uchar *log_key_copy,
|
|
|
|
uint length_diff)
|
|
|
|
{
|
|
|
|
MARIA_SHARE *share= info->s;
|
|
|
|
LSN lsn;
|
|
|
|
uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 1 + 2 + 1 + 2 + 2 + 7],
|
|
|
|
*log_pos;
|
|
|
|
LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 5];
|
|
|
|
uint translog_parts, extra_length= 0;
|
|
|
|
DBUG_ENTER("_ma_log_rt_split");
|
|
|
|
DBUG_PRINT("enter", ("page: %lu", (ulong) page));
|
|
|
|
|
|
|
|
DBUG_ASSERT(share->now_transactional);
|
|
|
|
page/= share->block_size;
|
|
|
|
page_store(log_data + FILEID_STORE_SIZE, page);
|
|
|
|
log_pos= log_data+ FILEID_STORE_SIZE + PAGE_STORE_SIZE;
|
|
|
|
log_pos[0]= KEY_OP_DEL_SUFFIX;
|
|
|
|
log_pos++;
|
|
|
|
DBUG_ASSERT((int)length_diff > 0);
|
|
|
|
int2store(log_pos, length_diff);
|
|
|
|
log_pos+= 2;
|
|
|
|
log_pos[0]= KEY_OP_MULTI_COPY;
|
|
|
|
log_pos++;
|
|
|
|
int2store(log_pos, full_length);
|
|
|
|
log_pos+= 2;
|
|
|
|
int2store(log_pos, log_internal_copy_length);
|
2008-04-24 23:13:56 +02:00
|
|
|
log_pos+= 2;
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data;
|
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data) - 7;
|
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + 1].str= log_internal_copy;
|
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + 1].length= log_internal_copy_length;
|
|
|
|
translog_parts= 2;
|
|
|
|
if (log_key_copy != NULL) /* need to store key into record */
|
|
|
|
{
|
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + 2].str= log_key_copy;
|
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + 2].length= 1 + 2 + 1 + 2;
|
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + 3].str= key_with_nod_flag;
|
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + 3].length= full_length;
|
|
|
|
extra_length= 1 + 2 + 1 + 2 + full_length;
|
|
|
|
translog_parts+= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef EXTRA_DEBUG_KEY_CHANGES
|
|
|
|
{
|
|
|
|
int page_length= _ma_get_page_used(share, buff);
|
|
|
|
ha_checksum crc;
|
2008-04-24 23:13:56 +02:00
|
|
|
uchar *check_start= log_pos;
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
crc= my_checksum(0, buff + LSN_STORE_SIZE, page_length - LSN_STORE_SIZE);
|
|
|
|
log_pos[0]= KEY_OP_CHECK;
|
2008-04-24 23:13:56 +02:00
|
|
|
log_pos++;
|
|
|
|
int2store(log_pos, page_length);
|
|
|
|
log_pos+= 2;
|
|
|
|
int4store(log_pos, crc);
|
|
|
|
log_pos+= 4;
|
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= check_start;
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7;
|
|
|
|
translog_parts++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (translog_write_record(&lsn, LOGREC_REDO_INDEX,
|
|
|
|
info->trn, info,
|
|
|
|
(translog_size_t) ((log_pos - log_data) +
|
|
|
|
log_internal_copy_length +
|
|
|
|
extra_length),
|
|
|
|
TRANSLOG_INTERNAL_PARTS + translog_parts,
|
|
|
|
log_array, log_data, NULL))
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
0 ok; the created page is put into page cache; the shortened one is not (up
|
|
|
|
to the caller to do it)
|
|
|
|
1 or -1: error.
|
|
|
|
If new_page_offs==NULL, won't create new page (for redo phase).
|
|
|
|
*/
|
|
|
|
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
int maria_rtree_split_page(MARIA_HA *info, const MARIA_KEYDEF *keyinfo,
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
my_off_t page_offs, uchar *page, const uchar *key,
|
2007-01-18 20:38:14 +01:00
|
|
|
uint key_length, my_off_t *new_page_offs)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
2007-12-10 01:32:00 +01:00
|
|
|
MARIA_SHARE *share= info->s;
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
const my_bool transactional= share->now_transactional;
|
2006-04-11 15:45:10 +02:00
|
|
|
int n1, n2; /* Number of items in groups */
|
|
|
|
SplitStruct *task;
|
|
|
|
SplitStruct *cur;
|
|
|
|
SplitStruct *stop;
|
|
|
|
double *coord_buf;
|
|
|
|
double *next_coord;
|
|
|
|
double *old_coord;
|
|
|
|
int n_dim;
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar *source_cur, *cur1, *cur2;
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
uchar *new_page, *log_internal_copy, *log_internal_copy_ptr,
|
|
|
|
*log_key_copy= NULL;
|
2006-04-11 15:45:10 +02:00
|
|
|
int err_code= 0;
|
2007-12-10 01:32:00 +01:00
|
|
|
uint nod_flag= _ma_test_if_nod(share, page);
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
uint org_length= _ma_get_page_used(share, page), new_length;
|
2006-04-11 15:45:10 +02:00
|
|
|
uint full_length= key_length + (nod_flag ? nod_flag :
|
2007-12-10 01:32:00 +01:00
|
|
|
share->base.rec_reflength);
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
int max_keys= ((org_length - share->keypage_header) /
|
2007-10-09 20:09:50 +02:00
|
|
|
(full_length));
|
First part of redo/undo for key pages
Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion
For transactional tables, shift record number in keys up with 1 bit to have place to indicate if transid follows
Checksum for MyISAM now ignores NULL and not used part of VARCHAR
Renamed some variables that caused shadow compiler warnings
Moved extra() call when waiting for tables to not be used to after tables are removed from cache.
Fixed crashing bugs when using Maria TEMPORARY tables with TRUNCATE. Removed 'hack' code in sql directory to go around this bug.
pagecache_unlock_by_ulink() now has extra argument to say if page was changed.
Give error message if we fail to open control file
Mark page cache variables as not flushable
include/maria.h:
Made min page cache larger (needed for pinning key page)
Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion
Added write_comp_flag to move some runtime code to maria_open()
include/my_base.h:
Added new error message to be used when handler initialization failed
include/my_global.h:
Renamed dummy to swap_dummy to avoid conflicts with local 'dummy' variables
include/my_handler.h:
Added const to some parameters
mysys/array.c:
More DBUG
mysys/my_error.c:
Fixed indentation
mysys/my_handler.c:
Added const to some parameters
Added missing error messages
sql/field.h:
Renamed variables to avoid variable shadowing
sql/handler.h:
Renamed parameter to avoid variable name conflict
sql/item.h:
Renamed variables to avoid variable shadowing
sql/log_event_old.h:
Renamed variables to avoid variable shadowing
sql/set_var.h:
Renamed variables to avoid variable shadowing
sql/sql_delete.cc:
Removed maria hack for temporary tables
Fixed indentation
sql/sql_table.cc:
Moved extra() call when waiting for tables to not be used to after tables are removed from cache.
This was needed to ensure we don't do a PREPARE_FOR_DROP or similar call while the table is still in use.
sql/table.cc:
Copy page_checksum from share
Removed Maria hack
storage/maria/Makefile.am:
Added new files
storage/maria/ha_maria.cc:
Renamed records -> record_count and info -> create_info to avoid variable name conflicts
Mark page cache variables as not flushable
storage/maria/ma_blockrec.c:
Moved _ma_unpin_all_pages() to ma_key_recover.c
Moved init of info->pinned_pages to ma_open.c
Moved _ma_finalize_row() to maria_key_recover.h
Renamed some variables to avoid variable name conflicts
Mark page_link.changed for blocks we change directly
Simplify handling of undo link when writing LOGREC_UNDO_ROW_INSERT (old code crashed when having redo for index)
storage/maria/ma_blockrec.h:
Removed extra empty line
storage/maria/ma_checkpoint.c:
Remove not needed trnman.h
storage/maria/ma_close.c:
Free pinned pages (which are now always allocated)
storage/maria/ma_control_file.c:
Give error message if we fail to open control file
storage/maria/ma_delete.c:
Changes for redo logging (first part, logging of underflow not yet done)
- Log undo-key-delete
- Log delete of key
- Updated arguments to _ma_fetch_keypage(), _ma_dispose(), _ma_write_keypage(), _ma_insert()
- Added new arguments to some functions to be able to write redo information
- Mark key pages as changed when we write with PAGECACHE_LOCK_LEFT_WRITELOCKED
Remove one not needed _ma_write_keypage() in d_search() when upper level will do the write anyway
Changed 2 bmove_upp() to bmove() as this made code easer to understand
More function comments
Indentation fixes
storage/maria/ma_ft_update.c:
New arguments to _ma_write_keypage()
storage/maria/ma_loghandler.c:
Fixed some DBUG_PRINT messages
Simplify code
Added new log entrys for key page redo
Renamed some variables to avoid variable name shadowing
storage/maria/ma_loghandler.h:
Moved some defines here
Added define for storing key number on key pages
Added new translog record types
Added enum for type of operations in LOGREC_REDO_INDEX
storage/maria/ma_open.c:
Always allocate info.pinned_pages (we need now also for normal key page usage)
Update keyinfo->key_nr
Added virtual functions to convert record position o number to be stored on key pages
Update keyinfo->write_comp_flag to value of search flag to be used when writing key
storage/maria/ma_page.c:
Added redo for key pages
- Extended _ma_fetch_keypage() with type of lock to put on page and address to used MARIA_PINNED_PAGE
- _ma_fetch_keypage() now pin's pages if needed
- Extended _ma_write_keypage() with type of locks to be used
- ma_dispose() now locks info->s->state.key_del from other threads
- ma_dispose() writes redo log record
- ma_new() locks info->s->state.key_del from other threads if it was used
- ma_new() now pins read page
Other things:
- Removed some not needed arguments from _ma_new() and _ma_dispose)
- Added some new variables to simplify code
- If EXTRA_DEBUG is used, do crc on full page to catch not unitialized bytes
storage/maria/ma_pagecache.h:
Applied patch from Sanja to add extra argument to pagecache_unlock_by_ulink() to mark if page was changed
Added some defines for pagecache priority levels that one can use
storage/maria/ma_range.c:
Added new arguments for call to _ma_fetch_keypage()
storage/maria/ma_recovery.c:
- Added hooks for new translog types:
REDO_INDEX, REDO_INDEX_NEW_PAGE, REDO_INDEX_FREE_PAGE, UNDO_KEY_INSERT, UNDO_KEY_DELETE and
UNDO_KEY_DELETE_WITH_ROOT.
- Moved variable declarations to start of function (portability fixes)
- Removed some not needed initializations
- Set only relevant state changes for each redo/undo entry
storage/maria/lockman.c:
Removed end space
storage/maria/ma_check.c:
Removed end space
storage/maria/ma_create.c:
Removed end space
storage/maria/ma_locking.c:
Removed end space
storage/maria/ma_packrec.c:
Removed end space
storage/maria/ma_pagecache.c:
Removed end space
storage/maria/ma_panic.c:
Removed end space
storage/maria/ma_rt_index.c:
Added new arguments for call to _ma_fetch_keypage(), _ma_write_keypage(), _ma_dispose() and _ma_new()
Fixed indentation
storage/maria/ma_rt_key.c:
Added new arguments for call to _ma_fetch_keypage()
storage/maria/ma_rt_split.c:
Added new arguments for call to _ma_new()
Use new keypage header
Added new arguments for call to _ma_write_keypage()
storage/maria/ma_search.c:
Updated comments & indentation
Added new arguments for call to _ma_fetch_keypage()
Made some variables and arguments const
Added virtual functions for converting row position to number to be stored in key
use MARIA_RECORD_POS of record position instead of my_off_t
Record in MARIA_KEY_PARAM how page was changed one key insert (needed for REDO)
storage/maria/ma_sort.c:
Removed end space
storage/maria/ma_statrec.c:
Updated arguments for call to _ma_rec_pos()
storage/maria/ma_test1.c:
Fixed too small buffer to init_pagecache()
Fixed bug when using insert_count and test_flag
storage/maria/ma_test2.c:
Use more resonable pagecache size
Remove not used code
Reset blob_length to fix wrong output message
storage/maria/ma_test_all.sh:
Fixed wrong test
storage/maria/ma_write.c:
Lots of new code to handle REDO of key pages
No logic changes because of REDO code, mostly adding new arguments and adding new code for logging
Added new arguments for calls to _ma_fetch_keypage(), _ma_write_keypage() and similar functions
Move setting of comp_flag in ma_ck_wrte_btree() from runtime to maria_open()
Zerofill new used pages for:
- To remove possible sensitive data left in buffer
- To get idenitical data on pages after running redo
- Better compression of pages if archived
storage/maria/maria_chk.c:
Added information if table is crash safe
storage/maria/maria_def.h:
New virtual function to convert between record position on key and normal record position
Aded mutex and extra variables to handle locking of share->state.key_del
Moved some structure variables to get things more aligned
Added extra arguments to MARIA_KEY_PARAM to be able to remember what was changed on key page on key insert
Added argument to MARIA_PINNED_PAGE to indicate if page was changed
Updated prototypes for functions
Added some structures for signaling changes in REDO handling
storage/maria/unittest/ma_pagecache_single.c:
Updated arguments for changed function calls
storage/myisam/mi_check.c:
Made calc_check_checksum virtual
storage/myisam/mi_checksum.c:
Update checksums to ignore null columns
storage/myisam/mi_create.c:
Mark if table has null column (to know when we have to use mi_checksum())
storage/myisam/mi_open.c:
Added virtual function for calculating checksum to be able to easily ignore NULL fields
storage/myisam/mi_test2.c:
Fixed bug
storage/myisam/myisamdef.h:
Added virtual function for calculating checksum during check table
Removed ha_key_cmp() as this is in handler.h
storage/maria/ma_key_recover.c:
New BitKeeper file ``storage/maria/ma_key_recover.c''
storage/maria/ma_key_recover.h:
New BitKeeper file ``storage/maria/ma_key_recover.h''
storage/maria/ma_key_redo.c:
New BitKeeper file ``storage/maria/ma_key_redo.c''
2007-11-14 18:08:06 +01:00
|
|
|
MARIA_PINNED_PAGE tmp_page_link, *page_link= &tmp_page_link;
|
2007-07-27 12:06:39 +02:00
|
|
|
DBUG_ENTER("maria_rtree_split_page");
|
|
|
|
DBUG_PRINT("rtree", ("splitting block"));
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
n_dim= keyinfo->keysegs / 2;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
if (!(coord_buf= (double*) my_alloca(n_dim * 2 * sizeof(double) *
|
|
|
|
(max_keys + 1 + 4) +
|
|
|
|
sizeof(SplitStruct) * (max_keys + 1))))
|
2007-07-27 12:06:39 +02:00
|
|
|
DBUG_RETURN(-1); /* purecov: inspected */
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
task= (SplitStruct *)(coord_buf + n_dim * 2 * (max_keys + 1 + 4));
|
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
next_coord= coord_buf;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
stop= task + max_keys;
|
2007-12-10 01:32:00 +01:00
|
|
|
source_cur= rt_PAGE_FIRST_KEY(share, page, nod_flag);
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-12-10 01:32:00 +01:00
|
|
|
for (cur= task;
|
|
|
|
cur < stop;
|
|
|
|
cur++, source_cur= rt_PAGE_NEXT_KEY(share, source_cur, key_length,
|
|
|
|
nod_flag))
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
cur->coords= reserve_coords(&next_coord, n_dim);
|
|
|
|
cur->key= source_cur;
|
2006-04-11 15:45:10 +02:00
|
|
|
maria_rtree_d_mbr(keyinfo->seg, source_cur, key_length, cur->coords);
|
|
|
|
}
|
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
cur->coords= reserve_coords(&next_coord, n_dim);
|
2006-04-11 15:45:10 +02:00
|
|
|
maria_rtree_d_mbr(keyinfo->seg, key, key_length, cur->coords);
|
2007-10-09 20:09:50 +02:00
|
|
|
cur->key= key;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
old_coord= next_coord;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
if (split_maria_rtree_node(task, max_keys + 1,
|
2007-12-10 01:32:00 +01:00
|
|
|
_ma_get_page_used(share, page) + full_length + 2,
|
2007-10-09 20:09:50 +02:00
|
|
|
full_length,
|
2006-04-11 15:45:10 +02:00
|
|
|
rt_PAGE_MIN_SIZE(keyinfo->block_length),
|
|
|
|
2, 2, &next_coord, n_dim))
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
err_code= 1;
|
2006-04-11 15:45:10 +02:00
|
|
|
goto split_err;
|
|
|
|
}
|
|
|
|
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
/* Allocate buffer for new page and piece of log record */
|
|
|
|
if (!(new_page= (uchar*) my_alloca((uint)keyinfo->block_length +
|
|
|
|
(transactional ?
|
|
|
|
(max_keys * (2 + 2) +
|
|
|
|
1 + 2 + 1 + 2) : 0))))
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
|
|
|
err_code= -1;
|
|
|
|
goto split_err;
|
|
|
|
}
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
log_internal_copy= log_internal_copy_ptr= new_page + keyinfo->block_length;
|
2008-03-21 22:29:05 +01:00
|
|
|
bzero(new_page, share->block_size);
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
stop= task + (max_keys + 1);
|
2007-12-10 01:32:00 +01:00
|
|
|
cur1= rt_PAGE_FIRST_KEY(share, page, nod_flag);
|
|
|
|
cur2= rt_PAGE_FIRST_KEY(share, new_page, nod_flag);
|
2006-04-11 15:45:10 +02:00
|
|
|
|
2007-10-09 20:09:50 +02:00
|
|
|
n1= n2= 0;
|
|
|
|
for (cur= task; cur < stop; cur++)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar *to;
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
const uchar *cur_key= cur->key;
|
|
|
|
my_bool log_this_change;
|
|
|
|
DBUG_ASSERT(log_key_copy == NULL);
|
2006-04-11 15:45:10 +02:00
|
|
|
if (cur->n_node == 1)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
to= cur1;
|
2007-12-10 01:32:00 +01:00
|
|
|
cur1= rt_PAGE_NEXT_KEY(share, cur1, key_length, nod_flag);
|
2007-10-09 20:09:50 +02:00
|
|
|
n1++;
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
log_this_change= transactional;
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
to= cur2;
|
2007-12-10 01:32:00 +01:00
|
|
|
cur2= rt_PAGE_NEXT_KEY(share, cur2, key_length, nod_flag);
|
2007-10-09 20:09:50 +02:00
|
|
|
n2++;
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
log_this_change= FALSE;
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
if (to != cur_key)
|
|
|
|
{
|
|
|
|
uchar *to_with_nod_flag= to - nod_flag;
|
|
|
|
const uchar *cur_key_with_nod_flag= cur_key - nod_flag;
|
|
|
|
memcpy(to_with_nod_flag, cur_key_with_nod_flag, full_length);
|
|
|
|
if (log_this_change)
|
|
|
|
{
|
|
|
|
uint to_with_nod_flag_offs= to_with_nod_flag - page;
|
|
|
|
if (likely(cur_key != key))
|
|
|
|
{
|
|
|
|
/* this memcpy() is internal to the page (source in the page) */
|
|
|
|
uint cur_key_with_nod_flag_offs= cur_key_with_nod_flag - page;
|
|
|
|
int2store(log_internal_copy_ptr, to_with_nod_flag_offs);
|
|
|
|
log_internal_copy_ptr+= 2;
|
|
|
|
int2store(log_internal_copy_ptr, cur_key_with_nod_flag_offs);
|
|
|
|
log_internal_copy_ptr+= 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* last iteration, and this involves *key: source is external */
|
|
|
|
log_key_copy= log_internal_copy_ptr;
|
|
|
|
log_key_copy[0]= KEY_OP_OFFSET;
|
|
|
|
int2store(log_key_copy + 1, to_with_nod_flag_offs);
|
|
|
|
log_key_copy[3]= KEY_OP_CHANGE;
|
|
|
|
int2store(log_key_copy + 4, full_length);
|
|
|
|
/* _ma_log_rt_split() will store *key, right after */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{ /* verify that above loop didn't touch header bytes */
|
|
|
|
uint i;
|
|
|
|
for (i= 0; i < share->keypage_header; i++)
|
|
|
|
DBUG_ASSERT(new_page[i]==0);
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
|
2007-12-04 22:23:42 +01:00
|
|
|
if (nod_flag)
|
2007-12-10 01:32:00 +01:00
|
|
|
_ma_store_keypage_flag(share, new_page, KEYPAGE_FLAG_ISNOD);
|
|
|
|
_ma_store_keynr(share, new_page, keyinfo->key_nr);
|
|
|
|
_ma_store_page_used(share, new_page, share->keypage_header +
|
2007-12-04 22:23:42 +01:00
|
|
|
n2 * full_length);
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
new_length= share->keypage_header + n1 * full_length;
|
|
|
|
_ma_store_page_used(share, page, new_length);
|
2006-04-11 15:45:10 +02:00
|
|
|
|
First part of redo/undo for key pages
Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion
For transactional tables, shift record number in keys up with 1 bit to have place to indicate if transid follows
Checksum for MyISAM now ignores NULL and not used part of VARCHAR
Renamed some variables that caused shadow compiler warnings
Moved extra() call when waiting for tables to not be used to after tables are removed from cache.
Fixed crashing bugs when using Maria TEMPORARY tables with TRUNCATE. Removed 'hack' code in sql directory to go around this bug.
pagecache_unlock_by_ulink() now has extra argument to say if page was changed.
Give error message if we fail to open control file
Mark page cache variables as not flushable
include/maria.h:
Made min page cache larger (needed for pinning key page)
Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion
Added write_comp_flag to move some runtime code to maria_open()
include/my_base.h:
Added new error message to be used when handler initialization failed
include/my_global.h:
Renamed dummy to swap_dummy to avoid conflicts with local 'dummy' variables
include/my_handler.h:
Added const to some parameters
mysys/array.c:
More DBUG
mysys/my_error.c:
Fixed indentation
mysys/my_handler.c:
Added const to some parameters
Added missing error messages
sql/field.h:
Renamed variables to avoid variable shadowing
sql/handler.h:
Renamed parameter to avoid variable name conflict
sql/item.h:
Renamed variables to avoid variable shadowing
sql/log_event_old.h:
Renamed variables to avoid variable shadowing
sql/set_var.h:
Renamed variables to avoid variable shadowing
sql/sql_delete.cc:
Removed maria hack for temporary tables
Fixed indentation
sql/sql_table.cc:
Moved extra() call when waiting for tables to not be used to after tables are removed from cache.
This was needed to ensure we don't do a PREPARE_FOR_DROP or similar call while the table is still in use.
sql/table.cc:
Copy page_checksum from share
Removed Maria hack
storage/maria/Makefile.am:
Added new files
storage/maria/ha_maria.cc:
Renamed records -> record_count and info -> create_info to avoid variable name conflicts
Mark page cache variables as not flushable
storage/maria/ma_blockrec.c:
Moved _ma_unpin_all_pages() to ma_key_recover.c
Moved init of info->pinned_pages to ma_open.c
Moved _ma_finalize_row() to maria_key_recover.h
Renamed some variables to avoid variable name conflicts
Mark page_link.changed for blocks we change directly
Simplify handling of undo link when writing LOGREC_UNDO_ROW_INSERT (old code crashed when having redo for index)
storage/maria/ma_blockrec.h:
Removed extra empty line
storage/maria/ma_checkpoint.c:
Remove not needed trnman.h
storage/maria/ma_close.c:
Free pinned pages (which are now always allocated)
storage/maria/ma_control_file.c:
Give error message if we fail to open control file
storage/maria/ma_delete.c:
Changes for redo logging (first part, logging of underflow not yet done)
- Log undo-key-delete
- Log delete of key
- Updated arguments to _ma_fetch_keypage(), _ma_dispose(), _ma_write_keypage(), _ma_insert()
- Added new arguments to some functions to be able to write redo information
- Mark key pages as changed when we write with PAGECACHE_LOCK_LEFT_WRITELOCKED
Remove one not needed _ma_write_keypage() in d_search() when upper level will do the write anyway
Changed 2 bmove_upp() to bmove() as this made code easer to understand
More function comments
Indentation fixes
storage/maria/ma_ft_update.c:
New arguments to _ma_write_keypage()
storage/maria/ma_loghandler.c:
Fixed some DBUG_PRINT messages
Simplify code
Added new log entrys for key page redo
Renamed some variables to avoid variable name shadowing
storage/maria/ma_loghandler.h:
Moved some defines here
Added define for storing key number on key pages
Added new translog record types
Added enum for type of operations in LOGREC_REDO_INDEX
storage/maria/ma_open.c:
Always allocate info.pinned_pages (we need now also for normal key page usage)
Update keyinfo->key_nr
Added virtual functions to convert record position o number to be stored on key pages
Update keyinfo->write_comp_flag to value of search flag to be used when writing key
storage/maria/ma_page.c:
Added redo for key pages
- Extended _ma_fetch_keypage() with type of lock to put on page and address to used MARIA_PINNED_PAGE
- _ma_fetch_keypage() now pin's pages if needed
- Extended _ma_write_keypage() with type of locks to be used
- ma_dispose() now locks info->s->state.key_del from other threads
- ma_dispose() writes redo log record
- ma_new() locks info->s->state.key_del from other threads if it was used
- ma_new() now pins read page
Other things:
- Removed some not needed arguments from _ma_new() and _ma_dispose)
- Added some new variables to simplify code
- If EXTRA_DEBUG is used, do crc on full page to catch not unitialized bytes
storage/maria/ma_pagecache.h:
Applied patch from Sanja to add extra argument to pagecache_unlock_by_ulink() to mark if page was changed
Added some defines for pagecache priority levels that one can use
storage/maria/ma_range.c:
Added new arguments for call to _ma_fetch_keypage()
storage/maria/ma_recovery.c:
- Added hooks for new translog types:
REDO_INDEX, REDO_INDEX_NEW_PAGE, REDO_INDEX_FREE_PAGE, UNDO_KEY_INSERT, UNDO_KEY_DELETE and
UNDO_KEY_DELETE_WITH_ROOT.
- Moved variable declarations to start of function (portability fixes)
- Removed some not needed initializations
- Set only relevant state changes for each redo/undo entry
storage/maria/lockman.c:
Removed end space
storage/maria/ma_check.c:
Removed end space
storage/maria/ma_create.c:
Removed end space
storage/maria/ma_locking.c:
Removed end space
storage/maria/ma_packrec.c:
Removed end space
storage/maria/ma_pagecache.c:
Removed end space
storage/maria/ma_panic.c:
Removed end space
storage/maria/ma_rt_index.c:
Added new arguments for call to _ma_fetch_keypage(), _ma_write_keypage(), _ma_dispose() and _ma_new()
Fixed indentation
storage/maria/ma_rt_key.c:
Added new arguments for call to _ma_fetch_keypage()
storage/maria/ma_rt_split.c:
Added new arguments for call to _ma_new()
Use new keypage header
Added new arguments for call to _ma_write_keypage()
storage/maria/ma_search.c:
Updated comments & indentation
Added new arguments for call to _ma_fetch_keypage()
Made some variables and arguments const
Added virtual functions for converting row position to number to be stored in key
use MARIA_RECORD_POS of record position instead of my_off_t
Record in MARIA_KEY_PARAM how page was changed one key insert (needed for REDO)
storage/maria/ma_sort.c:
Removed end space
storage/maria/ma_statrec.c:
Updated arguments for call to _ma_rec_pos()
storage/maria/ma_test1.c:
Fixed too small buffer to init_pagecache()
Fixed bug when using insert_count and test_flag
storage/maria/ma_test2.c:
Use more resonable pagecache size
Remove not used code
Reset blob_length to fix wrong output message
storage/maria/ma_test_all.sh:
Fixed wrong test
storage/maria/ma_write.c:
Lots of new code to handle REDO of key pages
No logic changes because of REDO code, mostly adding new arguments and adding new code for logging
Added new arguments for calls to _ma_fetch_keypage(), _ma_write_keypage() and similar functions
Move setting of comp_flag in ma_ck_wrte_btree() from runtime to maria_open()
Zerofill new used pages for:
- To remove possible sensitive data left in buffer
- To get idenitical data on pages after running redo
- Better compression of pages if archived
storage/maria/maria_chk.c:
Added information if table is crash safe
storage/maria/maria_def.h:
New virtual function to convert between record position on key and normal record position
Aded mutex and extra variables to handle locking of share->state.key_del
Moved some structure variables to get things more aligned
Added extra arguments to MARIA_KEY_PARAM to be able to remember what was changed on key page on key insert
Added argument to MARIA_PINNED_PAGE to indicate if page was changed
Updated prototypes for functions
Added some structures for signaling changes in REDO handling
storage/maria/unittest/ma_pagecache_single.c:
Updated arguments for changed function calls
storage/myisam/mi_check.c:
Made calc_check_checksum virtual
storage/myisam/mi_checksum.c:
Update checksums to ignore null columns
storage/myisam/mi_create.c:
Mark if table has null column (to know when we have to use mi_checksum())
storage/myisam/mi_open.c:
Added virtual function for calculating checksum to be able to easily ignore NULL fields
storage/myisam/mi_test2.c:
Fixed bug
storage/myisam/myisamdef.h:
Added virtual function for calculating checksum during check table
Removed ha_key_cmp() as this is in handler.h
storage/maria/ma_key_recover.c:
New BitKeeper file ``storage/maria/ma_key_recover.c''
storage/maria/ma_key_recover.h:
New BitKeeper file ``storage/maria/ma_key_recover.h''
storage/maria/ma_key_redo.c:
New BitKeeper file ``storage/maria/ma_key_redo.c''
2007-11-14 18:08:06 +01:00
|
|
|
if ((*new_page_offs= _ma_new(info, DFLT_INIT_HITS, &page_link)) ==
|
|
|
|
HA_OFFSET_ERROR)
|
2006-04-11 15:45:10 +02:00
|
|
|
err_code= -1;
|
|
|
|
else
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
{
|
|
|
|
if (transactional &&
|
|
|
|
( /* log change to split page */
|
|
|
|
_ma_log_rt_split(info, page_offs, page, key - nod_flag,
|
|
|
|
full_length, log_internal_copy,
|
|
|
|
log_internal_copy_ptr - log_internal_copy,
|
|
|
|
log_key_copy, org_length - new_length) ||
|
|
|
|
/* and to new page */
|
|
|
|
_ma_log_new(info, *new_page_offs, new_page,
|
|
|
|
share->keypage_header + n2 * full_length,
|
|
|
|
keyinfo->key_nr, 0)))
|
|
|
|
err_code= -1;
|
|
|
|
if ( _ma_write_keypage(info, keyinfo, *new_page_offs,
|
|
|
|
page_link->write_lock,
|
|
|
|
DFLT_INIT_HITS, new_page))
|
|
|
|
err_code= -1;
|
|
|
|
}
|
2007-07-27 12:06:39 +02:00
|
|
|
DBUG_PRINT("rtree", ("split new block: %lu", (ulong) *new_page_offs));
|
2006-04-11 15:45:10 +02:00
|
|
|
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
my_afree(new_page);
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
split_err:
|
WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)
mysql-test/r/maria.result:
correct result
mysql-test/t/maria.test:
now we get no error
storage/maria/ma_blockrec.c:
delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
ma_get_length() does not change **packet, marking it with 'const' to
remove some casts in callers of this function. The
(const uchar**)&header casts will be removed when Monty changes 'header'
to const uchar*.
_ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
so its initialization was superfluous.
storage/maria/ma_check.c:
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
(see comment in code)
storage/maria/ma_create.c:
FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
Logging done by _ma_ck_delete() is moved to a function
(_ma_write_undo_key_delete()), for reusal by R-tree logging.
_ma_log_delete() is made non-static for same
reason, and some of its parameters are made pointers to const.
Removed wrong comment ("Note that for delete key" etc, contradicted by
code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
unneeded cast, comment for future
storage/maria/ma_key_recover.c:
Comment about possible deadlock.
Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
Support operation KEY_OP_MULTI_COPY.
When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
the proper key insertion|deletion depending on if this is R-tree
or B-tree.
Explanation of of _ma_[un]lock_key_del() work, maybe useful for
mortals like me.
storage/maria/ma_key_recover.h:
change of prototypes
storage/maria/ma_loghandler.h:
New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
Comments
storage/maria/ma_pagecache.c:
typo
storage/maria/ma_rt_index.c:
Fix for bug: the page_link pointer in maria_rtree_insert_req()
could be wrong when we set its 'changed' member; for the solution
see ma_key_recover.h. It is needed only in cases when we manipulate
several pages.
Logging of changes done to pages by key insert/delete.
maria_rtree_delete()'s main work is moved to a new function
maria_rtree_real_delete(), which is used by maria_rtree_delete()
and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
Logging of maria_rtree_add_key() and maria_rtree_delete_key().
When inserting, split is necessary if there is not enough room for key:
take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
new prototypes (those functions need to know the page's id
because they do logging)
storage/maria/ma_rt_mbr.c:
Comments about what the functions change.
storage/maria/ma_rt_split.c:
maria_rtree_split_page() needs to know the page's id, because
it does logging.
Logging of what a split operation does to the split page (see
comment of _ma_log_rt_split(): moves of keys inside the page,
sometimes insertion of the new key, and shrinking of the page)
and to the new page (receives some keys from split page, and
sometimes the new key).
storage/maria/ma_rt_test.c:
ma_rt_test had been forgotten when maria_rkey() was changed some months ago
(0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
were rewritten to maria_scan() calls (which implies maria_scan_init()).
The 'max_i' change is to adapt to the fact that maria_scan() does
not return deleted records for BLOCK_RECORD but does so for other formats;
the initial code assumed a certain number of deleted records would be
returned, we change it to rather count only non-deleted ones.
We also add more features to this test, like ma_test1 (the plan
is to run ma_rt_test in ma_test_all-t):
options to choose records' format, table checksum, transactions,
checkpoints, end at specific stages, abort without committing,
and debug trace.
storage/maria/ma_test1.c:
MY_INIT() does my_init().
storage/maria/ma_write.c:
Logging done by _ma_ck_write_btree_with_log() is moved to a function
(_ma_write_undo_key_insert()), for reusal by R-tree logging.
_ma_log_new() and _ma_log_change() are made non-static for same
reason. Some parameters of logging functions are made pointers to const.
If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
(better checks, bigger record).
storage/maria/maria_read_log.c:
Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
rt_test had been forgotten when mi_rkey() was changed some months ago
(0->HA_WHOLE_KEY change).
The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
correct result
mysql-test/r/maria-gis-rtree-trans.result:
correct result
mysql-test/r/maria-recovery-rtree-ft.result:
almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00
|
|
|
my_afree(coord_buf);
|
2007-07-27 12:06:39 +02:00
|
|
|
DBUG_RETURN(err_code);
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /*HAVE_RTREE_KEYS*/
|