diff options
author | unknown <monty@mysql.com/narttu.mysql.fi> | 2007-01-18 21:38:14 +0200 |
---|---|---|
committer | unknown <monty@mysql.com/narttu.mysql.fi> | 2007-01-18 21:38:14 +0200 |
commit | 345959c660d7401c9dc991a2c572ba145d6e199c (patch) | |
tree | 0ff418a13c85f8e38c089046968b0d09cf583e4b /storage/maria/ma_rkey.c | |
parent | e8524352dc79e9231fd2c2d835bf0e479ba6e77a (diff) | |
download | mariadb-git-345959c660d7401c9dc991a2c572ba145d6e199c.tar.gz |
Implementation of rows-in-block
- Fixes some things missed in myisam->maria port
- Moved variables that holds the state for the current row to 'cur_row'
- Changed most uchar * to byte * to be able to remove a lot of casts
- Removed RAID support
- Added CHECK for rows-in-block
- Added allocate_dynamic() for easier usage of dynamic rows when we know how many entries we will need
- Reorder columns after CREATE for more optimal row storage (for rows-in-block)
- Removed flag 'RRND_PRESERVER_LASTINX' (not needed)
- Extended ma_test_all.sh to test more completely all row formats
- New structs and variables to hold rows-in-block and bitmap information
- Added org_data_file_type in header to allow easy restore of old record format when doing maria_pack / maria_chk -u
- More virtual functions to handle different row types
- Pointer to row is now MARIA_RECORD_POS instead of my_off_t
- New header signature for MARIA index files
- Fixed bugs in ma_test1.c and ma_test2.c
- All key and row blocks are now of same size
- We now only have one link chain for deleted key blocks
include/m_string.h:
Define bzero_if_purify
include/maria.h:
Implementation of rows-in-block
include/my_base.h:
Implementation of rows-in-block
include/my_handler.h:
Cleanup macros
Added size_to_store_key_length()
include/my_sys.h:
Added 'allocate_dynamic()'
include/myisamchk.h:
Implementation of rows-in-block
mysys/array.c:
Added allocate_dynamic()
mysys/mf_keycache.c:
Moved DBUG_ENTER to it's right position
mysys/my_pread.c:
Ensure my_errno is always set
sql/filesort.cc:
Fixed some compiler warnings
sql/gen_lex_hash.cc:
Removed not needed 'inline'
sql/ha_maria.cc:
Implementation of rows-in-block
Fixed compiler warnings
sql/mysqld.cc:
Fixed setting of wrong variable
sql/uniques.cc:
Fixed compiler warnings
storage/maria/Makefile.am:
Implementation of rows-in-block
storage/maria/ma_check.c:
Removed RAID functions
Added support for CHECK of rows-in-blocks rows
storage/maria/ma_checksum.c:
Implementation of rows-in-block
storage/maria/ma_close.c:
Implementation of rows-in-block
storage/maria/ma_create.c:
Implementation of rows-in-block:
- Reorder columns
- All key blocks are now of same size
- Removed old RAID support
storage/maria/ma_dbug.c:
Implementation of rows-in-block
storage/maria/ma_delete.c:
Implementation of rows-in-block
storage/maria/ma_delete_all.c:
Implementation of rows-in-block
storage/maria/ma_dynrec.c:
info->rec_buff is now allocated through _ma_alloc_buffer()
Use new info->cur_row structure
storage/maria/ma_extra.c:
Implementation of rows-in-block
storage/maria/ma_ft_boolean_search.c:
Removed compiler warnings
Indentation fixes
storage/maria/ma_ft_nlq_search.c:
Removed compiler warnings
Indentation fixes
storage/maria/ma_ft_update.c:
Removed some casts
storage/maria/ma_fulltext.h:
Changed pointer type
storage/maria/ma_info.c:
Implementation of rows-in-block
More general _ma_report_error()
storage/maria/ma_init.c:
Implementation of rows-in-block
storage/maria/ma_key.c:
Implementation of rows-in-block
Removed some casts
storage/maria/ma_keycache.c:
Fixed DBUG entry
storage/maria/ma_locking.c:
Implementation of rows-in-block
storage/maria/ma_open.c:
Implementation of rows-in-block
storage/maria/ma_packrec.c:
Indentation fixes
Changed uchar * to byte * to make it possible to remove some casts
storage/maria/ma_page.c:
Implementation of rows-in-block
storage/maria/ma_range.c:
Implementation of rows-in-block
storage/maria/ma_rfirst.c:
Implementation of rows-in-block
storage/maria/ma_rkey.c:
Implementation of rows-in-block
Indentation fixes
storage/maria/ma_rlast.c:
Implementation of rows-in-block
storage/maria/ma_rnext.c:
Implementation of rows-in-block
storage/maria/ma_rnext_same.c:
Implementation of rows-in-block
storage/maria/ma_rprev.c:
Implementation of rows-in-block
storage/maria/ma_rrnd.c:
Implementation of rows-in-block
Removed flag 'RRND_PRESERVER_LASTINX', by not resetting lastinx (This is reset by maria_scan_init())
storage/maria/ma_rsame.c:
Implementation of rows-in-block
storage/maria/ma_rsamepos.c:
Implementation of rows-in-block
storage/maria/ma_rt_index.c:
Implementation of rows-in-block
storage/maria/ma_rt_index.h:
Implementation of rows-in-block
storage/maria/ma_rt_key.c:
Implementation of rows-in-block
storage/maria/ma_rt_key.h:
Implementation of rows-in-block
storage/maria/ma_rt_mbr.c:
Implementation of rows-in-block
storage/maria/ma_rt_mbr.h:
Implementation of rows-in-block
storage/maria/ma_rt_split.c:
Implementation of rows-in-block
storage/maria/ma_rt_test.c:
Indentation fix
storage/maria/ma_scan.c:
Implementation of rows-in-block
Added 'maria_scan_end()'
storage/maria/ma_search.c:
Implementation of rows-in-block
storage/maria/ma_sort.c:
Indentation fixes
uchar -> byte to be able to remove some casts
storage/maria/ma_sp_defs.h:
uchar * -> byte *
storage/maria/ma_sp_key.c:
uchar * -> byte *
storage/maria/ma_sp_test.c:
Indentation fixes
storage/maria/ma_static.c:
New header signature for MARIA
storage/maria/ma_statrec.c:
int -> my_bool functions
my_off_t -> MARIA_RECORD_POS
Fixed argument order for _ma_read_static_record()
storage/maria/ma_test1.c:
Implementation of rows-in-block
Fixed some bugs in VARCHAR and BLOB testing
storage/maria/ma_test2.c:
Implementation of rows-in-block
Fixed bug in BLOB testing
storage/maria/ma_test3.c:
Implementation of rows-in-block
storage/maria/ma_test_all.sh:
Run all tests with dynamic, static and block row formats
(For the moment we skip REPAIR test of rows-in-block as this is not yet implemented)
storage/maria/ma_unique.c:
Implementation of rows-in-block
storage/maria/ma_update.c:
Implementation of rows-in-block
storage/maria/ma_write.c:
Implementation of rows-in-block
Write of row is split into two parts, as rows-in-block format require us to do write of row before keys (to get row position) in contrast to all other row formats
storage/maria/maria_chk.c:
Implementation of rows-in-block
storage/maria/maria_def.h:
Implementation of rows-in-block
- New structs and variables to hold rows-in-block and bitmap information
- Added org_data_file_type in header to allow easy restore of old record format when doing maria_pack / maria_chk -u
- More virtual functions to handle different row types
- Pointer to row is now MARIA_RECORD_POS instead of my_off_t
- uchar -> byte for many parameters to avoid casts
storage/maria/maria_ftdump.c:
Implementation of rows-in-block
storage/maria/maria_pack.c:
Implementation of rows-in-block
storage/myisam/mi_check.c:
Added new row types into switch to avoid compiler warnings
Added some casts to avoid warnings after changing type of lastkey and buff
storage/myisam/mi_create.c:
Fix that 'pack_fields' is calculated correctly
storage/myisam/mi_rsamepos.c:
Implementation of rows-in-block
storage/myisam/mi_test2.c:
Fixed wrong printf
storage/myisam/sort.c:
uchar * -> byte *
support-files/magic:
Added support for Maria files
Fided wrong entry's for MyISAM files
storage/maria/ma_bitmap.c:
New BitKeeper file ``storage/maria/ma_bitmap.c''
storage/maria/ma_blockrec.c:
New BitKeeper file ``storage/maria/ma_blockrec.c''
storage/maria/ma_blockrec.h:
New BitKeeper file ``storage/maria/ma_blockrec.h''
Diffstat (limited to 'storage/maria/ma_rkey.c')
-rw-r--r-- | storage/maria/ma_rkey.c | 76 |
1 files changed, 46 insertions, 30 deletions
diff --git a/storage/maria/ma_rkey.c b/storage/maria/ma_rkey.c index 2cb54a73b15..bd92ebd4e4c 100644 --- a/storage/maria/ma_rkey.c +++ b/storage/maria/ma_rkey.c @@ -22,16 +22,16 @@ /* Read a record using key */ /* Ordinary search_flag is 0 ; Give error if no record with key */ -int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len, - enum ha_rkey_function search_flag) +int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, + uint key_len, enum ha_rkey_function search_flag) { - uchar *key_buff; + byte *key_buff; MARIA_SHARE *share=info->s; MARIA_KEYDEF *keyinfo; HA_KEYSEG *last_used_keyseg; uint pack_key_length, use_key_length, nextflag; DBUG_ENTER("maria_rkey"); - DBUG_PRINT("enter", ("base: %lx buf: %lx inx: %d search_flag: %d", + DBUG_PRINT("enter", ("base: 0x%lx buf: 0x%lx inx: %d search_flag: %d", (long) info, (long) buf, inx, search_flag)); if ((inx = _ma_check_index(info,inx)) < 0) @@ -47,7 +47,7 @@ int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len /* key is already packed!; This happens when we are using a MERGE TABLE */ - key_buff=info->lastkey+info->s->base.max_key_length; + key_buff= info->lastkey+info->s->base.max_key_length; pack_key_length= key_len; bmove(key_buff,key,key_len); last_used_keyseg= 0; @@ -58,7 +58,7 @@ int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len key_len=USE_WHOLE_KEY; /* Save the packed key for later use in the second buffer of lastkey. */ key_buff=info->lastkey+info->s->base.max_key_length; - pack_key_length= _ma_pack_key(info,(uint) inx, key_buff, (uchar*) key, + pack_key_length= _ma_pack_key(info,(uint) inx, key_buff, key, key_len, &last_used_keyseg); /* Save packed_key_length for use by the MERGE engine. */ info->pack_key_length= pack_key_length; @@ -82,15 +82,17 @@ int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len if (maria_rtree_find_first(info,inx,key_buff,use_key_length,nextflag) < 0) { maria_print_error(info->s, HA_ERR_CRASHED); - my_errno=HA_ERR_CRASHED; - goto err; + my_errno= HA_ERR_CRASHED; + info->cur_row.lastpos= HA_OFFSET_ERROR; } break; #endif case HA_KEY_ALG_BTREE: default: if (!_ma_search(info, keyinfo, key_buff, use_key_length, - maria_read_vec[search_flag], info->s->state.key_root[inx])) + maria_read_vec[search_flag], + info->s->state.key_root[inx]) && + share->concurrent_insert) { /* If we are searching for an exact key (including the data pointer) @@ -98,50 +100,65 @@ int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len then the result is "key not found". */ if ((search_flag == HA_READ_KEY_EXACT) && - (info->lastpos >= info->state->data_file_length)) + (info->cur_row.lastpos >= info->state->data_file_length)) { my_errno= HA_ERR_KEY_NOT_FOUND; - info->lastpos= HA_OFFSET_ERROR; + info->cur_row.lastpos= HA_OFFSET_ERROR; } - else while (info->lastpos >= info->state->data_file_length) + else { - /* - Skip rows that are inserted by other threads since we got a lock - Note that this can only happen if we are not searching after an - exact key, because the keys are sorted according to position - */ - - if (_ma_search_next(info, keyinfo, info->lastkey, - info->lastkey_length, - maria_readnext_vec[search_flag], - info->s->state.key_root[inx])) - break; + while (info->cur_row.lastpos >= info->state->data_file_length) + { + /* + Skip rows that are inserted by other threads since we got a lock + Note that this can only happen if we are not searching after an + exact key, because the keys are sorted according to position + */ + + if (_ma_search_next(info, keyinfo, info->lastkey, + info->lastkey_length, + maria_readnext_vec[search_flag], + info->s->state.key_root[inx])) + { + info->cur_row.lastpos= HA_OFFSET_ERROR; + break; + } + } } } } if (share->concurrent_insert) rw_unlock(&share->key_root_lock[inx]); + if (info->cur_row.lastpos == HA_OFFSET_ERROR) + { + fast_ma_writeinfo(info); + goto err; + } + /* Calculate length of the found key; Used by maria_rnext_same */ - if ((keyinfo->flag & HA_VAR_LENGTH_KEY) && last_used_keyseg && - info->lastpos != HA_OFFSET_ERROR) + if ((keyinfo->flag & HA_VAR_LENGTH_KEY) && last_used_keyseg) info->last_rkey_length= _ma_keylength_part(keyinfo, info->lastkey, last_used_keyseg); else info->last_rkey_length= pack_key_length; + /* Check if we don't want to have record back, only error message */ if (!buf) - DBUG_RETURN(info->lastpos == HA_OFFSET_ERROR ? my_errno : 0); - - if (!(*info->read_record)(info,info->lastpos,buf)) + { + fast_ma_writeinfo(info); + DBUG_RETURN(0); + } + if (!(*info->read_record)(info, buf, info->cur_row.lastpos)) { info->update|= HA_STATE_AKTIV; /* Record is read */ DBUG_RETURN(0); } - info->lastpos = HA_OFFSET_ERROR; /* Didn't find key */ + info->cur_row.lastpos= HA_OFFSET_ERROR; /* Didn't find row */ +err: /* Store last used key as a base for read next */ memcpy(info->lastkey,key_buff,pack_key_length); info->last_rkey_length= pack_key_length; @@ -150,6 +167,5 @@ int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len if (search_flag == HA_READ_AFTER_KEY) info->update|=HA_STATE_NEXT_FOUND; /* Previous gives last row */ -err: DBUG_RETURN(my_errno); } /* _ma_rkey */ |