summaryrefslogtreecommitdiff
path: root/storage/maria/ma_search.c
diff options
context:
space:
mode:
authorunknown <monty@mysql.com/nosik.monty.fi>2007-11-20 17:42:16 +0200
committerunknown <monty@mysql.com/nosik.monty.fi>2007-11-20 17:42:16 +0200
commit6b3743f0aa10ff5bcb0ea0e88722b2c912dd7a89 (patch)
tree69cc78ab4b628220ce007ad2e937462c18327954 /storage/maria/ma_search.c
parent422375fc1bce1ea6ffb9226cfdef02c6a05b2a0f (diff)
downloadmariadb-git-6b3743f0aa10ff5bcb0ea0e88722b2c912dd7a89.tar.gz
Fixes for redo/undo logging of key pages
New extendable format for maria_log_control file Fixed some compiler warnings include/maria.h: Added maria_disable_logging() and maria_enable_logging() mysql-test/include/maria_verify_recovery.inc: Updated tests now when key redo/undo works mysql-test/r/maria-recovery.result: Updated tests now when key redo/undo works storage/maria/ma_blockrec.c: Use unified CLR code Added rec_lsn for full pages Moved clr write hook to ma_key_recover.c Changed REDO code to keep pages pinned until undo Mark page_link's as changed storage/maria/ma_blockrec.h: Moved write_hook_for_clr_end() to ma_key_recover.c storage/maria/ma_check.c: Changed key check code to use PAGECACHE_READ_UNKNOWN_PAGE Fixed wrong warning when checking files after maria_pack When unpacking files, we have to use new keypos_to_recpos method When doing repair, we can disregard index key file pages in page cache storage/maria/ma_commit.c: Added simple enable/disable logging functions (Needed for recovery) storage/maria/ma_control_file.c: Make maria control file extendable without having to make it incompatible for older versions storage/maria/ma_control_file.h: New error messages Added CONTROL_FILE_VERSION storage/maria/ma_delete.c: Added redo/undo for key pages change_length -> changed_length to make things similar More comments & more DBUG storage/maria/ma_key_recover.c: Unified CLR method Moved here write_hook_for_clr_end() and common keypage log functions Changed REDO to keep pages pinned until undo Changed UNDO code to change key_root under log mutex storage/maria/ma_key_recover.h: New structures and functions storage/maria/ma_loghandler.c: Include needed files storage/maria/ma_open.c: Change maria_open() to use pread() instead of read() storage/maria/ma_page.c: Fixed bug in key_del handling Clear pages if IDENTICAL_PAGES_AFTER_RECOVERY is defined storage/maria/ma_pagecache.c: Indentation and spelling fixes More DBUG Added helper function: pagecache_block_link_to_buffer() storage/maria/ma_pagecache.h: Added pagecache_block_link_to_buffer() storage/maria/ma_recovery.c: Fixed state.changed Fixed that REDO keeps pages pinned until UNDO Some bug fixes from previous commit Fixes for UNDO/REDO of key pages storage/maria/ma_search.c: Fixed packing and storing of keys to provide more information to caller so that we can do efficent REDO logging of the changes. storage/maria/ma_test1.c: Fixed bug with not initialized variable storage/maria/ma_test2.c: Removed not used code storage/maria/ma_test_all.res: Updated results storage/maria/ma_test_all.sh: Changed one test to test more Removed timing tests as not relevant here storage/maria/ma_test_recovery.expected: Updated test result after redo/undo if key pages works storage/maria/ma_test_recovery: Updated test after redo/undo if key pages works storage/maria/ma_write.c: Moved some general log functions to ma_key_recover.c Fixed some bugs in undo Moved ma_log_split() to _ma_split_page() Small changes in some function arguments to be able to do redo logging storage/maria/maria_chk.c: disable logging while doing repair table storage/maria/maria_def.h: New function prototypes Move some structs and functions to ma_key_recover.c storage/maria/unittest/ma_control_file-t.c: Updated with patch from Sanja NOTE: This is not complete and need to be updated to new control file format storage/maria/unittest/ma_test_loghandler-t.c: Fixed compiler warning
Diffstat (limited to 'storage/maria/ma_search.c')
-rw-r--r--storage/maria/ma_search.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/storage/maria/ma_search.c b/storage/maria/ma_search.c
index 8eaff88155e..78e787eae4d 100644
--- a/storage/maria/ma_search.c
+++ b/storage/maria/ma_search.c
@@ -1182,7 +1182,10 @@ static my_bool _ma_get_prev_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
/*
- @brief Get last key from key-page
+ @brief Get last key from key-page before 'endpos'
+
+ @note
+ endpos may be either end of buffer or start of a key
@return
@retval pointer to where key starts
@@ -1506,7 +1509,7 @@ _ma_calc_static_key_length(MARIA_KEYDEF *keyinfo,uint nod_flag,
const uchar *key, MARIA_KEY_PARAM *s_temp)
{
s_temp->key= key;
- return (int) (s_temp->totlength=keyinfo->keylength+nod_flag);
+ return (int) (s_temp->move_length= keyinfo->keylength + nod_flag);
}
/* Variable length key */
@@ -1519,26 +1522,28 @@ _ma_calc_var_key_length(MARIA_KEYDEF *keyinfo,uint nod_flag,
const uchar *key, MARIA_KEY_PARAM *s_temp)
{
s_temp->key= key;
- return (int) (s_temp->totlength= _ma_keylength(keyinfo,key)+nod_flag);
+ return (int) (s_temp->move_length= _ma_keylength(keyinfo,key)+nod_flag);
}
-/*
- length of key with a variable length first segment which is prefix
- compressed (maria_chk reports 'packed + stripped')
+/**
+ @brief Calc length needed to store prefixed compressed keys
- Keys are compressed the following way:
+ @info
+ Variable length first segment which is prefix compressed
+ (maria_chk reports 'packed + stripped')
- If the max length of first key segment <= 127 bytes the prefix is
- 1 uchar else it's 2 byte
+ Keys are compressed the following way:
- prefix byte(s) The high bit is set if this is a prefix for the prev key
- length Packed length if the previous was a prefix byte
- [length] data bytes ('length' bytes)
- next-key-seg Next key segments
+ If the max length of first key segment <= 127 bytes the prefix is
+ 1 uchar else it's 2 byte
- If the first segment can have NULL:
- The length is 0 for NULLS and 1+length for not null columns.
+ prefix byte(s) The high bit is set if this is a prefix for the prev key
+ length Packed length if the previous was a prefix byte
+ [length] data bytes ('length' bytes)
+ next-key-seg Next key segments
+ If the first segment can have NULL:
+ The length is 0 for NULLS and 1+length for not null columns.
*/
int
@@ -1589,7 +1594,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
s_temp->key_length= 0;
s_temp->totlength= key_length-1+diff_flag;
s_temp->next_key_pos= 0; /* No next key */
- return (s_temp->totlength);
+ return (s_temp->move_length= s_temp->totlength);
}
s_temp->store_not_null=1;
key_length--; /* We don't store NULL */
@@ -1744,7 +1749,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
s_temp->n_ref_length=s_temp->n_length= org_key_length;
length+= org_key_length;
}
- return (int) length;
+ return (s_temp->move_length= (int) length);
}
ref_length=n_length;
@@ -1757,7 +1762,8 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
s_temp->part_of_prev_key= 0;
s_temp->prev_length= ref_length;
s_temp->n_ref_length= s_temp->n_length= n_length+ref_length;
- return (int) length+ref_length-next_length_pack;
+ return s_temp->move_length= ((int) length+ref_length-
+ next_length_pack);
}
if (ref_length+pack_marker > new_ref_length)
{
@@ -1768,7 +1774,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
s_temp->n_ref_length=s_temp->n_length=n_length + s_temp->prev_length;
s_temp->prev_key+= new_pack_length;
length-= (next_length_pack - get_pack_length(s_temp->n_length));
- return (int) length + s_temp->prev_length;
+ return s_temp->move_length= ((int) length + s_temp->prev_length);
}
}
else
@@ -1803,7 +1809,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
if (!(tmp_length=(uint) (key-start)))
{ /* Key can't be re-packed */
s_temp->next_key_pos=0;
- return length;
+ return (s_temp->move_length= length);
}
ref_length+=tmp_length;
n_length-=tmp_length;
@@ -1821,7 +1827,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
}
}
}
- return length;
+ return (s_temp->move_length= length);
}
@@ -1884,8 +1890,9 @@ int _ma_calc_bin_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
s_temp->n_ref_length= ref_length;
s_temp->prev_length= next_length-ref_length;
s_temp->prev_key+= ref_length;
- return (int) (length+ s_temp->prev_length - next_length_pack +
- get_pack_length(ref_length));
+ return s_temp->move_length= ((int) (length+ s_temp->prev_length -
+ next_length_pack +
+ get_pack_length(ref_length)));
}
/* Check how many characters are identical to next key */
key= s_temp->key+next_length;
@@ -1893,14 +1900,15 @@ int _ma_calc_bin_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
if ((ref_length= (uint) (key - s_temp->key)-1) == next_length)
{
s_temp->next_key_pos=0;
- return length; /* can't pack next key */
+ return (s_temp->move_length= length); /* Can't pack next key */
}
s_temp->prev_length=0;
s_temp->n_ref_length=ref_length;
- return (int) (length-(ref_length - next_length) - next_length_pack +
- get_pack_length(ref_length));
+ return s_temp->move_length= (int) (length-(ref_length - next_length) -
+ next_length_pack +
+ get_pack_length(ref_length));
}
- return (int) length;
+ return (s_temp->move_length= (int) length);
}
@@ -1914,8 +1922,8 @@ void _ma_store_static_key(MARIA_KEYDEF *keyinfo __attribute__((unused)),
register uchar *key_pos,
register MARIA_KEY_PARAM *s_temp)
{
- memcpy(key_pos, s_temp->key,(size_t) s_temp->totlength);
- s_temp->changed_length= s_temp->totlength;
+ memcpy(key_pos, s_temp->key,(size_t) s_temp->move_length);
+ s_temp->changed_length= s_temp->move_length;
}