#include "myisam.h"#include "myisampack.h"#include <my_tree.h>#include <my_no_pthread.h>Include dependency graph for myisamdef.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
| #define BLOCK_DELETED 4 |
Definition at line 646 of file myisamdef.h.
Referenced by _mi_cmp_dynamic_record(), _mi_find_writepos(), _mi_get_block_info(), _mi_read_dynamic_record(), _mi_read_rnd_dynamic_record(), _mi_write_part_record(), delete_dynamic_record(), unlink_deleted_block(), update_backward_delete_link(), and update_dynamic_record().
| #define BLOCK_ERROR 8 |
Definition at line 647 of file myisamdef.h.
| #define BLOCK_FATAL_ERROR 32 |
Definition at line 649 of file myisamdef.h.
Referenced by _mi_cmp_dynamic_record(), _mi_pack_get_block_info(), _mi_read_dynamic_record(), _mi_read_rnd_dynamic_record(), delete_dynamic_record(), and update_dynamic_record().
| #define BLOCK_FIRST 1 |
| #define BLOCK_LAST 2 |
Definition at line 645 of file myisamdef.h.
Referenced by _mi_get_block_info(), and delete_dynamic_record().
| #define BLOCK_SYNC_ERROR 16 |
Definition at line 648 of file myisamdef.h.
Referenced by _mi_cmp_dynamic_record(), _mi_get_block_info(), _mi_read_dynamic_record(), _mi_read_rnd_dynamic_record(), delete_dynamic_record(), and update_dynamic_record().
| #define BUFFERS_WHEN_SORTING 16 |
| #define DATA_TMP_EXT ".TMD" |
Definition at line 656 of file myisamdef.h.
Referenced by compress(), make_new_name(), mi_repair(), mi_repair_by_sort(), mi_repair_parallel(), mi_sort_records(), and myisamchk().
| #define F_EXTRA_LCK -1 |
Definition at line 348 of file myisamdef.h.
Referenced by ha_myisam::external_lock(), main(), mi_close(), mi_extra(), mi_lock_database(), myisamchk(), and ha_myisam::repair().
| #define fast_mi_readinfo | ( | INFO | ) | ((INFO)->lock_type == F_UNLCK) && _mi_readinfo((INFO),F_RDLCK,1) |
Definition at line 678 of file myisamdef.h.
Referenced by mi_is_changed(), mi_records_in_range(), mi_rkey(), mi_rnext(), mi_rnext_same(), mi_rprev(), and mi_rsame().
| #define fast_mi_writeinfo | ( | INFO | ) | if (!(INFO)->s->tot_locks) (void) _mi_writeinfo((INFO),0) |
Definition at line 677 of file myisamdef.h.
Referenced by _mi_read_dynamic_record(), _mi_read_key_record(), _mi_read_rnd_dynamic_record(), _mi_read_rnd_static_record(), _mi_read_static_record(), mi_records_in_range(), and mi_status().
| #define get_key_full_length | ( | length, | |||
| key | ) |
Value:
{ if ((uchar) *(key) != 255) \
length= ((uint) (uchar) *((key)++))+1; \
else \
{ length=mi_uint2korr((key)+1)+3; (key)+=3; } \
}
Definition at line 402 of file myisamdef.h.
| #define get_key_full_length_rdonly | ( | length, | |||
| key | ) |
Value:
{ if ((uchar) *(key) != 255) \
length= ((uint) (uchar) *((key)))+1; \
else \
{ length=mi_uint2korr((key)+1)+3; } \
}
Definition at line 409 of file myisamdef.h.
Referenced by _mi_ft_convert_to_ft2(), chk_index(), d_search(), sort_ft_buf_flush(), sort_ft_key_write(), sort_one_index(), and w_search().
| #define get_pack_length | ( | length | ) | ((length) >= 255 ? 3 : 1) |
Definition at line 416 of file myisamdef.h.
Referenced by _mi_calc_bin_pack_key_length(), _mi_calc_var_pack_key_length(), _mi_prefix_search(), _mi_rec_check(), mi_repair_by_sort(), mi_repair_parallel(), and remove_key().
| #define HA_KEYSEG_SIZE (6+ 2*2 + 4*2) |
| #define INDEX_TMP_EXT ".TMM" |
| #define MAX_NONMAPPED_INSERTS 1000 |
| #define MAXERR 20 |
Definition at line 652 of file myisamdef.h.
| #define MEMMAP_EXTRA_MARGIN 7 |
Definition at line 431 of file myisamdef.h.
Referenced by chk_size(), compress(), and write_data_suffix().
| #define MEMMAP_USED 32 |
| #define MI_BASE_INFO_SIZE (5*8 + 8*4 + 4 + 4*2 + 16) |
Definition at line 102 of file myisamdef.h.
Referenced by mi_base_info_write(), mi_open(), and myisamchk().
| #define MI_BLOCK_INFO_HEADER_LENGTH 20 |
Definition at line 422 of file myisamdef.h.
Referenced by _mi_get_block_info(), _mi_read_cache(), _mi_read_dynamic_record(), and _mi_read_rnd_dynamic_record().
| #define MI_BLOCK_SIZE | ( | key_length, | |||
| data_pointer, | |||||
| key_pointer, | |||||
| block_size | ) | (((((key_length)+(data_pointer)+(key_pointer))*4+(key_pointer)+2)/(block_size)+1)*(block_size)) |
Definition at line 439 of file myisamdef.h.
| #define MI_COLUMNDEF_SIZE (2*3+1) |
| #define MI_DYN_ALIGN_SIZE 4 |
Definition at line 426 of file myisamdef.h.
Referenced by _mi_find_writepos(), _mi_get_block_info(), _mi_write_part_record(), sort_write_record(), and update_dynamic_record().
| #define MI_DYN_DELETE_BLOCK_HEADER 20 |
Definition at line 423 of file myisamdef.h.
Referenced by _mi_update_blob_record(), _mi_write_blob_record(), _mi_write_part_record(), and sort_write_record().
| #define MI_DYN_MAX_BLOCK_LENGTH ((1L << 24)-4L) |
Definition at line 424 of file myisamdef.h.
Referenced by _mi_write_part_record(), and delete_dynamic_record().
| #define MI_DYN_MAX_ROW_LENGTH (MI_DYN_MAX_BLOCK_LENGTH - MI_SPLIT_LENGTH) |
Definition at line 425 of file myisamdef.h.
Referenced by _mi_update_blob_record(), and _mi_write_blob_record().
| #define MI_EXTEND_BLOCK_LENGTH 20 |
| #define MI_FOUND_WRONG_KEY 32738 |
Definition at line 436 of file myisamdef.h.
Referenced by _mi_prefix_search(), _mi_search(), _mi_search_pos(), _mi_seq_search(), d_search(), and w_search().
Value:
((((info)->s->options & HA_OPTION_PACK_RECORD) && (buf)) ? \ (buf) - MI_REC_BUFF_OFFSET : (buf))
Definition at line 602 of file myisamdef.h.
Referenced by _mi_cmp_dynamic_unique(), and mi_close().
Definition at line 375 of file myisamdef.h.
Referenced by _mi_balance_page(), _mi_bin_search(), _mi_ck_real_delete(), _mi_fetch_keypage(), _mi_find_half_pos(), _mi_find_last_pos(), _mi_insert(), _mi_keynr(), _mi_prefix_search(), _mi_search(), _mi_search_first(), _mi_search_last(), _mi_seq_search(), _mi_split_page(), _mi_write_keypage(), chk_index(), d_search(), del(), flush_pending_blocks(), sort_insert_key(), sort_one_index(), sort_record_index(), and underflow().
| #define MI_INDEX_BLOCK_MARGIN 16 |
Definition at line 103 of file myisamdef.h.
Definition at line 381 of file myisamdef.h.
Referenced by ha_myisam::analyze(), ha_myisam::check(), ha_myisam::check_and_repair(), chk_status(), mi_close(), myisamchk(), and ha_myisam::repair().
| #define MI_KEYDEF_SIZE (2+ 5*2) |
Definition at line 379 of file myisamdef.h.
Referenced by ha_myisam::analyze(), ha_myisam::check(), mi_assign_to_key_cache(), mi_extra(), mi_lock_database(), mi_update_status(), and myisamchk().
Definition at line 428 of file myisamdef.h.
Referenced by _mi_find_writepos(), _mi_write_part_record(), sort_write_record(), and update_dynamic_record().
| #define MI_MAX_DYN_BLOCK_HEADER 20 |
Definition at line 421 of file myisamdef.h.
Referenced by _mi_update_blob_record(), _mi_write_blob_record(), mi_alloc_rec_buff(), and sort_write_record().
| #define MI_MAX_DYN_HEADER_BYTE 13 |
Definition at line 427 of file myisamdef.h.
| #define MI_MAX_KEY_BLOCK_SIZE (MI_MAX_KEY_BLOCK_LENGTH/MI_MIN_KEY_BLOCK_LENGTH) |
| #define MI_MAX_KEYPTR_SIZE 5 |
Definition at line 440 of file myisamdef.h.
| #define MI_MIN_BLOCK_LENGTH 20 |
Definition at line 418 of file myisamdef.h.
Referenced by _mi_get_block_info(), delete_dynamic_record(), underflow(), and update_dynamic_record().
| #define MI_MIN_KEYBLOCK_LENGTH 50 |
| #define MI_MIN_ROWS_TO_DISABLE_INDEXES 100 |
Definition at line 445 of file myisamdef.h.
Referenced by mi_disable_non_unique_index(), and ha_myisam::start_bulk_insert().
| #define MI_MIN_ROWS_TO_USE_BULK_INSERT 100 |
Definition at line 444 of file myisamdef.h.
Referenced by mi_init_bulk_insert(), and ha_myisam::start_bulk_insert().
| #define MI_MIN_ROWS_TO_USE_WRITE_CACHE 10 |
| #define MI_MIN_SIZE_BULK_INSERT_TREE 16384 |
Definition at line 443 of file myisamdef.h.
| #define mi_print_error | ( | SHARE, | |||
| ERRNO | ) | mi_report_error((ERRNO), (SHARE)->index_file_name) |
Definition at line 383 of file myisamdef.h.
Referenced by _mi_ck_real_delete(), _mi_fetch_keypage(), _mi_find_last_pos(), _mi_get_binary_pack_key(), _mi_get_key(), _mi_get_last_key(), _mi_get_pack_key(), _mi_get_prev_key(), _mi_insert(), _mi_prefix_search(), _mi_read_key_record(), _mi_seq_search(), d_search(), mi_assign_to_key_cache(), mi_delete(), mi_enable_indexes(), mi_extra(), mi_lock_database(), mi_rkey(), mi_update(), mi_update_status(), and mi_write().
| #define mi_putint | ( | x, | |||
| y, | |||||
| nod | ) |
Value:
{ uint16 boh=(nod ? (uint16) 32768 : 0) + (uint16) (y);\
mi_int2store(x,boh); }
Definition at line 376 of file myisamdef.h.
Referenced by _mi_balance_page(), _mi_enlarge_root(), _mi_ft_convert_to_ft2(), _mi_insert(), _mi_split_page(), d_search(), del(), sort_insert_key(), and underflow().
| #define MI_REC_BUFF_OFFSET ALIGN_SIZE(MI_DYN_DELETE_BLOCK_HEADER+sizeof(uint32)) |
| #define MI_SPLIT_LENGTH ((MI_EXTEND_BLOCK_LENGTH+4)*2) |
Definition at line 420 of file myisamdef.h.
Referenced by _mi_update_blob_record(), _mi_write_blob_record(), _mi_write_part_record(), mi_alloc_rec_buff(), and sort_write_record().
| #define MI_STATE_EXTRA_SIZE ((MI_MAX_KEY+MI_MAX_KEY_BLOCK_SIZE)*MI_STATE_KEY_SIZE + MI_MAX_KEY*MI_MAX_KEY_SEG*MI_STATE_KEYSEG_SIZE) |
Definition at line 97 of file myisamdef.h.
Referenced by mi_state_info_read_dsk(), and mi_state_info_write().
| #define MI_STATE_INFO_SIZE (24+14*8+7*4+2*2+8) |
Definition at line 93 of file myisamdef.h.
Referenced by mi_open(), mi_state_info_read_dsk(), mi_state_info_write(), and myisamchk().
| #define MI_STATE_KEY_SIZE 8 |
Definition at line 94 of file myisamdef.h.
| #define MI_STATE_KEYBLOCK_SIZE 8 |
Definition at line 95 of file myisamdef.h.
| #define MI_STATE_KEYSEG_SIZE 4 |
Definition at line 96 of file myisamdef.h.
Definition at line 378 of file myisamdef.h.
Referenced by _mi_balance_page(), _mi_bin_search(), _mi_ck_real_delete(), _mi_get_key(), _mi_get_last_key(), _mi_get_prev_key(), _mi_insert(), _mi_keynr(), _mi_prefix_search(), _mi_search(), _mi_search_first(), _mi_search_last(), _mi_search_next(), _mi_search_pos(), _mi_seq_search(), _mi_split_page(), chk_index(), d_search(), del(), mi_preload(), movepoint(), sort_one_index(), sort_record_index(), underflow(), and w_search().
| #define MI_UNIQUE_HASH_TYPE HA_KEYTYPE_ULONG_INT |
Definition at line 450 of file myisamdef.h.
| #define MI_UNIQUEDEF_SIZE (2+1+1) |
| #define MIN_SORT_BUFFER (4096-MALLOC_OVERHEAD) |
Definition at line 667 of file myisamdef.h.
| #define myisam_log | ( | a, | |||
| b, | |||||
| c, | |||||
| d | ) | if (myisam_log_file >= 0) _myisam_log(a,b,c,d) |
Definition at line 673 of file myisamdef.h.
| #define myisam_log_command | ( | a, | |||
| b, | |||||
| c, | |||||
| d, | |||||
| e | ) | if (myisam_log_file >= 0) _myisam_log_command(a,b,c,d,e) |
Definition at line 674 of file myisamdef.h.
Referenced by mi_close(), mi_delete_all_rows(), and mi_lock_database().
| #define myisam_log_record | ( | a, | |||
| b, | |||||
| c, | |||||
| d, | |||||
| e | ) | if (myisam_log_file >= 0) _myisam_log_record(a,b,c,d,e) |
Definition at line 675 of file myisamdef.h.
| #define NEED_MEM ((uint) 10*4*(IO_SIZE+32)+32) |
Definition at line 651 of file myisamdef.h.
| #define PACK_TYPE_SELECTED 1 |
Definition at line 433 of file myisamdef.h.
Referenced by compress_isam_file(), descript(), get_unpack_function(), and test_space_compress().
| #define PACK_TYPE_SPACE_FIELDS 2 |
Definition at line 434 of file myisamdef.h.
Referenced by compress_isam_file(), descript(), and get_unpack_function().
| #define PACK_TYPE_ZERO_FILL 4 |
Definition at line 435 of file myisamdef.h.
Referenced by compress_isam_file(), descript(), get_unpack_function(), and write_field_info().
| #define READ_BUFFER_INIT (1024L*256L-MALLOC_OVERHEAD) |
| #define READING_HEADER 2 |
Definition at line 373 of file myisamdef.h.
Referenced by _mi_read_cache(), and _mi_read_rnd_dynamic_record().
| #define READING_NEXT 1 |
Definition at line 372 of file myisamdef.h.
Referenced by _mi_read_cache(), and _mi_read_rnd_dynamic_record().
| #define REMEMBER_OLD_POS 64 |
| #define RRND_PRESERVE_LASTINX 2 |
| #define rw_rdlock | ( | A | ) | {} |
Definition at line 458 of file myisamdef.h.
| #define rw_unlock | ( | A | ) | {} |
Definition at line 459 of file myisamdef.h.
| #define rw_wrlock | ( | A | ) | {} |
Definition at line 457 of file myisamdef.h.
| #define SORT_BUFFER_INIT (2048L*1024L-MALLOC_OVERHEAD) |
| #define STATE_CHANGED 1 |
Definition at line 363 of file myisamdef.h.
Referenced by _mi_mark_file_changed(), ha_myisam::check(), descript(), mi_extra(), myisamchk(), ha_myisam::repair(), and save_state_mrg().
| #define STATE_CRASHED 2 |
Definition at line 364 of file myisamdef.h.
Referenced by ha_myisam::check(), descript(), ha_myisam::is_crashed(), mi_open(), myisamchk(), and ha_myisam::repair().
| #define STATE_CRASHED_ON_REPAIR 4 |
Definition at line 365 of file myisamdef.h.
Referenced by ha_myisam::check(), mi_open(), myisamchk(), and ha_myisam::repair().
| #define STATE_NOT_ANALYZED 8 |
Definition at line 366 of file myisamdef.h.
Referenced by _mi_mark_file_changed(), ha_myisam::analyze(), ha_myisam::check(), descript(), mi_extra(), myisamchk(), ha_myisam::repair(), save_state_mrg(), and update_state_info().
| #define STATE_NOT_OPTIMIZED_KEYS 16 |
Definition at line 367 of file myisamdef.h.
Referenced by _mi_mark_file_changed(), descript(), myisamchk(), and ha_myisam::repair().
| #define STATE_NOT_SORTED_PAGES 32 |
Definition at line 368 of file myisamdef.h.
Referenced by _mi_dispose(), _mi_new(), descript(), mi_sort_index(), myisamchk(), and ha_myisam::repair().
| #define store_key_length | ( | key, | |||
| length | ) |
Value:
{ if ((length) < 255) \
{ *(key)=(length); } \
else \
{ *(key)=255; mi_int2store((key)+1,(length)); } \
}
Definition at line 395 of file myisamdef.h.
Referenced by _mi_prefix_search(), _mi_store_var_pack_key(), and remove_key().
| #define store_key_length_inc | ( | key, | |||
| length | ) |
Value:
{ if ((length) < 255) \
{ *(key)++=(length); } \
else \
{ *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
}
Definition at line 388 of file myisamdef.h.
| #define UPDATE_AUTO_INC 8 |
Definition at line 661 of file myisamdef.h.
Referenced by myisamchk(), update_auto_increment_key(), and update_state_info().
| #define UPDATE_OPEN_COUNT 16 |
Definition at line 662 of file myisamdef.h.
Referenced by ha_myisam::check(), myisamchk(), recreate_table(), ha_myisam::repair(), and update_state_info().
| #define UPDATE_SORT 4 |
| #define UPDATE_STAT 2 |
Definition at line 659 of file myisamdef.h.
Referenced by ha_myisam::analyze(), ha_myisam::check(), myisamchk(), recreate_table(), ha_myisam::repair(), and update_state_info().
| #define UPDATE_TIME 1 |
Definition at line 658 of file myisamdef.h.
Referenced by ha_myisam::check(), myisamchk(), recreate_table(), ha_myisam::repair(), and update_state_info().
| #define USE_BUFFER_INIT (((1024L*512L-MALLOC_OVERHEAD)/IO_SIZE)*IO_SIZE) |
| #define USE_PACKED_KEYS 1 |
| #define USE_WHOLE_KEY MI_MAX_KEY_BUFF*2 |
Definition at line 347 of file myisamdef.h.
Referenced by _ft2_search(), _mi_insert(), _mi_record_pos(), _mi_search(), _mi_search_next(), _mi_search_pos(), chk_index(), d_search(), keys_compare(), main(), mi_collect_stats_nonulls_next(), mi_repair(), mi_rkey(), mi_rnext(), mi_rprev(), mi_rsame(), movepoint(), queue_key_cmp(), sort_key_cmp(), sort_key_write(), and w_search().
| #define WRITE_COUNT MY_HOW_OFTEN_TO_WRITE |
| #define WRITEINFO_NO_UNLOCK 2 |
| #define WRITEINFO_UPDATE_KEYFILE 1 |
Definition at line 354 of file myisamdef.h.
Referenced by mi_delete_all_rows(), and mi_sort_index().
| typedef struct st_buffpek BUFFPEK |
| typedef struct st_mi_base_info MI_BASE_INFO |
| typedef struct st_mi_bit_buff MI_BIT_BUFF |
| typedef uint mi_bit_type |
Definition at line 224 of file myisamdef.h.
| typedef struct st_mi_blob MI_BLOB |
| typedef struct st_mi_block_info MI_BLOCK_INFO |
| typedef struct st_mi_s_param MI_KEY_PARAM |
| typedef struct st_mi_isam_pack MI_PACK |
| typedef struct st_mi_sort_param MI_SORT_PARAM |
| typedef struct st_mi_state_info MI_STATE_INFO |
| typedef struct st_mi_status_info MI_STATUS_INFO |
| typedef struct st_mi_isam_share MYISAM_SHARE |
| enum myisam_log_commands |
| MI_LOG_OPEN | |
| MI_LOG_WRITE | |
| MI_LOG_UPDATE | |
| MI_LOG_DELETE | |
| MI_LOG_CLOSE | |
| MI_LOG_EXTRA | |
| MI_LOG_LOCK | |
| MI_LOG_DELETE_ALL |
Definition at line 669 of file myisamdef.h.
00669 { 00670 MI_LOG_OPEN,MI_LOG_WRITE,MI_LOG_UPDATE,MI_LOG_DELETE,MI_LOG_CLOSE,MI_LOG_EXTRA,MI_LOG_LOCK,MI_LOG_DELETE_ALL 00671 };
| int _create_index_by_sort | ( | MI_SORT_PARAM * | info, | |
| my_bool | no_messages, | |||
| ulong | ||||
| ) |
Definition at line 104 of file sort.c.
References _mi_ck_write(), bzero, close_cached_file(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, delete_dynamic(), dynamic_element, err, error, find_all_keys(), st_mi_keydef::flag, flush_ft_buf(), flush_io_cache, flush_pending_blocks(), HA_FT_MAXBYTELEN, HA_POS_ERROR, HA_VAR_LENGTH_KEY, index(), st_sort_info::info, st_mi_sort_param::key, st_mi_sort_param::key_length, key_length, st_mi_sort_param::keyinfo, keys, LINT_INIT, st_mi_sort_param::lock_in_memory, max, st_sort_info::max_records, merge_index(), merge_many_buff(), MERGEBUFF2, mi_check_print_error(), MIN_SORT_MEMORY, my_b_clear, my_b_inited, my_b_read, my_free, my_init_dynamic_array, my_malloc(), MYF, NULL, st_sort_info::param, READ_CACHE, st_mi_sort_param::read_to_buffer, read_to_buffer(), read_to_buffer_varlen(), records, reinit_io_cache(), st_mi_sort_param::sort_info, sort_keys(), write_index(), st_mi_sort_param::write_key, st_mi_sort_param::write_keys, write_keys(), write_keys_varlen(), write_merge_key(), and write_merge_key_varlen().
00106 { 00107 int error,maxbuffer,skr; 00108 uint memavl,old_memavl,keys,sort_length; 00109 DYNAMIC_ARRAY buffpek; 00110 ha_rows records; 00111 uchar **sort_keys; 00112 IO_CACHE tempfile, tempfile_for_exceptions; 00113 DBUG_ENTER("_create_index_by_sort"); 00114 DBUG_PRINT("enter",("sort_length: %d", info->key_length)); 00115 00116 if (info->keyinfo->flag & HA_VAR_LENGTH_KEY) 00117 { 00118 info->write_keys=write_keys_varlen; 00119 info->read_to_buffer=read_to_buffer_varlen; 00120 info->write_key=write_merge_key_varlen; 00121 } 00122 else 00123 { 00124 info->write_keys=write_keys; 00125 info->read_to_buffer=read_to_buffer; 00126 info->write_key=write_merge_key; 00127 } 00128 00129 my_b_clear(&tempfile); 00130 my_b_clear(&tempfile_for_exceptions); 00131 bzero((char*) &buffpek,sizeof(buffpek)); 00132 sort_keys= (uchar **) NULL; error= 1; 00133 maxbuffer=1; 00134 00135 memavl=max(sortbuff_size,MIN_SORT_MEMORY); 00136 records= info->sort_info->max_records; 00137 sort_length= info->key_length; 00138 LINT_INIT(keys); 00139 00140 while (memavl >= MIN_SORT_MEMORY) 00141 { 00142 if ((my_off_t) (records+1)*(sort_length+sizeof(char*)) <= 00143 (my_off_t) memavl) 00144 keys= records+1; 00145 else 00146 do 00147 { 00148 skr=maxbuffer; 00149 if (memavl < sizeof(BUFFPEK)*(uint) maxbuffer || 00150 (keys=(memavl-sizeof(BUFFPEK)*(uint) maxbuffer)/ 00151 (sort_length+sizeof(char*))) <= 1) 00152 { 00153 mi_check_print_error(info->sort_info->param, 00154 "sort_buffer_size is to small"); 00155 goto err; 00156 } 00157 } 00158 while ((maxbuffer= (int) (records/(keys-1)+1)) != skr); 00159 00160 if ((sort_keys=(uchar **)my_malloc(keys*(sort_length+sizeof(char*))+ 00161 HA_FT_MAXBYTELEN, MYF(0)))) 00162 { 00163 if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer, 00164 maxbuffer/2)) 00165 { 00166 my_free((gptr) sort_keys,MYF(0)); 00167 sort_keys= 0; 00168 } 00169 else 00170 break; 00171 } 00172 old_memavl=memavl; 00173 if ((memavl=memavl/4*3) < MIN_SORT_MEMORY && old_memavl > MIN_SORT_MEMORY) 00174 memavl=MIN_SORT_MEMORY; 00175 } 00176 if (memavl < MIN_SORT_MEMORY) 00177 { 00178 mi_check_print_error(info->sort_info->param,"Sort buffer to small"); /* purecov: tested */ 00179 goto err; /* purecov: tested */ 00180 } 00181 (*info->lock_in_memory)(info->sort_info->param);/* Everything is allocated */ 00182 00183 if (!no_messages) 00184 printf(" - Searching for keys, allocating buffer for %d keys\n",keys); 00185 00186 if ((records=find_all_keys(info,keys,sort_keys,&buffpek,&maxbuffer, 00187 &tempfile,&tempfile_for_exceptions)) 00188 == HA_POS_ERROR) 00189 goto err; /* purecov: tested */ 00190 if (maxbuffer == 0) 00191 { 00192 if (!no_messages) 00193 printf(" - Dumping %lu keys\n", (ulong) records); 00194 if (write_index(info,sort_keys, (uint) records)) 00195 goto err; /* purecov: inspected */ 00196 } 00197 else 00198 { 00199 keys=(keys*(sort_length+sizeof(char*)))/sort_length; 00200 if (maxbuffer >= MERGEBUFF2) 00201 { 00202 if (!no_messages) 00203 printf(" - Merging %lu keys\n", (ulong) records); /* purecov: tested */ 00204 if (merge_many_buff(info,keys,sort_keys, 00205 dynamic_element(&buffpek,0,BUFFPEK *),&maxbuffer,&tempfile)) 00206 goto err; /* purecov: inspected */ 00207 } 00208 if (flush_io_cache(&tempfile) || 00209 reinit_io_cache(&tempfile,READ_CACHE,0L,0,0)) 00210 goto err; /* purecov: inspected */ 00211 if (!no_messages) 00212 printf(" - Last merge and dumping keys\n"); /* purecov: tested */ 00213 if (merge_index(info,keys,sort_keys,dynamic_element(&buffpek,0,BUFFPEK *), 00214 maxbuffer,&tempfile)) 00215 goto err; /* purecov: inspected */ 00216 } 00217 00218 if (flush_ft_buf(info) || flush_pending_blocks(info)) 00219 goto err; 00220 00221 if (my_b_inited(&tempfile_for_exceptions)) 00222 { 00223 MI_INFO *index=info->sort_info->info; 00224 uint keyno=info->key; 00225 uint key_length, ref_length=index->s->rec_reflength; 00226 00227 if (!no_messages) 00228 printf(" - Adding exceptions\n"); /* purecov: tested */ 00229 if (flush_io_cache(&tempfile_for_exceptions) || 00230 reinit_io_cache(&tempfile_for_exceptions,READ_CACHE,0L,0,0)) 00231 goto err; 00232 00233 while (!my_b_read(&tempfile_for_exceptions,(byte*)&key_length, 00234 sizeof(key_length)) 00235 && !my_b_read(&tempfile_for_exceptions,(byte*)sort_keys, 00236 (uint) key_length)) 00237 { 00238 if (_mi_ck_write(index,keyno,(uchar*) sort_keys,key_length-ref_length)) 00239 goto err; 00240 } 00241 } 00242 00243 error =0; 00244 00245 err: 00246 if (sort_keys) 00247 my_free((gptr) sort_keys,MYF(0)); 00248 delete_dynamic(&buffpek); 00249 close_cached_file(&tempfile); 00250 close_cached_file(&tempfile_for_exceptions); 00251 00252 DBUG_RETURN(error ? -1 : 0); 00253 } /* _create_index_by_sort */
Here is the call graph for this function:

| int _mi_bin_search | ( | struct st_myisam_info * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | page, | |||
| uchar * | key, | |||
| uint | key_len, | |||
| uint | comp_flag, | |||
| uchar ** | ret_pos, | |||
| uchar * | buff, | |||
| my_bool * | was_last_key | |||
| ) |
| int _mi_calc_bin_pack_key_length | ( | MI_KEYDEF * | keyinfo, | |
| uint | nod_flag, | |||
| uchar * | key_pos, | |||
| uchar * | org_key, | |||
| uchar * | prev_key, | |||
| uchar * | key, | |||
| MI_KEY_PARAM * | s_temp | |||
| ) |
Definition at line 1718 of file mi_search.c.
References _mi_keylength(), get_key_pack_length, get_pack_length, st_mi_s_param::key, key_length, keyinfo, st_mi_s_param::n_length, st_mi_s_param::n_ref_length, st_mi_s_param::next_key_pos, st_mi_s_param::prev_key, st_mi_s_param::prev_length, st_mi_s_param::ref_length, and st_mi_s_param::totlength.
Referenced by setup_key_functions().
01721 { 01722 uint length,key_length,ref_length; 01723 01724 s_temp->totlength=key_length=_mi_keylength(keyinfo,key)+nod_flag; 01725 #ifdef HAVE_purify 01726 s_temp->n_length= s_temp->n_ref_length=0; /* For valgrind */ 01727 #endif 01728 s_temp->key=key; 01729 s_temp->prev_key=org_key; 01730 if (prev_key) /* If not first key in block */ 01731 { 01732 /* pack key against previous key */ 01733 /* 01734 As keys may be identical when running a sort in myisamchk, we 01735 have to guard against the case where keys may be identical 01736 */ 01737 uchar *end; 01738 end=key+key_length; 01739 for ( ; *key == *prev_key && key < end; key++,prev_key++) ; 01740 s_temp->ref_length= ref_length=(uint) (key-s_temp->key); 01741 length=key_length - ref_length + get_pack_length(ref_length); 01742 } 01743 else 01744 { 01745 /* No previous key */ 01746 s_temp->ref_length=ref_length=0; 01747 length=key_length+1; 01748 } 01749 if ((s_temp->next_key_pos=next_key)) /* If another key after */ 01750 { 01751 /* pack key against next key */ 01752 uint next_length,next_length_pack; 01753 get_key_pack_length(next_length,next_length_pack,next_key); 01754 01755 /* If first key and next key is packed (only on delete) */ 01756 if (!prev_key && org_key && next_length) 01757 { 01758 uchar *end; 01759 for (key= s_temp->key, end=key+next_length ; 01760 *key == *org_key && key < end; 01761 key++,org_key++) ; 01762 ref_length= (uint) (key - s_temp->key); 01763 } 01764 01765 if (next_length > ref_length) 01766 { 01767 /* We put a key with different case between two keys with the same prefix 01768 Extend next key to have same prefix as 01769 this key */ 01770 s_temp->n_ref_length= ref_length; 01771 s_temp->prev_length= next_length-ref_length; 01772 s_temp->prev_key+= ref_length; 01773 return (int) (length+ s_temp->prev_length - next_length_pack + 01774 get_pack_length(ref_length)); 01775 } 01776 /* Check how many characters are identical to next key */ 01777 key= s_temp->key+next_length; 01778 while (*key++ == *next_key++) ; 01779 if ((ref_length= (uint) (key - s_temp->key)-1) == next_length) 01780 { 01781 s_temp->next_key_pos=0; 01782 return length; /* can't pack next key */ 01783 } 01784 s_temp->prev_length=0; 01785 s_temp->n_ref_length=ref_length; 01786 return (int) (length-(ref_length - next_length) - next_length_pack + 01787 get_pack_length(ref_length)); 01788 } 01789 return (int) length; 01790 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_calc_static_key_length | ( | MI_KEYDEF * | keyinfo, | |
| uint | nod_flag, | |||
| uchar * | key_pos, | |||
| uchar * | org_key, | |||
| uchar * | key_buff, | |||
| uchar * | key, | |||
| MI_KEY_PARAM * | s_temp | |||
| ) |
| int _mi_calc_var_key_length | ( | MI_KEYDEF * | keyinfo, | |
| uint | nod_flag, | |||
| uchar * | key_pos, | |||
| uchar * | org_key, | |||
| uchar * | key_buff, | |||
| uchar * | key, | |||
| MI_KEY_PARAM * | s_temp | |||
| ) |
| int _mi_calc_var_pack_key_length | ( | MI_KEYDEF * | keyinfo, | |
| uint | nod_flag, | |||
| uchar * | key_pos, | |||
| uchar * | org_key, | |||
| uchar * | prev_key, | |||
| uchar * | key, | |||
| MI_KEY_PARAM * | s_temp | |||
| ) |
Definition at line 1436 of file mi_search.c.
References _mi_keylength(), DBUG_PRINT, st_mi_keydef::flag, get_key_length, get_key_pack_length, get_pack_length, HA_FULLTEXT, HA_KEYTYPE_TEXT, HA_KEYTYPE_VARTEXT1, HA_KEYTYPE_VARTEXT2, HA_NULL_PART, int(), st_mi_s_param::key, key_end(), st_mi_s_param::key_length, key_length, keyinfo, keyseg, mi_uint2korr, st_mi_s_param::n_length, st_mi_s_param::n_ref_length, st_mi_s_param::next_key_pos, st_mi_s_param::pack_marker, st_mi_s_param::part_of_prev_key, st_mi_s_param::prev_key, st_mi_s_param::prev_length, st_mi_s_param::ref_length, reg1, st_mi_keydef::seg, sort_order, start(), st_mi_s_param::store_not_null, st_mi_s_param::totlength, and use_strnxfrm.
Referenced by setup_key_functions().
01439 { 01440 reg1 HA_KEYSEG *keyseg; 01441 int length; 01442 uint key_length,ref_length,org_key_length=0, 01443 length_pack,new_key_length,diff_flag,pack_marker; 01444 uchar *start,*end,*key_end,*sort_order; 01445 bool same_length; 01446 01447 length_pack=s_temp->ref_length=s_temp->n_ref_length=s_temp->n_length=0; 01448 same_length=0; keyseg=keyinfo->seg; 01449 key_length=_mi_keylength(keyinfo,key)+nod_flag; 01450 01451 sort_order=0; 01452 if ((keyinfo->flag & HA_FULLTEXT) && 01453 ((keyseg->type == HA_KEYTYPE_TEXT) || 01454 (keyseg->type == HA_KEYTYPE_VARTEXT1) || 01455 (keyseg->type == HA_KEYTYPE_VARTEXT2)) && 01456 !use_strnxfrm(keyseg->charset)) 01457 sort_order=keyseg->charset->sort_order; 01458 01459 /* diff flag contains how many bytes is needed to pack key */ 01460 if (keyseg->length >= 127) 01461 { 01462 diff_flag=2; 01463 pack_marker=32768; 01464 } 01465 else 01466 { 01467 diff_flag= 1; 01468 pack_marker=128; 01469 } 01470 s_temp->pack_marker=pack_marker; 01471 01472 /* Handle the case that the first part have NULL values */ 01473 if (keyseg->flag & HA_NULL_PART) 01474 { 01475 if (!*key++) 01476 { 01477 s_temp->key=key; 01478 s_temp->key_length= 0; 01479 s_temp->totlength=key_length-1+diff_flag; 01480 s_temp->next_key_pos=0; /* No next key */ 01481 return (s_temp->totlength); 01482 } 01483 s_temp->store_not_null=1; 01484 key_length--; /* We don't store NULL */ 01485 if (prev_key && !*prev_key++) 01486 org_key=prev_key=0; /* Can't pack against prev */ 01487 else if (org_key) 01488 org_key++; /* Skip NULL */ 01489 } 01490 else 01491 s_temp->store_not_null=0; 01492 s_temp->prev_key=org_key; 01493 01494 /* The key part will start with a packed length */ 01495 01496 get_key_pack_length(new_key_length,length_pack,key); 01497 end=key_end= key+ new_key_length; 01498 start=key; 01499 01500 /* Calc how many characters are identical between this and the prev. key */ 01501 if (prev_key) 01502 { 01503 get_key_length(org_key_length,prev_key); 01504 s_temp->prev_key=prev_key; /* Pointer at data */ 01505 /* Don't use key-pack if length == 0 */ 01506 if (new_key_length && new_key_length == org_key_length) 01507 same_length=1; 01508 else if (new_key_length > org_key_length) 01509 end=key + org_key_length; 01510 01511 if (sort_order) /* SerG */ 01512 { 01513 while (key < end && sort_order[*key] == sort_order[*prev_key]) 01514 { 01515 key++; prev_key++; 01516 } 01517 } 01518 else 01519 { 01520 while (key < end && *key == *prev_key) 01521 { 01522 key++; prev_key++; 01523 } 01524 } 01525 } 01526 01527 s_temp->key=key; 01528 s_temp->key_length= (uint) (key_end-key); 01529 01530 if (same_length && key == key_end) 01531 { 01532 /* identical variable length key */ 01533 s_temp->ref_length= pack_marker; 01534 length=(int) key_length-(int) (key_end-start)-length_pack; 01535 length+= diff_flag; 01536 if (next_key) 01537 { /* Can't combine with next */ 01538 s_temp->n_length= *next_key; /* Needed by _mi_store_key */ 01539 next_key=0; 01540 } 01541 } 01542 else 01543 { 01544 if (start != key) 01545 { /* Starts as prev key */ 01546 ref_length= (uint) (key-start); 01547 s_temp->ref_length= ref_length + pack_marker; 01548 length= (int) (key_length - ref_length); 01549 01550 length-= length_pack; 01551 length+= diff_flag; 01552 length+= ((new_key_length-ref_length) >= 255) ? 3 : 1;/* Rest_of_key */ 01553 } 01554 else 01555 { 01556 s_temp->key_length+=s_temp->store_not_null; /* If null */ 01557 length= key_length - length_pack+ diff_flag; 01558 } 01559 } 01560 s_temp->totlength=(uint) length; 01561 s_temp->prev_length=0; 01562 DBUG_PRINT("test",("tot_length: %u length: %d uniq_key_length: %u", 01563 key_length, length, s_temp->key_length)); 01564 01565 /* If something after that hasn't length=0, test if we can combine */ 01566 if ((s_temp->next_key_pos=next_key)) 01567 { 01568 uint packed,n_length; 01569 01570 packed = *next_key & 128; 01571 if (diff_flag == 2) 01572 { 01573 n_length= mi_uint2korr(next_key) & 32767; /* Length of next key */ 01574 next_key+=2; 01575 } 01576 else 01577 n_length= *next_key++ & 127; 01578 if (!packed) 01579 n_length-= s_temp->store_not_null; 01580 01581 if (n_length || packed) /* Don't pack 0 length keys */ 01582 { 01583 uint next_length_pack, new_ref_length=s_temp->ref_length; 01584 01585 if (packed) 01586 { 01587 /* If first key and next key is packed (only on delete) */ 01588 if (!prev_key && org_key) 01589 { 01590 get_key_length(org_key_length,org_key); 01591 key=start; 01592 if (sort_order) /* SerG */ 01593 { 01594 while (key < end && sort_order[*key] == sort_order[*org_key]) 01595 { 01596 key++; org_key++; 01597 } 01598 } 01599 else 01600 { 01601 while (key < end && *key == *org_key) 01602 { 01603 key++; org_key++; 01604 } 01605 } 01606 if ((new_ref_length= (uint) (key - start))) 01607 new_ref_length+=pack_marker; 01608 } 01609 01610 if (!n_length) 01611 { 01612 /* 01613 We put a different key between two identical variable length keys 01614 Extend next key to have same prefix as this key 01615 */ 01616 if (new_ref_length) /* prefix of previus key */ 01617 { /* make next key longer */ 01618 s_temp->part_of_prev_key= new_ref_length; 01619 s_temp->prev_length= org_key_length - 01620 (new_ref_length-pack_marker); 01621 s_temp->n_ref_length= s_temp->part_of_prev_key; 01622 s_temp->n_length= s_temp->prev_length; 01623 n_length= get_pack_length(s_temp->prev_length); 01624 s_temp->prev_key+= (new_ref_length - pack_marker); 01625 length+= s_temp->prev_length + n_length; 01626 } 01627 else 01628 { /* Can't use prev key */ 01629 s_temp->part_of_prev_key=0; 01630 s_temp->prev_length= org_key_length; 01631 s_temp->n_ref_length=s_temp->n_length= org_key_length; 01632 length+= org_key_length; 01633 } 01634 return (int) length; 01635 } 01636 01637 ref_length=n_length; 01638 /* Get information about not packed key suffix */ 01639 get_key_pack_length(n_length,next_length_pack,next_key); 01640 01641 /* Test if new keys has fewer characters that match the previous key */ 01642 if (!new_ref_length) 01643 { /* Can't use prev key */ 01644 s_temp->part_of_prev_key= 0; 01645 s_temp->prev_length= ref_length; 01646 s_temp->n_ref_length= s_temp->n_length= n_length+ref_length; 01647 return (int) length+ref_length-next_length_pack; 01648 } 01649 if (ref_length+pack_marker > new_ref_length) 01650 { 01651 uint new_pack_length=new_ref_length-pack_marker; 01652 /* We must copy characters from the original key to the next key */ 01653 s_temp->part_of_prev_key= new_ref_length; 01654 s_temp->prev_length= ref_length - new_pack_length; 01655 s_temp->n_ref_length=s_temp->n_length=n_length + s_temp->prev_length; 01656 s_temp->prev_key+= new_pack_length; 01657 length-= (next_length_pack - get_pack_length(s_temp->n_length)); 01658 return (int) length + s_temp->prev_length; 01659 } 01660 } 01661 else 01662 { 01663 /* Next key wasn't a prefix of previous key */ 01664 ref_length=0; 01665 next_length_pack=0; 01666 } 01667 DBUG_PRINT("test",("length: %d next_key: 0x%lx", length, 01668 (long) next_key)); 01669 01670 { 01671 uint tmp_length; 01672 key=(start+=ref_length); 01673 if (key+n_length < key_end) /* Normalize length based */ 01674 key_end=key+n_length; 01675 if (sort_order) /* SerG */ 01676 { 01677 while (key < key_end && sort_order[*key] == 01678 sort_order[*next_key]) 01679 { 01680 key++; next_key++; 01681 } 01682 } 01683 else 01684 { 01685 while (key < key_end && *key == *next_key) 01686 { 01687 key++; next_key++; 01688 } 01689 } 01690 if (!(tmp_length=(uint) (key-start))) 01691 { /* Key can't be re-packed */ 01692 s_temp->next_key_pos=0; 01693 return length; 01694 } 01695 ref_length+=tmp_length; 01696 n_length-=tmp_length; 01697 length-=tmp_length+next_length_pack; /* We gained these chars */ 01698 } 01699 if (n_length == 0 && ref_length == new_key_length) 01700 { 01701 s_temp->n_ref_length=pack_marker; /* Same as prev key */ 01702 } 01703 else 01704 { 01705 s_temp->n_ref_length=ref_length | pack_marker; 01706 length+= get_pack_length(n_length); 01707 s_temp->n_length=n_length; 01708 } 01709 } 01710 } 01711 return length; 01712 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_check_index | ( | MI_INFO * | info, | |
| int | inx | |||
| ) |
Definition at line 28 of file mi_search.c.
References flush_io_cache, HA_ERR_WRONG_INDEX, HA_STATE_CHANGED, HA_STATE_NEXT_FOUND, HA_STATE_PREV_FOUND, HA_STATE_ROW_CHANGED, st_mi_state_info::key_map, st_myisam_info::lastinx, mi_is_key_active, my_errno, st_myisam_info::opt_flag, st_myisam_info::page_changed, st_myisam_info::rec_cache, st_myisam_info::s, st_mi_isam_share::state, st_myisam_info::update, and WRITE_CACHE_USED.
Referenced by ft_boolean_read_next(), ft_init_nlq_search(), mi_records_in_range(), mi_rkey(), mi_rnext(), and mi_rprev().
00029 { 00030 if (inx == -1) /* Use last index */ 00031 inx=info->lastinx; 00032 if (inx < 0 || ! mi_is_key_active(info->s->state.key_map, inx)) 00033 { 00034 my_errno=HA_ERR_WRONG_INDEX; 00035 return -1; 00036 } 00037 if (info->lastinx != inx) /* Index changed */ 00038 { 00039 info->lastinx = inx; 00040 info->page_changed=1; 00041 info->update= ((info->update & (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED)) | 00042 HA_STATE_NEXT_FOUND | HA_STATE_PREV_FOUND); 00043 } 00044 if (info->opt_flag & WRITE_CACHE_USED && flush_io_cache(&info->rec_cache)) 00045 return(-1); 00046 return(inx); 00047 } /* mi_check_index */
Here is the caller graph for this function:

| int _mi_ck_real_write_btree | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | key, | |||
| uint | key_length, | |||
| my_off_t * | root, | |||
| uint | comp_flag | |||
| ) |
Definition at line 296 of file mi_write.c.
References _mi_enlarge_root(), DBUG_ENTER, DBUG_RETURN, error, HA_OFFSET_ERROR, keyinfo, and w_search().
Referenced by _mi_ck_write_btree(), _mi_ft_convert_to_ft2(), and w_search().
00298 { 00299 int error; 00300 DBUG_ENTER("_mi_ck_real_write_btree"); 00301 /* key_length parameter is used only if comp_flag is SEARCH_FIND */ 00302 if (*root == HA_OFFSET_ERROR || 00303 (error=w_search(info, keyinfo, comp_flag, key, key_length, 00304 *root, (uchar *) 0, (uchar*) 0, 00305 (my_off_t) 0, 1)) > 0) 00306 error=_mi_enlarge_root(info,keyinfo,key,root); 00307 DBUG_RETURN(error); 00308 } /* _mi_ck_real_write_btree */
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 244 of file mi_write.c.
References _mi_ck_write_btree(), _mi_ck_write_tree(), st_myisam_info::bulk_insert, DBUG_ENTER, DBUG_RETURN, and is_tree_inited.
Referenced by _create_index_by_sort(), _mi_ft_store(), _mi_ft_update(), movepoint(), and setup_key_functions().
00245 { 00246 DBUG_ENTER("_mi_ck_write"); 00247 00248 if (info->bulk_insert && is_tree_inited(&info->bulk_insert[keynr])) 00249 { 00250 DBUG_RETURN(_mi_ck_write_tree(info, keynr, key, key_length)); 00251 } 00252 else 00253 { 00254 DBUG_RETURN(_mi_ck_write_btree(info, keynr, key, key_length)); 00255 } 00256 } /* _mi_ck_write */
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_cmp_dynamic_unique | ( | MI_INFO * | info, | |
| MI_UNIQUEDEF * | def, | |||
| const byte * | record, | |||
| my_off_t | pos | |||
| ) |
Definition at line 1443 of file mi_dynrec.c.
References _mi_read_dynamic_record(), st_mi_isam_share::base, st_mi_base_info::blobs, DBUG_ENTER, DBUG_RETURN, error, mi_get_rec_buff_ptr, mi_unique_comp(), my_afree, my_alloca, MY_ALLOW_ZERO_PTR, my_free, MYF, st_unique_def::null_are_equal, st_myisam_info::rec_buff, st_mi_base_info::reclength, and st_myisam_info::s.
Referenced by mi_setup_functions().
01445 { 01446 byte *rec_buff,*old_record; 01447 int error; 01448 DBUG_ENTER("_mi_cmp_dynamic_unique"); 01449 01450 if (!(old_record=my_alloca(info->s->base.reclength))) 01451 DBUG_RETURN(1); 01452 01453 /* Don't let the compare destroy blobs that may be in use */ 01454 rec_buff=info->rec_buff; 01455 if (info->s->base.blobs) 01456 info->rec_buff=0; 01457 error=_mi_read_dynamic_record(info,pos,old_record); 01458 if (!error) 01459 error=mi_unique_comp(def, record, old_record, def->null_are_equal); 01460 if (info->s->base.blobs) 01461 { 01462 my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR)); 01463 info->rec_buff=rec_buff; 01464 } 01465 my_afree(old_record); 01466 DBUG_RETURN(error); 01467 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_cmp_static_unique | ( | MI_INFO * | info, | |
| MI_UNIQUEDEF * | def, | |||
| const byte * | record, | |||
| my_off_t | pos | |||
| ) |
Definition at line 150 of file mi_statrec.c.
References st_mi_isam_share::base, DBUG_ENTER, DBUG_RETURN, st_mi_isam_share::file_read, mi_unique_comp(), MY_NABP, MYF, st_unique_def::null_are_equal, st_myisam_info::rec_buff, st_myisam_info::rec_cache, st_mi_base_info::reclength, st_myisam_info::s, and st_io_cache::seek_not_done.
Referenced by mi_setup_functions().
00152 { 00153 DBUG_ENTER("_mi_cmp_static_unique"); 00154 00155 info->rec_cache.seek_not_done=1; /* We have done a seek */ 00156 if (info->s->file_read(info, (char*) info->rec_buff, info->s->base.reclength, 00157 pos, MYF(MY_NABP))) 00158 DBUG_RETURN(-1); 00159 DBUG_RETURN(mi_unique_comp(def, record, info->rec_buff, 00160 def->null_are_equal)); 00161 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_decrement_open_count | ( | MI_INFO * | info | ) |
Definition at line 531 of file mi_locking.c.
References F_WRLCK, st_mi_isam_share::global_changed, st_mi_state_info::header, st_mi_isam_share::kfile, st_myisam_info::lock_type, mi_int2store, mi_lock_database(), MY_NABP, my_pwrite(), MYF, st_mi_state_info::open_count, st_myisam_info::s, st_mi_isam_share::state, and test.
Referenced by mi_close().
00532 { 00533 char buff[2]; 00534 register MYISAM_SHARE *share=info->s; 00535 int lock_error=0,write_error=0; 00536 if (share->global_changed) 00537 { 00538 uint old_lock=info->lock_type; 00539 share->global_changed=0; 00540 lock_error=mi_lock_database(info,F_WRLCK); 00541 /* Its not fatal even if we couldn't get the lock ! */ 00542 if (share->state.open_count > 0) 00543 { 00544 share->state.open_count--; 00545 mi_int2store(buff,share->state.open_count); 00546 write_error=my_pwrite(share->kfile,buff,sizeof(buff), 00547 sizeof(share->state.header), 00548 MYF(MY_NABP)); 00549 } 00550 if (!lock_error) 00551 lock_error=mi_lock_database(info,old_lock); 00552 } 00553 return test(lock_error || write_error); 00554 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_delete_dynamic_record | ( | MI_INFO * | info | ) |
Definition at line 305 of file mi_dynrec.c.
References delete_dynamic_record(), and st_myisam_info::lastpos.
Referenced by mi_setup_functions().
00306 { 00307 return delete_dynamic_record(info,info->lastpos,0); 00308 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_delete_static_record | ( | MI_INFO * | info | ) |
Definition at line 99 of file mi_statrec.c.
References _mi_dpointer(), st_mi_isam_share::base, st_mi_status_info::del, st_mi_state_info::dellink, st_mi_status_info::empty, st_mi_isam_share::file_write, st_myisam_info::lastpos, MY_NABP, MYF, st_mi_base_info::pack_reclength, st_myisam_info::rec_cache, st_mi_isam_share::rec_reflength, st_myisam_info::s, st_io_cache::seek_not_done, st_mi_isam_share::state, and st_myisam_info::state.
Referenced by mi_setup_functions().
00100 { 00101 uchar temp[9]; /* 1+sizeof(uint32) */ 00102 00103 info->state->del++; 00104 info->state->empty+=info->s->base.pack_reclength; 00105 temp[0]= '\0'; /* Mark that record is deleted */ 00106 _mi_dpointer(info,temp+1,info->s->state.dellink); 00107 info->s->state.dellink = info->lastpos; 00108 info->rec_cache.seek_not_done=1; 00109 return (info->s->file_write(info,(byte*) temp, 1+info->s->rec_reflength, 00110 info->lastpos, MYF(MY_NABP)) != 0); 00111 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 715 of file mi_search.c.
References abort(), st_mi_isam_share::base, HA_OFFSET_ERROR, HA_OPTION_COMPRESS_RECORD, HA_OPTION_PACK_RECORD, mi_int2store, mi_int3store, mi_int4store, mi_int5store, mi_int6store, mi_int7store, mi_int8store, st_mi_isam_share::options, st_mi_base_info::pack_reclength, st_mi_isam_share::rec_reflength, and st_myisam_info::s.
Referenced by _ft2_search(), _mi_delete_static_record(), _mi_ft_convert_to_ft2(), _mi_make_key(), d_search(), movepoint(), sort_ft_buf_flush(), sort_one_index(), sort_record_index(), and w_search().
00716 { 00717 if (!(info->s->options & 00718 (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) && 00719 pos != HA_OFFSET_ERROR) 00720 pos/=info->s->base.pack_reclength; 00721 00722 switch (info->s->rec_reflength) { 00723 #if SIZEOF_OFF_T > 4 00724 case 8: mi_int8store(buff,pos); break; 00725 case 7: mi_int7store(buff,pos); break; 00726 case 6: mi_int6store(buff,pos); break; 00727 case 5: mi_int5store(buff,pos); break; 00728 #else 00729 case 8: *buff++=0; 00730 /* fall trough */ 00731 case 7: *buff++=0; 00732 /* fall trough */ 00733 case 6: *buff++=0; 00734 /* fall trough */ 00735 case 5: *buff++=0; 00736 /* fall trough */ 00737 #endif 00738 case 4: mi_int4store(buff,pos); break; 00739 case 3: mi_int3store(buff,pos); break; 00740 case 2: mi_int2store(buff,(uint) pos); break; 00741 default: abort(); /* Impossible */ 00742 } 00743 } /* _mi_dpointer */
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 627 of file mi_search.c.
References st_mi_isam_share::base, HA_OPTION_COMPRESS_RECORD, HA_OPTION_PACK_RECORD, mi_uint2korr, mi_uint3korr, mi_uint4korr, mi_uint5korr, mi_uint6korr, mi_uint7korr, mi_uint8korr, st_mi_isam_share::options, st_mi_base_info::pack_reclength, pos(), st_mi_isam_share::rec_reflength, and st_myisam_info::s.
Referenced by _mi_search(), _mi_search_first(), _mi_search_last(), _mi_search_next(), chk_index(), d_search(), get_record_for_key(), sort_one_index(), sort_record_index(), and w_search().
00628 { 00629 my_off_t pos; 00630 after_key-=(nod_flag + info->s->rec_reflength); 00631 switch (info->s->rec_reflength) { 00632 #if SIZEOF_OFF_T > 4 00633 case 8: pos= (my_off_t) mi_uint8korr(after_key); break; 00634 case 7: pos= (my_off_t) mi_uint7korr(after_key); break; 00635 case 6: pos= (my_off_t) mi_uint6korr(after_key); break; 00636 case 5: pos= (my_off_t) mi_uint5korr(after_key); break; 00637 #else 00638 case 8: pos= (my_off_t) mi_uint4korr(after_key+4); break; 00639 case 7: pos= (my_off_t) mi_uint4korr(after_key+3); break; 00640 case 6: pos= (my_off_t) mi_uint4korr(after_key+2); break; 00641 case 5: pos= (my_off_t) mi_uint4korr(after_key+1); break; 00642 #endif 00643 case 4: pos= (my_off_t) mi_uint4korr(after_key); break; 00644 case 3: pos= (my_off_t) mi_uint3korr(after_key); break; 00645 case 2: pos= (my_off_t) mi_uint2korr(after_key); break; 00646 default: 00647 pos=0L; /* Shut compiler up */ 00648 } 00649 return (info->s->options & 00650 (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ? pos : 00651 pos*info->s->base.pack_reclength; 00652 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 313 of file mi_write.c.
References _mi_kpointer(), _mi_new(), _mi_write_keypage(), st_mi_isam_share::base, st_myisam_info::buff, st_myisam_info::buff_used, DBUG_ENTER, DBUG_RETURN, DFLT_INIT_HITS, HA_OFFSET_ERROR, st_mi_base_info::key_reflength, keyinfo, mi_putint, st_mi_keydef::pack_key, st_myisam_info::page_changed, st_myisam_info::s, and st_mi_keydef::store_key.
Referenced by _mi_ck_real_delete(), and _mi_ck_real_write_btree().
00315 { 00316 uint t_length,nod_flag; 00317 MI_KEY_PARAM s_temp; 00318 MYISAM_SHARE *share=info->s; 00319 DBUG_ENTER("_mi_enlarge_root"); 00320 00321 nod_flag= (*root != HA_OFFSET_ERROR) ? share->base.key_reflength : 0; 00322 _mi_kpointer(info,info->buff+2,*root); /* if nod */ 00323 t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,(uchar*) 0, 00324 (uchar*) 0, (uchar*) 0, key,&s_temp); 00325 mi_putint(info->buff,t_length+2+nod_flag,nod_flag); 00326 (*keyinfo->store_key)(keyinfo,info->buff+2+nod_flag,&s_temp); 00327 info->buff_used=info->page_changed=1; /* info->buff is used */ 00328 if ((*root= _mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR || 00329 _mi_write_keypage(info,keyinfo,*root,DFLT_INIT_HITS,info->buff)) 00330 DBUG_RETURN(-1); 00331 DBUG_RETURN(0); 00332 } /* _mi_enlarge_root */
Here is the call graph for this function:

Here is the caller graph for this function:

| uchar* _mi_fetch_keypage | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| my_off_t | page, | |||
| int | level, | |||
| uchar * | buff, | |||
| int | return_buffer | |||
| ) |
| uchar* _mi_find_half_pos | ( | uint | nod_flag, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | page, | |||
| uchar * | key, | |||
| uint * | return_key_length, | |||
| uchar ** | after_key | |||
| ) |
Definition at line 658 of file mi_write.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_mi_keydef::flag, st_mi_keydef::get_key, HA_BINARY_PACK_KEY, HA_PACK_KEY, HA_SPACE_PACK_USED, HA_VAR_LENGTH_KEY, keyinfo, st_mi_keydef::keylength, keys, memcpy, and mi_getint.
Referenced by _mi_split_page(), and underflow().
00661 { 00662 uint keys,length,key_ref_length; 00663 uchar *end,*lastpos; 00664 DBUG_ENTER("_mi_find_half_pos"); 00665 00666 key_ref_length=2+nod_flag; 00667 length=mi_getint(page)-key_ref_length; 00668 page+=key_ref_length; 00669 if (!(keyinfo->flag & 00670 (HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY | 00671 HA_BINARY_PACK_KEY))) 00672 { 00673 key_ref_length=keyinfo->keylength+nod_flag; 00674 keys=length/(key_ref_length*2); 00675 *return_key_length=keyinfo->keylength; 00676 end=page+keys*key_ref_length; 00677 *after_key=end+key_ref_length; 00678 memcpy(key,end,key_ref_length); 00679 DBUG_RETURN(end); 00680 } 00681 00682 end=page+length/2-key_ref_length; /* This is aprox. half */ 00683 *key='\0'; 00684 do 00685 { 00686 lastpos=page; 00687 if (!(length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,key))) 00688 DBUG_RETURN(0); 00689 } while (page < end); 00690 *return_key_length=length; 00691 *after_key=page; 00692 DBUG_PRINT("exit",("returns: %lx page: %lx half: %lx",lastpos,page,end)); 00693 DBUG_RETURN(lastpos); 00694 } /* _mi_find_half_pos */
Here is the caller graph for this function:

| int _mi_ft_update | ( | MI_INFO * | info, | |
| uint | keynr, | |||
| byte * | keybuf, | |||
| const byte * | oldrec, | |||
| const byte * | newrec, | |||
| my_off_t | pos | |||
| ) |
Definition at line 194 of file ft_update.c.
References _ft_make_key(), _mi_ck_delete(), _mi_ck_write(), _mi_ft_erase(), _mi_ft_parserecord(), _mi_ft_store(), st_HA_KEYSEG::charset, cmp, DBUG_ENTER, DBUG_RETURN, err, error, free_root(), st_myisam_info::ft_memroot, key_length, st_mi_isam_share::keyinfo, st_ft_word::len, mi_compare_text(), MY_MARK_BLOCKS_FREE, MYF, st_ft_word::pos, st_myisam_info::s, st_mi_keydef::seg, and st_ft_word::weight.
00196 { 00197 int error= -1; 00198 FT_WORD *oldlist,*newlist, *old_word, *new_word; 00199 CHARSET_INFO *cs=info->s->keyinfo[keynr].seg->charset; 00200 uint key_length; 00201 int cmp, cmp2; 00202 DBUG_ENTER("_mi_ft_update"); 00203 00204 if (!(old_word=oldlist=_mi_ft_parserecord(info, keynr, oldrec, 00205 &info->ft_memroot)) || 00206 !(new_word=newlist=_mi_ft_parserecord(info, keynr, newrec, 00207 &info->ft_memroot))) 00208 goto err; 00209 00210 error=0; 00211 while(old_word->pos && new_word->pos) 00212 { 00213 cmp= mi_compare_text(cs, (uchar*) old_word->pos,old_word->len, 00214 (uchar*) new_word->pos,new_word->len,0,0); 00215 cmp2= cmp ? 0 : (fabs(old_word->weight - new_word->weight) > 1.e-5); 00216 00217 if (cmp < 0 || cmp2) 00218 { 00219 key_length=_ft_make_key(info,keynr,keybuf,old_word,pos); 00220 if ((error=_mi_ck_delete(info,keynr,(uchar*) keybuf,key_length))) 00221 goto err; 00222 } 00223 if (cmp > 0 || cmp2) 00224 { 00225 key_length=_ft_make_key(info,keynr,keybuf,new_word,pos); 00226 if ((error=_mi_ck_write(info,keynr,(uchar*) keybuf,key_length))) 00227 goto err; 00228 } 00229 if (cmp<=0) old_word++; 00230 if (cmp>=0) new_word++; 00231 } 00232 if (old_word->pos) 00233 error=_mi_ft_erase(info,keynr,keybuf,old_word,pos); 00234 else if (new_word->pos) 00235 error=_mi_ft_store(info,keynr,keybuf,new_word,pos); 00236 00237 err: 00238 free_root(&info->ft_memroot, MYF(MY_MARK_BLOCKS_FREE)); 00239 DBUG_RETURN(error); 00240 }
Here is the call graph for this function:

| uint _mi_get_block_info | ( | MI_BLOCK_INFO * | , | |
| File | , | |||
| my_off_t | ||||
| ) |
Definition at line 1795 of file mi_dynrec.c.
References BLOCK_DELETED, BLOCK_ERROR, BLOCK_FIRST, BLOCK_LAST, st_mi_block_info::block_len, BLOCK_SYNC_ERROR, st_mi_block_info::data_len, DBUG_DUMP, err, st_mi_block_info::filepos, HA_ERR_WRONG_IN_RECORD, HA_OFFSET_ERROR, st_mi_block_info::header, MI_BLOCK_INFO_HEADER_LENGTH, MI_DYN_ALIGN_SIZE, MI_MIN_BLOCK_LENGTH, mi_sizekorr, mi_uint2korr, mi_uint3korr, mi_uint4korr, my_errno, my_read, my_seek(), MY_SEEK_SET, MYF, st_mi_block_info::next_filepos, st_mi_block_info::prev_filepos, st_mi_block_info::rec_len, st_mi_block_info::second_read, and VOID.
Referenced by _mi_cmp_dynamic_record(), _mi_find_writepos(), _mi_read_dynamic_record(), _mi_read_rnd_dynamic_record(), _mi_write_part_record(), delete_dynamic_record(), unlink_deleted_block(), update_backward_delete_link(), and update_dynamic_record().
01796 { 01797 uint return_val=0; 01798 uchar *header=info->header; 01799 01800 if (file >= 0) 01801 { 01802 /* 01803 We do not use my_pread() here because we want to have the file 01804 pointer set to the end of the header after this function. 01805 my_pread() may leave the file pointer untouched. 01806 */ 01807 VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0))); 01808 if (my_read(file,(char*) header,sizeof(info->header),MYF(0)) != 01809 sizeof(info->header)) 01810 goto err; 01811 } 01812 DBUG_DUMP("header",(byte*) header,MI_BLOCK_INFO_HEADER_LENGTH); 01813 if (info->second_read) 01814 { 01815 if (info->header[0] <= 6 || info->header[0] == 13) 01816 return_val=BLOCK_SYNC_ERROR; 01817 } 01818 else 01819 { 01820 if (info->header[0] > 6 && info->header[0] != 13) 01821 return_val=BLOCK_SYNC_ERROR; 01822 } 01823 info->next_filepos= HA_OFFSET_ERROR; /* Dummy if no next block */ 01824 01825 switch (info->header[0]) { 01826 case 0: 01827 if ((info->block_len=(uint) mi_uint3korr(header+1)) < 01828 MI_MIN_BLOCK_LENGTH || 01829 (info->block_len & (MI_DYN_ALIGN_SIZE -1))) 01830 goto err; 01831 info->filepos=filepos; 01832 info->next_filepos=mi_sizekorr(header+4); 01833 info->prev_filepos=mi_sizekorr(header+12); 01834 #if SIZEOF_OFF_T == 4 01835 if ((mi_uint4korr(header+4) != 0 && 01836 (mi_uint4korr(header+4) != (ulong) ~0 || 01837 info->next_filepos != (ulong) ~0)) || 01838 (mi_uint4korr(header+12) != 0 && 01839 (mi_uint4korr(header+12) != (ulong) ~0 || 01840 info->prev_filepos != (ulong) ~0))) 01841 goto err; 01842 #endif 01843 return return_val | BLOCK_DELETED; /* Deleted block */ 01844 01845 case 1: 01846 info->rec_len=info->data_len=info->block_len=mi_uint2korr(header+1); 01847 info->filepos=filepos+3; 01848 return return_val | BLOCK_FIRST | BLOCK_LAST; 01849 case 2: 01850 info->rec_len=info->data_len=info->block_len=mi_uint3korr(header+1); 01851 info->filepos=filepos+4; 01852 return return_val | BLOCK_FIRST | BLOCK_LAST; 01853 01854 case 13: 01855 info->rec_len=mi_uint4korr(header+1); 01856 info->block_len=info->data_len=mi_uint3korr(header+5); 01857 info->next_filepos=mi_sizekorr(header+8); 01858 info->second_read=1; 01859 info->filepos=filepos+16; 01860 return return_val | BLOCK_FIRST; 01861 01862 case 3: 01863 info->rec_len=info->data_len=mi_uint2korr(header+1); 01864 info->block_len=info->rec_len+ (uint) header[3]; 01865 info->filepos=filepos+4; 01866 return return_val | BLOCK_FIRST | BLOCK_LAST; 01867 case 4: 01868 info->rec_len=info->data_len=mi_uint3korr(header+1); 01869 info->block_len=info->rec_len+ (uint) header[4]; 01870 info->filepos=filepos+5; 01871 return return_val | BLOCK_FIRST | BLOCK_LAST; 01872 01873 case 5: 01874 info->rec_len=mi_uint2korr(header+1); 01875 info->block_len=info->data_len=mi_uint2korr(header+3); 01876 info->next_filepos=mi_sizekorr(header+5); 01877 info->second_read=1; 01878 info->filepos=filepos+13; 01879 return return_val | BLOCK_FIRST; 01880 case 6: 01881 info->rec_len=mi_uint3korr(header+1); 01882 info->block_len=info->data_len=mi_uint3korr(header+4); 01883 info->next_filepos=mi_sizekorr(header+7); 01884 info->second_read=1; 01885 info->filepos=filepos+15; 01886 return return_val | BLOCK_FIRST; 01887 01888 /* The following blocks are identical to 1-6 without rec_len */ 01889 case 7: 01890 info->data_len=info->block_len=mi_uint2korr(header+1); 01891 info->filepos=filepos+3; 01892 return return_val | BLOCK_LAST; 01893 case 8: 01894 info->data_len=info->block_len=mi_uint3korr(header+1); 01895 info->filepos=filepos+4; 01896 return return_val | BLOCK_LAST; 01897 01898 case 9: 01899 info->data_len=mi_uint2korr(header+1); 01900 info->block_len=info->data_len+ (uint) header[3]; 01901 info->filepos=filepos+4; 01902 return return_val | BLOCK_LAST; 01903 case 10: 01904 info->data_len=mi_uint3korr(header+1); 01905 info->block_len=info->data_len+ (uint) header[4]; 01906 info->filepos=filepos+5; 01907 return return_val | BLOCK_LAST; 01908 01909 case 11: 01910 info->data_len=info->block_len=mi_uint2korr(header+1); 01911 info->next_filepos=mi_sizekorr(header+3); 01912 info->second_read=1; 01913 info->filepos=filepos+11; 01914 return return_val; 01915 case 12: 01916 info->data_len=info->block_len=mi_uint3korr(header+1); 01917 info->next_filepos=mi_sizekorr(header+4); 01918 info->second_read=1; 01919 info->filepos=filepos+12; 01920 return return_val; 01921 } 01922 01923 err: 01924 my_errno=HA_ERR_WRONG_IN_RECORD; /* Garbage */ 01925 return BLOCK_ERROR; 01926 }
Here is the call graph for this function:

Here is the caller graph for this function:

| uchar* _mi_get_key | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | page, | |||
| uchar * | key, | |||
| uchar * | keypos, | |||
| uint * | return_key_length | |||
| ) |
Definition at line 1021 of file mi_search.c.
References bmove(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_mi_keydef::flag, st_mi_keydef::get_key, HA_BINARY_PACK_KEY, HA_ERR_CRASHED, HA_VAR_LENGTH_KEY, keyinfo, st_mi_keydef::keylength, mi_print_error, mi_test_if_nod, my_errno, and st_myisam_info::s.
Referenced by underflow().
01023 { 01024 uint nod_flag; 01025 DBUG_ENTER("_mi_get_key"); 01026 01027 nod_flag=mi_test_if_nod(page); 01028 if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY))) 01029 { 01030 bmove((byte*) key,(byte*) keypos,keyinfo->keylength+nod_flag); 01031 DBUG_RETURN(keypos+keyinfo->keylength+nod_flag); 01032 } 01033 else 01034 { 01035 page+=2+nod_flag; 01036 key[0]=0; /* safety */ 01037 while (page <= keypos) 01038 { 01039 *return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,key); 01040 if (*return_key_length == 0) 01041 { 01042 mi_print_error(info->s, HA_ERR_CRASHED); 01043 my_errno=HA_ERR_CRASHED; 01044 DBUG_RETURN(0); 01045 } 01046 } 01047 } 01048 DBUG_PRINT("exit",("page: 0x%lx length: %u", (long) page, 01049 *return_key_length)); 01050 DBUG_RETURN(page); 01051 } /* _mi_get_key */
Here is the call graph for this function:

Here is the caller graph for this function:

| uchar* _mi_get_last_key | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | keypos, | |||
| uchar * | lastkey, | |||
| uchar * | endpos, | |||
| uint * | return_key_length | |||
| ) |
Definition at line 1095 of file mi_search.c.
References bmove(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_mi_keydef::flag, st_mi_keydef::get_key, HA_BINARY_PACK_KEY, HA_ERR_CRASHED, HA_VAR_LENGTH_KEY, keyinfo, st_mi_keydef::keylength, mi_print_error, mi_test_if_nod, my_errno, and st_myisam_info::s.
Referenced by _mi_search_last(), _mi_search_next(), d_search(), del(), and underflow().
01097 { 01098 uint nod_flag; 01099 uchar *lastpos; 01100 DBUG_ENTER("_mi_get_last_key"); 01101 DBUG_PRINT("enter",("page: 0x%lx endpos: 0x%lx", (long) page, 01102 (long) endpos)); 01103 01104 nod_flag=mi_test_if_nod(page); 01105 if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY))) 01106 { 01107 lastpos=endpos-keyinfo->keylength-nod_flag; 01108 *return_key_length=keyinfo->keylength; 01109 if (lastpos > page) 01110 bmove((byte*) lastkey,(byte*) lastpos,keyinfo->keylength+nod_flag); 01111 } 01112 else 01113 { 01114 lastpos=(page+=2+nod_flag); 01115 lastkey[0]=0; 01116 while (page < endpos) 01117 { 01118 lastpos=page; 01119 *return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,lastkey); 01120 if (*return_key_length == 0) 01121 { 01122 DBUG_PRINT("error",("Couldn't find last key: page: 0x%lx", 01123 (long) page)); 01124 mi_print_error(info->s, HA_ERR_CRASHED); 01125 my_errno=HA_ERR_CRASHED; 01126 DBUG_RETURN(0); 01127 } 01128 } 01129 } 01130 DBUG_PRINT("exit",("lastpos: 0x%lx length: %u", (long) lastpos, 01131 *return_key_length)); 01132 DBUG_RETURN(lastpos); 01133 } /* _mi_get_last_key */
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_insert | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | key, | |||
| uchar * | anc_buff, | |||
| uchar * | key_pos, | |||
| uchar * | key_buff, | |||
| uchar * | father_buff, | |||
| uchar * | father_keypos, | |||
| my_off_t | father_page, | |||
| my_bool | insert_last | |||
| ) |
Definition at line 1173 of file mi_search.c.
References get_key_length, HA_BLOB_PART, HA_NULL_PART, HA_SPACE_PACK, HA_VAR_LENGTH_PART, keyinfo, keyseg, reg1, st_mi_keydef::seg, and start().
Referenced by mi_rkey().
01175 { 01176 reg1 HA_KEYSEG *keyseg; 01177 uchar *start= key; 01178 01179 for (keyseg=keyinfo->seg ; keyseg != end ; keyseg++) 01180 { 01181 if (keyseg->flag & HA_NULL_PART) 01182 if (!*key++) 01183 continue; 01184 if (keyseg->flag & (HA_SPACE_PACK | HA_BLOB_PART | HA_VAR_LENGTH_PART)) 01185 { 01186 uint length; 01187 get_key_length(length,key); 01188 key+=length; 01189 } 01190 else 01191 key+= keyseg->length; 01192 } 01193 return (uint) (key-start); 01194 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 563 of file mi_search.c.
References HA_OFFSET_ERROR, MI_MIN_KEY_BLOCK_LENGTH, mi_uint2korr, mi_uint3korr, mi_uint4korr, mi_uint5korr, mi_uint6korr, and mi_uint7korr.
Referenced by _mi_balance_page(), _mi_ck_real_delete(), _mi_search(), _mi_search_first(), _mi_search_last(), _mi_search_next(), _mi_search_pos(), chk_index(), d_search(), del(), remove_key(), sort_one_index(), sort_record_index(), underflow(), and w_search().
00564 { 00565 after_key-=nod_flag; 00566 switch (nod_flag) { 00567 #if SIZEOF_OFF_T > 4 00568 case 7: 00569 return mi_uint7korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH; 00570 case 6: 00571 return mi_uint6korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH; 00572 case 5: 00573 return mi_uint5korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH; 00574 #else 00575 case 7: 00576 after_key++; 00577 case 6: 00578 after_key++; 00579 case 5: 00580 after_key++; 00581 #endif 00582 case 4: 00583 return ((my_off_t) mi_uint4korr(after_key))*MI_MIN_KEY_BLOCK_LENGTH; 00584 case 3: 00585 return ((my_off_t) mi_uint3korr(after_key))*MI_MIN_KEY_BLOCK_LENGTH; 00586 case 2: 00587 return (my_off_t) (mi_uint2korr(after_key)*MI_MIN_KEY_BLOCK_LENGTH); 00588 case 1: 00589 return (uint) (*after_key)*MI_MIN_KEY_BLOCK_LENGTH; 00590 case 0: /* At leaf page */ 00591 default: /* Impossible */ 00592 return(HA_OFFSET_ERROR); 00593 } 00594 } /* _kpos */
Here is the caller graph for this function:

| uint _mi_make_key | ( | MI_INFO * | info, | |
| uint | keynr, | |||
| uchar * | key, | |||
| const byte * | record, | |||
| my_off_t | filepos | |||
| ) |
| int _mi_mark_file_changed | ( | MI_INFO * | info | ) |
Definition at line 498 of file mi_locking.c.
References st_mi_state_info::changed, DBUG_ENTER, DBUG_RETURN, st_mi_isam_share::global_changed, st_mi_state_info::header, st_mi_isam_share::kfile, mi_int2store, MY_NABP, my_pwrite(), MYF, st_mi_state_info::open_count, st_myisam_info::s, st_mi_isam_share::state, STATE_CHANGED, STATE_NOT_ANALYZED, STATE_NOT_OPTIMIZED_KEYS, and st_mi_isam_share::temporary.
Referenced by mi_delete_all_rows().
00499 { 00500 char buff[3]; 00501 register MYISAM_SHARE *share=info->s; 00502 DBUG_ENTER("_mi_mark_file_changed"); 00503 00504 if (!(share->state.changed & STATE_CHANGED) || ! share->global_changed) 00505 { 00506 share->state.changed|=(STATE_CHANGED | STATE_NOT_ANALYZED | 00507 STATE_NOT_OPTIMIZED_KEYS); 00508 if (!share->global_changed) 00509 { 00510 share->global_changed=1; 00511 share->state.open_count++; 00512 } 00513 if (!share->temporary) 00514 { 00515 mi_int2store(buff,share->state.open_count); 00516 buff[2]=1; /* Mark that it's changed */ 00517 DBUG_RETURN(my_pwrite(share->kfile,buff,sizeof(buff), 00518 sizeof(share->state.header), 00519 MYF(MY_NABP))); 00520 } 00521 } 00522 DBUG_RETURN(0); 00523 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1198 of file mi_search.c.
References _mi_keylength(), keyinfo, memcpy, and reg1.
Referenced by _mi_split_page(), and sort_insert_key().
01199 { 01200 reg1 uint length; 01201 memcpy((byte*) to, (byte*) from, 01202 (size_t) (length=_mi_keylength(keyinfo,from))); 01203 return to+length; 01204 }
Here is the call graph for this function:

Here is the caller graph for this function:

| uint _mi_pack_get_block_info | ( | MI_INFO * | , | |
| MI_BLOCK_INFO * | , | |||
| File | , | |||
| my_off_t | ||||
| ) |
Definition at line 1055 of file mi_packrec.c.
References st_mi_isam_share::base, st_myisam_info::bit_buff, st_mi_bit_buff::blob_end, st_mi_block_info::blob_len, st_myisam_info::blob_length, st_mi_bit_buff::blob_pos, st_mi_base_info::blobs, BLOCK_FATAL_ERROR, DBUG_DUMP, st_mi_block_info::filepos, st_mi_block_info::header, LINT_INIT, memcpy, mi_alloc_rec_buff(), min, MY_NABP, my_read, my_seek(), MY_SEEK_SET, MYF, st_mi_block_info::offset, st_mi_isam_share::pack, read_pack_length(), st_myisam_info::rec_buff, st_mi_block_info::rec_len, st_mi_isam_pack::ref_length, st_myisam_info::s, st_mi_isam_pack::version, and VOID.
Referenced by _mi_read_pack_record(), and _mi_read_rnd_pack_record().
01057 { 01058 uchar *header=info->header; 01059 uint head_length,ref_length; 01060 LINT_INIT(ref_length); 01061 01062 if (file >= 0) 01063 { 01064 ref_length=myisam->s->pack.ref_length; 01065 /* 01066 We can't use my_pread() here because mi_read_rnd_pack_record assumes 01067 position is ok 01068 */ 01069 VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0))); 01070 if (my_read(file,(char*) header,ref_length,MYF(MY_NABP))) 01071 return BLOCK_FATAL_ERROR; 01072 DBUG_DUMP("header",(byte*) header,ref_length); 01073 } 01074 head_length= read_pack_length((uint) myisam->s->pack.version, header, 01075 &info->rec_len); 01076 if (myisam->s->base.blobs) 01077 { 01078 head_length+= read_pack_length((uint) myisam->s->pack.version, 01079 header + head_length, &info->blob_len); 01080 if (!(mi_alloc_rec_buff(myisam,info->rec_len + info->blob_len, 01081 &myisam->rec_buff))) 01082 return BLOCK_FATAL_ERROR; /* not enough memory */ 01083 myisam->bit_buff.blob_pos=(uchar*) myisam->rec_buff+info->rec_len; 01084 myisam->bit_buff.blob_end= myisam->bit_buff.blob_pos+info->blob_len; 01085 myisam->blob_length=info->blob_len; 01086 } 01087 info->filepos=filepos+head_length; 01088 if (file > 0) 01089 { 01090 info->offset=min(info->rec_len, ref_length - head_length); 01091 memcpy(myisam->rec_buff, header+head_length, info->offset); 01092 } 01093 return 0; 01094 }
Here is the call graph for this function:

Here is the caller graph for this function:

| uint _mi_pack_key | ( | MI_INFO * | info, | |
| uint | keynr, | |||
| uchar * | key, | |||
| uchar * | old, | |||
| uint | key_length, | |||
| HA_KEYSEG ** | last_used_keyseg | |||
| ) |
| int _mi_prefix_search | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | page, | |||
| uchar * | key, | |||
| uint | key_len, | |||
| uint | comp_flag, | |||
| uchar ** | ret_pos, | |||
| uchar * | buff, | |||
| my_bool * | was_last_key | |||
| ) |
| int _mi_read_cache | ( | IO_CACHE * | info, | |
| byte * | buff, | |||
| my_off_t | pos, | |||
| uint | length, | |||
| int | re_read_if_possibly | |||
| ) |
Definition at line 39 of file mi_cache.c.
References bzero, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_io_cache::error, st_io_cache::file, HA_ERR_WRONG_IN_RECORD, memcpy, MI_BLOCK_INFO_HEADER_LENGTH, min, my_errno, MY_NABP, my_pread(), MYF, offset, st_io_cache::pos_in_file, st_io_cache::read_end, st_io_cache::read_function, st_io_cache::read_pos, READING_HEADER, READING_NEXT, st_io_cache::request_pos, and st_io_cache::seek_not_done.
Referenced by _mi_read_rnd_dynamic_record(), and _mi_read_rnd_pack_record().
00041 { 00042 uint read_length,in_buff_length; 00043 my_off_t offset; 00044 char *in_buff_pos; 00045 DBUG_ENTER("_mi_read_cache"); 00046 00047 if (pos < info->pos_in_file) 00048 { 00049 read_length=length; 00050 if ((my_off_t) read_length > (my_off_t) (info->pos_in_file-pos)) 00051 read_length=(uint) (info->pos_in_file-pos); 00052 info->seek_not_done=1; 00053 if (my_pread(info->file,buff,read_length,pos,MYF(MY_NABP))) 00054 DBUG_RETURN(1); 00055 if (!(length-=read_length)) 00056 DBUG_RETURN(0); 00057 pos+=read_length; 00058 buff+=read_length; 00059 } 00060 if (pos >= info->pos_in_file && 00061 (offset= (my_off_t) (pos - info->pos_in_file)) < 00062 (my_off_t) (info->read_end - info->request_pos)) 00063 { 00064 in_buff_pos=info->request_pos+(uint) offset; 00065 in_buff_length= min(length,(uint) (info->read_end-in_buff_pos)); 00066 memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length); 00067 if (!(length-=in_buff_length)) 00068 DBUG_RETURN(0); 00069 pos+=in_buff_length; 00070 buff+=in_buff_length; 00071 } 00072 else 00073 in_buff_length=0; 00074 if (flag & READING_NEXT) 00075 { 00076 if (pos != (info->pos_in_file + 00077 (uint) (info->read_end - info->request_pos))) 00078 { 00079 info->pos_in_file=pos; /* Force start here */ 00080 info->read_pos=info->read_end=info->request_pos; /* Everything used */ 00081 info->seek_not_done=1; 00082 } 00083 else 00084 info->read_pos=info->read_end; /* All block used */ 00085 if (!(*info->read_function)(info,buff,length)) 00086 DBUG_RETURN(0); 00087 read_length=info->error; 00088 } 00089 else 00090 { 00091 info->seek_not_done=1; 00092 if ((read_length=my_pread(info->file,buff,length,pos,MYF(0))) == length) 00093 DBUG_RETURN(0); 00094 } 00095 if (!(flag & READING_HEADER) || (int) read_length == -1 || 00096 read_length+in_buff_length < 3) 00097 { 00098 DBUG_PRINT("error", 00099 ("Error %d reading next-multi-part block (Got %d bytes)", 00100 my_errno, (int) read_length)); 00101 if (!my_errno || my_errno == -1) 00102 my_errno=HA_ERR_WRONG_IN_RECORD; 00103 DBUG_RETURN(1); 00104 } 00105 bzero(buff+read_length,MI_BLOCK_INFO_HEADER_LENGTH - in_buff_length - 00106 read_length); 00107 DBUG_RETURN(0); 00108 } /* _mi_read_cache */
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1339 of file mi_dynrec.c.
References _mi_get_block_info(), _mi_rec_unpack(), _mi_writeinfo(), st_mi_isam_share::base, st_mi_base_info::blobs, BLOCK_DELETED, BLOCK_ERROR, BLOCK_FATAL_ERROR, BLOCK_SYNC_ERROR, st_mi_block_info::data_len, DBUG_ENTER, DBUG_RETURN, st_myisam_info::dfile, err, fast_mi_writeinfo, st_mi_isam_share::file_read, st_mi_block_info::filepos, flush_io_cache, HA_ERR_RECORD_DELETED, HA_ERR_WRONG_IN_RECORD, HA_OFFSET_ERROR, HA_STATE_AKTIV, st_mi_block_info::header, LINT_INIT, st_mi_base_info::max_pack_length, memcpy, mi_alloc_rec_buff(), MI_BLOCK_INFO_HEADER_LENGTH, my_errno, MY_FILE_ERROR, MY_NABP, MYF, st_mi_block_info::next_filepos, offset, st_myisam_info::opt_flag, st_io_cache::pos_in_file, st_myisam_info::rec_buff, st_myisam_info::rec_cache, st_mi_block_info::rec_len, st_myisam_info::s, st_mi_block_info::second_read, st_io_cache::seek_not_done, to, st_myisam_info::update, VOID, and WRITE_CACHE_USED.
Referenced by _mi_cmp_dynamic_unique(), and mi_setup_functions().
01340 { 01341 int block_of_record; 01342 uint b_type,left_length; 01343 byte *to; 01344 MI_BLOCK_INFO block_info; 01345 File file; 01346 DBUG_ENTER("mi_read_dynamic_record"); 01347 01348 if (filepos != HA_OFFSET_ERROR) 01349 { 01350 LINT_INIT(to); 01351 LINT_INIT(left_length); 01352 file=info->dfile; 01353 block_of_record= 0; /* First block of record is numbered as zero. */ 01354 block_info.second_read= 0; 01355 do 01356 { 01357 /* A corrupted table can have wrong pointers. (Bug# 19835) */ 01358 if (filepos == HA_OFFSET_ERROR) 01359 goto panic; 01360 if (info->opt_flag & WRITE_CACHE_USED && 01361 info->rec_cache.pos_in_file < filepos + MI_BLOCK_INFO_HEADER_LENGTH && 01362 flush_io_cache(&info->rec_cache)) 01363 goto err; 01364 info->rec_cache.seek_not_done=1; 01365 if ((b_type= _mi_get_block_info(&block_info, file, filepos)) 01366 & (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR | 01367 BLOCK_FATAL_ERROR)) 01368 { 01369 if (b_type & (BLOCK_SYNC_ERROR | BLOCK_DELETED)) 01370 my_errno=HA_ERR_RECORD_DELETED; 01371 goto err; 01372 } 01373 if (block_of_record++ == 0) /* First block */ 01374 { 01375 if (block_info.rec_len > (uint) info->s->base.max_pack_length) 01376 goto panic; 01377 if (info->s->base.blobs) 01378 { 01379 if (!(to=mi_alloc_rec_buff(info, block_info.rec_len, 01380 &info->rec_buff))) 01381 goto err; 01382 } 01383 else 01384 to= info->rec_buff; 01385 left_length=block_info.rec_len; 01386 } 01387 if (left_length < block_info.data_len || ! block_info.data_len) 01388 goto panic; /* Wrong linked record */ 01389 /* copy information that is already read */ 01390 { 01391 uint offset= (uint) (block_info.filepos - filepos); 01392 uint prefetch_len= (sizeof(block_info.header) - offset); 01393 filepos+= sizeof(block_info.header); 01394 01395 if (prefetch_len > block_info.data_len) 01396 prefetch_len= block_info.data_len; 01397 if (prefetch_len) 01398 { 01399 memcpy((byte*) to, block_info.header + offset, prefetch_len); 01400 block_info.data_len-= prefetch_len; 01401 left_length-= prefetch_len; 01402 to+= prefetch_len; 01403 } 01404 } 01405 /* read rest of record from file */ 01406 if (block_info.data_len) 01407 { 01408 if (info->opt_flag & WRITE_CACHE_USED && 01409 info->rec_cache.pos_in_file < filepos + block_info.data_len && 01410 flush_io_cache(&info->rec_cache)) 01411 goto err; 01412 /* 01413 What a pity that this method is not called 'file_pread' and that 01414 there is no equivalent without seeking. We are at the right 01415 position already. :( 01416 */ 01417 if (info->s->file_read(info, (byte*) to, block_info.data_len, 01418 filepos, MYF(MY_NABP))) 01419 goto panic; 01420 left_length-=block_info.data_len; 01421 to+=block_info.data_len; 01422 } 01423 filepos= block_info.next_filepos; 01424 } while (left_length); 01425 01426 info->update|= HA_STATE_AKTIV; /* We have a aktive record */ 01427 fast_mi_writeinfo(info); 01428 DBUG_RETURN(_mi_rec_unpack(info,buf,info->rec_buff,block_info.rec_len) != 01429 MY_FILE_ERROR ? 0 : -1); 01430 } 01431 fast_mi_writeinfo(info); 01432 DBUG_RETURN(-1); /* Wrong data to read */ 01433 01434 panic: 01435 my_errno=HA_ERR_WRONG_IN_RECORD; 01436 err: 01437 VOID(_mi_writeinfo(info,0)); 01438 DBUG_RETURN(-1); 01439 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 489 of file mi_key.c.
References _mi_put_key_in_record(), fast_mi_writeinfo, HA_ERR_CRASHED, HA_ERR_WRONG_INDEX, HA_OFFSET_ERROR, HA_STATE_AKTIV, st_myisam_info::lastinx, mi_print_error, my_errno, st_myisam_info::s, and st_myisam_info::update.
Referenced by chk_key(), and mi_extra().
00490 { 00491 fast_mi_writeinfo(info); 00492 if (filepos != HA_OFFSET_ERROR) 00493 { 00494 if (info->lastinx >= 0) 00495 { /* Read only key */ 00496 if (_mi_put_key_in_record(info,(uint) info->lastinx,buf)) 00497 { 00498 mi_print_error(info->s, HA_ERR_CRASHED); 00499 my_errno=HA_ERR_CRASHED; 00500 return -1; 00501 } 00502 info->update|= HA_STATE_AKTIV; /* We should find a record */ 00503 return 0; 00504 } 00505 my_errno=HA_ERR_WRONG_INDEX; 00506 } 00507 return(-1); /* Wrong data to read */ 00508 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 128 of file mi_packrec.c.
References ADD_TO_PTR, st_mi_isam_share::base, st_columndef::base_type, DBUG_ENTER, DBUG_RETURN, st_mi_isam_share::decode_tables, st_mi_isam_share::decode_trees, st_myisam_info::dfile, st_mi_base_info::fields, get_bits, get_unpack_function, HA_ERR_END_OF_FILE, HA_ERR_WRONG_IN_RECORD, st_mi_isam_pack::header_length, st_columndef::huff_tree, init_bit_buffer(), int(), intervall_length, st_mi_isam_share::keyinfo, st_mi_keydef::keylength, st_mi_base_info::keys, st_mi_keydef::keysegs, max_bit(), st_mi_isam_share::max_pack_length, MAX_QUICK_TABLE_BITS, st_mi_keydef::maxlength, memcmp(), st_mi_base_info::min_block_length, st_mi_isam_share::min_pack_length, st_mi_keydef::minlength, my_errno, my_free, MY_HOLD_ON_ERROR, my_malloc(), MY_NABP, my_read, my_realloc(), MY_WME, MY_ZEROFILL, MYF, myisam_pack_file_magic, myisam_quick_table_bits, OFFSET_TABLE_SIZE, st_mi_isam_share::pack, st_mi_base_info::pack_reclength, st_columndef::pack_type, PTR_BYTE_DIFF, read_huff_table(), st_mi_isam_share::rec, st_mi_isam_share::rec_reflength, st_mi_base_info::rec_reflength, st_mi_isam_pack::ref_length, st_myisam_info::s, st_mi_keydef::seg, set_if_bigger, skip_to_next_byte, st_columndef::space_length_bits, st_mi_decode_tree::table, uint2korr, uint4korr, st_columndef::unpack, and st_mi_isam_pack::version.
00129 { 00130 File file; 00131 int diff_length; 00132 uint i,trees,huff_tree_bits,rec_reflength,length; 00133 uint16 *decode_table,*tmp_buff; 00134 ulong elements,intervall_length; 00135 char *disk_cache,*intervall_buff; 00136 uchar header[32]; 00137 MYISAM_SHARE *share=info->s; 00138 MI_BIT_BUFF bit_buff; 00139 DBUG_ENTER("_mi_read_pack_info"); 00140 00141 if (myisam_quick_table_bits < 4) 00142 myisam_quick_table_bits=4; 00143 else if (myisam_quick_table_bits > MAX_QUICK_TABLE_BITS) 00144 myisam_quick_table_bits=MAX_QUICK_TABLE_BITS; 00145 00146 file=info->dfile; 00147 my_errno=0; 00148 if (my_read(file,(byte*) header,sizeof(header),MYF(MY_NABP))) 00149 { 00150 if (!my_errno) 00151 my_errno=HA_ERR_END_OF_FILE; 00152 goto err0; 00153 } 00154 if (memcmp((byte*) header, (byte*) myisam_pack_file_magic, 3)) 00155 { 00156 my_errno=HA_ERR_WRONG_IN_RECORD; 00157 goto err0; 00158 } 00159 share->pack.version= header[3]; 00160 share->pack.header_length= uint4korr(header+4); 00161 share->min_pack_length=(uint) uint4korr(header+8); 00162 share->max_pack_length=(uint) uint4korr(header+12); 00163 set_if_bigger(share->base.pack_reclength,share->max_pack_length); 00164 elements=uint4korr(header+16); 00165 intervall_length=uint4korr(header+20); 00166 trees=uint2korr(header+24); 00167 share->pack.ref_length=header[26]; 00168 rec_reflength=header[27]; 00169 diff_length=(int) rec_reflength - (int) share->base.rec_reflength; 00170 if (fix_keys) 00171 share->rec_reflength=rec_reflength; 00172 share->base.min_block_length=share->min_pack_length+1; 00173 if (share->min_pack_length > 254) 00174 share->base.min_block_length+=2; 00175 00176 if (!(share->decode_trees=(MI_DECODE_TREE*) 00177 my_malloc((uint) (trees*sizeof(MI_DECODE_TREE)+ 00178 intervall_length*sizeof(byte)), 00179 MYF(MY_WME)))) 00180 goto err0; 00181 intervall_buff=(byte*) (share->decode_trees+trees); 00182 00183 length=(uint) (elements*2+trees*(1 << myisam_quick_table_bits)); 00184 if (!(share->decode_tables=(uint16*) 00185 my_malloc((length+OFFSET_TABLE_SIZE)*sizeof(uint16)+ 00186 (uint) (share->pack.header_length+7), 00187 MYF(MY_WME | MY_ZEROFILL)))) 00188 goto err1; 00189 tmp_buff=share->decode_tables+length; 00190 disk_cache=(byte*) (tmp_buff+OFFSET_TABLE_SIZE); 00191 00192 if (my_read(file,disk_cache, 00193 (uint) (share->pack.header_length-sizeof(header)), 00194 MYF(MY_NABP))) 00195 goto err2; 00196 00197 huff_tree_bits=max_bit(trees ? trees-1 : 0); 00198 init_bit_buffer(&bit_buff, (uchar*) disk_cache, 00199 (uint) (share->pack.header_length-sizeof(header))); 00200 /* Read new info for each field */ 00201 for (i=0 ; i < share->base.fields ; i++) 00202 { 00203 share->rec[i].base_type=(enum en_fieldtype) get_bits(&bit_buff,5); 00204 share->rec[i].pack_type=(uint) get_bits(&bit_buff,6); 00205 share->rec[i].space_length_bits=get_bits(&bit_buff,5); 00206 share->rec[i].huff_tree=share->decode_trees+(uint) get_bits(&bit_buff, 00207 huff_tree_bits); 00208 share->rec[i].unpack=get_unpack_function(share->rec+i); 00209 } 00210 skip_to_next_byte(&bit_buff); 00211 decode_table=share->decode_tables; 00212 for (i=0 ; i < trees ; i++) 00213 if (read_huff_table(&bit_buff,share->decode_trees+i,&decode_table, 00214 &intervall_buff,tmp_buff)) 00215 goto err3; 00216 decode_table=(uint16*) 00217 my_realloc((gptr) share->decode_tables, 00218 (uint) ((byte*) decode_table - (byte*) share->decode_tables), 00219 MYF(MY_HOLD_ON_ERROR)); 00220 { 00221 long diff=PTR_BYTE_DIFF(decode_table,share->decode_tables); 00222 share->decode_tables=decode_table; 00223 for (i=0 ; i < trees ; i++) 00224 share->decode_trees[i].table=ADD_TO_PTR(share->decode_trees[i].table, 00225 diff, uint16*); 00226 } 00227 00228 /* Fix record-ref-length for keys */ 00229 if (fix_keys) 00230 { 00231 for (i=0 ; i < share->base.keys ; i++) 00232 { 00233 share->keyinfo[i].keylength+=(uint16) diff_length; 00234 share->keyinfo[i].minlength+=(uint16) diff_length; 00235 share->keyinfo[i].maxlength+=(uint16) diff_length; 00236 share->keyinfo[i].seg[share->keyinfo[i].keysegs].length= 00237 (uint16) rec_reflength; 00238 } 00239 } 00240 00241 if (bit_buff.error || bit_buff.pos < bit_buff.end) 00242 goto err3; 00243 00244 DBUG_RETURN(0); 00245 00246 err3: 00247 my_errno=HA_ERR_WRONG_IN_RECORD; 00248 err2: 00249 my_free((gptr) share->decode_tables,MYF(0)); 00250 err1: 00251 my_free((gptr) share->decode_trees,MYF(0)); 00252 err0: 00253 DBUG_RETURN(1); 00254 }
Here is the call graph for this function:

Definition at line 434 of file mi_packrec.c.
References _mi_pack_get_block_info(), _mi_pack_rec_unpack(), DBUG_ENTER, DBUG_RETURN, st_myisam_info::dfile, err, HA_ERR_WRONG_IN_RECORD, HA_OFFSET_ERROR, HA_STATE_AKTIV, my_errno, MY_NABP, my_read, MYF, st_mi_block_info::offset, st_myisam_info::rec_buff, st_mi_block_info::rec_len, and st_myisam_info::update.
Referenced by mi_setup_functions().
00435 { 00436 MI_BLOCK_INFO block_info; 00437 File file; 00438 DBUG_ENTER("mi_read_pack_record"); 00439 00440 if (filepos == HA_OFFSET_ERROR) 00441 DBUG_RETURN(-1); /* _search() didn't find record */ 00442 00443 file=info->dfile; 00444 if (_mi_pack_get_block_info(info, &block_info, file, filepos)) 00445 goto err; 00446 if (my_read(file,(byte*) info->rec_buff + block_info.offset , 00447 block_info.rec_len - block_info.offset, MYF(MY_NABP))) 00448 goto panic; 00449 info->update|= HA_STATE_AKTIV; 00450 DBUG_RETURN(_mi_pack_rec_unpack(info,buf,info->rec_buff,block_info.rec_len)); 00451 panic: 00452 my_errno=HA_ERR_WRONG_IN_RECORD; 00453 err: 00454 DBUG_RETURN(-1); 00455 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_readinfo | ( | MI_INFO * | info, | |
| int | lock_flag, | |||
| int | check_keybuffer | |||
| ) |
| my_bool _mi_rec_check | ( | MI_INFO * | info, | |
| const char * | record, | |||
| byte * | packpos, | |||
| ulong | packed_length, | |||
| my_bool | with_checkum | |||
| ) |
Definition at line 996 of file mi_dynrec.c.
References _mi_calc_blob_length(), st_mi_isam_share::base, st_mi_isam_share::calc_checksum, st_myisam_info::checksum, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, err, FIELD_BLOB, FIELD_NORMAL, FIELD_SKIP_ENDSPACE, FIELD_SKIP_PRESPACE, FIELD_SKIP_ZERO, FIELD_VARCHAR, st_mi_base_info::fields, flag, get_pack_length, HA_VARCHAR_PACKLENGTH, st_columndef::length, memcmp(), mi_portable_sizeof_char_ptr, st_mi_base_info::pack_bits, pos(), st_mi_isam_share::rec, reg3, st_myisam_info::s, test, to, uint2korr, and zero_string.
00998 { 00999 uint length,new_length,flag,bit,i; 01000 char *pos,*end,*packpos,*to; 01001 enum en_fieldtype type; 01002 reg3 MI_COLUMNDEF *rec; 01003 DBUG_ENTER("_mi_rec_check"); 01004 01005 packpos=rec_buff; to= rec_buff+info->s->base.pack_bits; 01006 rec=info->s->rec; 01007 flag= *packpos; bit=1; 01008 01009 for (i=info->s->base.fields ; i-- > 0; record+= length, rec++) 01010 { 01011 length=(uint) rec->length; 01012 if ((type = (enum en_fieldtype) rec->type) != FIELD_NORMAL) 01013 { 01014 if (type == FIELD_BLOB) 01015 { 01016 uint blob_length= 01017 _mi_calc_blob_length(length-mi_portable_sizeof_char_ptr,record); 01018 if (!blob_length && !(flag & bit)) 01019 goto err; 01020 if (blob_length) 01021 to+=length - mi_portable_sizeof_char_ptr+ blob_length; 01022 } 01023 else if (type == FIELD_SKIP_ZERO) 01024 { 01025 if (memcmp((byte*) record,zero_string,length) == 0) 01026 { 01027 if (!(flag & bit)) 01028 goto err; 01029 } 01030 else 01031 to+=length; 01032 } 01033 else if (type == FIELD_SKIP_ENDSPACE || 01034 type == FIELD_SKIP_PRESPACE) 01035 { 01036 pos= (byte*) record; end= (byte*) record + length; 01037 if (type == FIELD_SKIP_ENDSPACE) 01038 { /* Pack trailing spaces */ 01039 while (end > record && *(end-1) == ' ') 01040 end--; 01041 } 01042 else 01043 { /* Pack pre-spaces */ 01044 while (pos < end && *pos == ' ') 01045 pos++; 01046 } 01047 new_length=(uint) (end-pos); 01048 if (new_length +1 + test(rec->length > 255 && new_length > 127) 01049 < length) 01050 { 01051 if (!(flag & bit)) 01052 goto err; 01053 if (rec->length > 255 && new_length > 127) 01054 { 01055 if (to[0] != (char) ((new_length & 127)+128) || 01056 to[1] != (char) (new_length >> 7)) 01057 goto err; 01058 to+=2; 01059 } 01060 else if (*to++ != (char) new_length) 01061 goto err; 01062 to+=new_length; 01063 } 01064 else 01065 to+=length; 01066 } 01067 else if (type == FIELD_VARCHAR) 01068 { 01069 uint pack_length= HA_VARCHAR_PACKLENGTH(rec->length -1); 01070 uint tmp_length; 01071 if (pack_length == 1) 01072 { 01073 tmp_length= (uint) *(uchar*) record; 01074 to+= 1+ tmp_length; 01075 continue; 01076 } 01077 else 01078 { 01079 tmp_length= uint2korr(record); 01080 to+= get_pack_length(tmp_length)+tmp_length; 01081 } 01082 continue; 01083 } 01084 else 01085 { 01086 to+=length; 01087 continue; /* Normal field */ 01088 } 01089 if ((bit= bit << 1) >= 256) 01090 { 01091 flag= *++packpos; 01092 bit=1; 01093 } 01094 } 01095 else 01096 to+= length; 01097 } 01098 if (packed_length != (uint) (to - rec_buff) + test(info->s->calc_checksum) || 01099 (bit != 1 && (flag & ~(bit - 1)))) 01100 goto err; 01101 if (with_checksum && ((uchar) info->checksum != (uchar) *to)) 01102 { 01103 DBUG_PRINT("error",("wrong checksum for row")); 01104 goto err; 01105 } 01106 DBUG_RETURN(0); 01107 01108 err: 01109 DBUG_RETURN(1); 01110 }
Here is the call graph for this function:

| my_off_t _mi_rec_pos | ( | MYISAM_SHARE * | info, | |
| uchar * | ptr | |||
| ) |
Definition at line 657 of file mi_search.c.
References abort(), st_mi_isam_share::base, HA_OFFSET_ERROR, HA_OPTION_COMPRESS_RECORD, HA_OPTION_PACK_RECORD, mi_uint2korr, mi_uint3korr, mi_uint4korr, mi_uint5korr, mi_uint6korr, mi_uint7korr, mi_uint8korr, st_mi_isam_share::options, st_mi_base_info::pack_reclength, pos(), and st_mi_isam_share::rec_reflength.
Referenced by _mi_write_static_record(), and chk_del().
00658 { 00659 my_off_t pos; 00660 switch (s->rec_reflength) { 00661 #if SIZEOF_OFF_T > 4 00662 case 8: 00663 pos= (my_off_t) mi_uint8korr(ptr); 00664 if (pos == HA_OFFSET_ERROR) 00665 return HA_OFFSET_ERROR; /* end of list */ 00666 break; 00667 case 7: 00668 pos= (my_off_t) mi_uint7korr(ptr); 00669 if (pos == (((my_off_t) 1) << 56) -1) 00670 return HA_OFFSET_ERROR; /* end of list */ 00671 break; 00672 case 6: 00673 pos= (my_off_t) mi_uint6korr(ptr); 00674 if (pos == (((my_off_t) 1) << 48) -1) 00675 return HA_OFFSET_ERROR; /* end of list */ 00676 break; 00677 case 5: 00678 pos= (my_off_t) mi_uint5korr(ptr); 00679 if (pos == (((my_off_t) 1) << 40) -1) 00680 return HA_OFFSET_ERROR; /* end of list */ 00681 break; 00682 #else 00683 case 8: 00684 case 7: 00685 case 6: 00686 case 5: 00687 ptr+= (s->rec_reflength-4); 00688 /* fall through */ 00689 #endif 00690 case 4: 00691 pos= (my_off_t) mi_uint4korr(ptr); 00692 if (pos == (my_off_t) (uint32) ~0L) 00693 return HA_OFFSET_ERROR; 00694 break; 00695 case 3: 00696 pos= (my_off_t) mi_uint3korr(ptr); 00697 if (pos == (my_off_t) (1 << 24) -1) 00698 return HA_OFFSET_ERROR; 00699 break; 00700 case 2: 00701 pos= (my_off_t) mi_uint2korr(ptr); 00702 if (pos == (my_off_t) (1 << 16) -1) 00703 return HA_OFFSET_ERROR; 00704 break; 00705 default: abort(); /* Impossible */ 00706 } 00707 return ((s->options & 00708 (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ? pos : 00709 pos*s->base.pack_reclength); 00710 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_search | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | key, | |||
| uint | key_len, | |||
| uint | nextflag, | |||
| my_off_t | pos | |||
| ) |
| int _mi_search_next | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | key, | |||
| uint | key_length, | |||
| uint | nextflag, | |||
| my_off_t | pos | |||
| ) |
| int _mi_seq_search | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | page, | |||
| uchar * | key, | |||
| uint | key_len, | |||
| uint | comp_flag, | |||
| uchar ** | ret_pos, | |||
| uchar * | buff, | |||
| my_bool * | was_last_key | |||
| ) |
| int _mi_split_page | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| uchar * | key, | |||
| uchar * | buff, | |||
| uchar * | key_buff, | |||
| my_bool | insert_last | |||
| ) |
| void _mi_store_bin_pack_key | ( | MI_KEYDEF * | keyinfo, | |
| uchar * | key_pos, | |||
| MI_KEY_PARAM * | s_temp | |||
| ) |
| void _mi_store_static_key | ( | MI_KEYDEF * | keyinfo, | |
| uchar * | key_pos, | |||
| MI_KEY_PARAM * | s_temp | |||
| ) |
| void _mi_store_var_pack_key | ( | MI_KEYDEF * | keyinfo, | |
| uchar * | key_pos, | |||
| MI_KEY_PARAM * | s_temp | |||
| ) |
| int _mi_test_if_changed | ( | MI_INFO * | info | ) |
| void _mi_unmap_file | ( | MI_INFO * | info | ) |
Definition at line 273 of file mi_dynrec.c.
References _mi_rec_pack(), _my_calc_total_blob_length(), ALIGN_SIZE, st_mi_isam_share::base, error, HA_ERR_TO_BIG_ROW, MI_DYN_DELETE_BLOCK_HEADER, MI_DYN_MAX_ROW_LENGTH, MI_MAX_DYN_BLOCK_HEADER, MI_SPLIT_LENGTH, my_afree, my_alloca, my_errno, st_mi_base_info::pack_reclength, reclength, st_myisam_info::s, and update_dynamic_record().
Referenced by mi_setup_functions().
00274 { 00275 byte *rec_buff; 00276 int error; 00277 ulong reclength,extra; 00278 00279 extra= (ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+ 00280 MI_DYN_DELETE_BLOCK_HEADER); 00281 reclength= (info->s->base.pack_reclength+ 00282 _my_calc_total_blob_length(info,record)+ extra); 00283 #ifdef NOT_USED /* We now support big rows */ 00284 if (reclength > MI_DYN_MAX_ROW_LENGTH) 00285 { 00286 my_errno=HA_ERR_TO_BIG_ROW; 00287 return -1; 00288 } 00289 #endif 00290 if (!(rec_buff=(byte*) my_alloca(reclength))) 00291 { 00292 my_errno=ENOMEM; 00293 return(-1); 00294 } 00295 reclength=_mi_rec_pack(info,rec_buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER), 00296 record); 00297 error=update_dynamic_record(info,pos, 00298 rec_buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER), 00299 reclength); 00300 my_afree(rec_buff); 00301 return(error); 00302 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 233 of file mi_dynrec.c.
References _mi_rec_pack(), st_myisam_info::rec_buff, and update_dynamic_record().
Referenced by mi_setup_functions().
00234 { 00235 uint length=_mi_rec_pack(info,info->rec_buff,record); 00236 return (update_dynamic_record(info,pos,info->rec_buff,length)); 00237 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 89 of file mi_statrec.c.
References st_mi_isam_share::base, st_mi_isam_share::file_write, MY_NABP, MYF, st_myisam_info::rec_cache, st_mi_base_info::reclength, st_myisam_info::s, and st_io_cache::seek_not_done.
Referenced by mi_setup_functions().
00090 { 00091 info->rec_cache.seek_not_done=1; /* We have done a seek */ 00092 return (info->s->file_write(info, 00093 (char*) record,info->s->base.reclength, 00094 pos, 00095 MYF(MY_NABP)) != 0); 00096 }
Here is the caller graph for this function:

Definition at line 239 of file mi_dynrec.c.
References _mi_rec_pack(), _my_calc_total_blob_length(), ALIGN_SIZE, st_mi_isam_share::base, DBUG_ASSERT, DBUG_PRINT, error, HA_ERR_TO_BIG_ROW, MI_DYN_DELETE_BLOCK_HEADER, MI_DYN_MAX_ROW_LENGTH, MI_MAX_DYN_BLOCK_HEADER, MI_SPLIT_LENGTH, my_afree, my_alloca, my_errno, st_mi_base_info::pack_reclength, reclength, st_myisam_info::s, and write_dynamic_record().
Referenced by mi_setup_functions().
00240 { 00241 byte *rec_buff; 00242 int error; 00243 ulong reclength,reclength2,extra; 00244 00245 extra= (ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+ 00246 MI_DYN_DELETE_BLOCK_HEADER+1); 00247 reclength= (info->s->base.pack_reclength + 00248 _my_calc_total_blob_length(info,record)+ extra); 00249 #ifdef NOT_USED /* We now support big rows */ 00250 if (reclength > MI_DYN_MAX_ROW_LENGTH) 00251 { 00252 my_errno=HA_ERR_TO_BIG_ROW; 00253 return -1; 00254 } 00255 #endif 00256 if (!(rec_buff=(byte*) my_alloca(reclength))) 00257 { 00258 my_errno=ENOMEM; 00259 return(-1); 00260 } 00261 reclength2= _mi_rec_pack(info,rec_buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER), 00262 record); 00263 DBUG_PRINT("info",("reclength: %lu reclength2: %lu", 00264 reclength, reclength2)); 00265 DBUG_ASSERT(reclength2 <= reclength); 00266 error=write_dynamic_record(info,rec_buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER), 00267 reclength2); 00268 my_afree(rec_buff); 00269 return(error); 00270 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 227 of file mi_dynrec.c.
References _mi_rec_pack(), st_myisam_info::rec_buff, reclength, and write_dynamic_record().
Referenced by mi_setup_functions().
00228 { 00229 ulong reclength=_mi_rec_pack(info,info->rec_buff,record); 00230 return (write_dynamic_record(info,info->rec_buff,reclength)); 00231 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int _mi_write_keypage | ( | MI_INFO * | info, | |
| MI_KEYDEF * | keyinfo, | |||
| my_off_t | page, | |||
| int | level, | |||
| uchar * | buff | |||
| ) |
| int _mi_write_part_record | ( | MI_INFO * | info, | |
| my_off_t | filepos, | |||
| ulong | length, | |||
| my_off_t | next_filepos, | |||
| byte ** | record, | |||
| ulong * | reclength, | |||
| int * | flag | |||
| ) |
Definition at line 558 of file mi_dynrec.c.
References _mi_get_block_info(), st_myisam_info::append_insert_at_end, bfill, BLOCK_DELETED, bmove(), bzero, st_mi_status_info::data_file_length, DBUG_DUMP, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_mi_status_info::del, st_mi_state_info::dellink, st_myisam_info::dfile, st_mi_status_info::empty, err, extra_length, st_mi_isam_share::file_write, HA_OFFSET_ERROR, HA_STATE_EXTEND_BLOCK, HA_STATE_WRITE_AT_END, memcpy, MI_DYN_ALIGN_SIZE, MI_DYN_DELETE_BLOCK_HEADER, MI_DYN_MAX_BLOCK_LENGTH, MI_EXTEND_BLOCK_LENGTH, mi_int2store, mi_int3store, mi_int4store, MI_MAX_BLOCK_LENGTH, mi_sizestore, MI_SPLIT_LENGTH, MY_ALIGN, my_b_write, my_block_write(), my_errno, st_myisam_info::opt_flag, pos(), st_myisam_info::rec_cache, st_myisam_info::s, st_mi_block_info::second_read, st_io_cache::seek_not_done, st_mi_state_info::split, st_myisam_info::state, st_mi_isam_share::state, unlink_deleted_block(), st_myisam_info::update, update_backward_delete_link(), WRITE_CACHE_USED, and st_mi_isam_share::write_flag.
Referenced by sort_write_record(), update_dynamic_record(), and write_dynamic_record().
00565 { 00566 ulong head_length,res_length,extra_length,long_block,del_length; 00567 byte *pos,*record_end; 00568 my_off_t next_delete_block; 00569 uchar temp[MI_SPLIT_LENGTH+MI_DYN_DELETE_BLOCK_HEADER]; 00570 DBUG_ENTER("_mi_write_part_record"); 00571 00572 next_delete_block=HA_OFFSET_ERROR; 00573 00574 res_length=extra_length=0; 00575 if (length > *reclength + MI_SPLIT_LENGTH) 00576 { /* Splitt big block */ 00577 res_length=MY_ALIGN(length- *reclength - MI_EXTEND_BLOCK_LENGTH, 00578 MI_DYN_ALIGN_SIZE); 00579 length-= res_length; /* Use this for first part */ 00580 } 00581 long_block= (length < 65520L && *reclength < 65520L) ? 0 : 1; 00582 if (length == *reclength+ 3 + long_block) 00583 { 00584 /* Block is exactly of the right length */ 00585 temp[0]=(uchar) (1+ *flag)+(uchar) long_block; /* Flag is 0 or 6 */ 00586 if (long_block) 00587 { 00588 mi_int3store(temp+1,*reclength); 00589 head_length=4; 00590 } 00591 else 00592 { 00593 mi_int2store(temp+1,*reclength); 00594 head_length=3; 00595 } 00596 } 00597 else if (length-long_block < *reclength+4) 00598 { /* To short block */ 00599 if (next_filepos == HA_OFFSET_ERROR) 00600 next_filepos= (info->s->state.dellink != HA_OFFSET_ERROR && 00601 !info->append_insert_at_end ? 00602 info->s->state.dellink : info->state->data_file_length); 00603 if (*flag == 0) /* First block */ 00604 { 00605 if (*reclength > MI_MAX_BLOCK_LENGTH) 00606 { 00607 head_length= 16; 00608 temp[0]=13; 00609 mi_int4store(temp+1,*reclength); 00610 mi_int3store(temp+5,length-head_length); 00611 mi_sizestore((byte*) temp+8,next_filepos); 00612 } 00613 else 00614 { 00615 head_length=5+8+long_block*2; 00616 temp[0]=5+(uchar) long_block; 00617 if (long_block) 00618 { 00619 mi_int3store(temp+1,*reclength); 00620 mi_int3store(temp+4,length-head_length); 00621 mi_sizestore((byte*) temp+7,next_filepos); 00622 } 00623 else 00624 { 00625 mi_int2store(temp+1,*reclength); 00626 mi_int2store(temp+3,length-head_length); 00627 mi_sizestore((byte*) temp+5,next_filepos); 00628 } 00629 } 00630 } 00631 else 00632 { 00633 head_length=3+8+long_block; 00634 temp[0]=11+(uchar) long_block; 00635 if (long_block) 00636 { 00637 mi_int3store(temp+1,length-head_length); 00638 mi_sizestore((byte*) temp+4,next_filepos); 00639 } 00640 else 00641 { 00642 mi_int2store(temp+1,length-head_length); 00643 mi_sizestore((byte*) temp+3,next_filepos); 00644 } 00645 } 00646 } 00647 else 00648 { /* Block with empty info last */ 00649 head_length=4+long_block; 00650 extra_length= length- *reclength-head_length; 00651 temp[0]= (uchar) (3+ *flag)+(uchar) long_block; /* 3,4 or 9,10 */ 00652 if (long_block) 00653 { 00654 mi_int3store(temp+1,*reclength); 00655 temp[4]= (uchar) (extra_length); 00656 } 00657 else 00658 { 00659 mi_int2store(temp+1,*reclength); 00660 temp[3]= (uchar) (extra_length); 00661 } 00662 length= *reclength+head_length; /* Write only what is needed */ 00663 } 00664 DBUG_DUMP("header",(byte*) temp,head_length); 00665 00666 /* Make a long block for one write */ 00667 record_end= *record+length-head_length; 00668 del_length=(res_length ? MI_DYN_DELETE_BLOCK_HEADER : 0); 00669 bmove((byte*) (*record-head_length),(byte*) temp,head_length); 00670 memcpy(temp,record_end,(size_t) (extra_length+del_length)); 00671 bzero((byte*) record_end,extra_length); 00672 00673 if (res_length) 00674 { 00675 /* Check first if we can join this block with the next one */ 00676 MI_BLOCK_INFO del_block; 00677 my_off_t next_block=filepos+length+extra_length+res_length; 00678 00679 del_block.second_read=0; 00680 if (next_block < info->state->data_file_length && 00681 info->s->state.dellink != HA_OFFSET_ERROR) 00682 { 00683 if ((_mi_get_block_info(&del_block,info->dfile,next_block) 00684 & BLOCK_DELETED) && 00685 res_length + del_block.block_len < MI_DYN_MAX_BLOCK_LENGTH) 00686 { 00687 if (unlink_deleted_block(info,&del_block)) 00688 goto err; 00689 res_length+=del_block.block_len; 00690 } 00691 } 00692 00693 /* Create a delete link of the last part of the block */ 00694 pos=record_end+extra_length; 00695 pos[0]= '\0'; 00696 mi_int3store(pos+1,res_length); 00697 mi_sizestore(pos+4,info->s->state.dellink); 00698 bfill(pos+12,8,255); /* End link */ 00699 next_delete_block=info->s->state.dellink; 00700 info->s->state.dellink= filepos+length+extra_length; 00701 info->state->del++; 00702 info->state->empty+=res_length; 00703 info->s->state.split++; 00704 } 00705 if (info->opt_flag & WRITE_CACHE_USED && 00706 info->update & HA_STATE_WRITE_AT_END) 00707 { 00708 if (info->update & HA_STATE_EXTEND_BLOCK) 00709 { 00710 info->update&= ~HA_STATE_EXTEND_BLOCK; 00711 if (my_block_write(&info->rec_cache,(byte*) *record-head_length, 00712 length+extra_length+del_length,filepos)) 00713 goto err; 00714 } 00715 else if (my_b_write(&info->rec_cache,(byte*) *record-head_length, 00716 length+extra_length+del_length)) 00717 goto err; 00718 } 00719 else 00720 { 00721 info->rec_cache.seek_not_done=1; 00722 if (info->s->file_write(info,(byte*) *record-head_length,length+extra_length+ 00723 del_length,filepos,info->s->write_flag)) 00724 goto err; 00725 } 00726 memcpy(record_end,temp,(size_t) (extra_length+del_length)); 00727 *record=record_end; 00728 *reclength-=(length-head_length); 00729 *flag=6; 00730 00731 if (del_length) 00732 { 00733 /* link the next delete block to this */ 00734 if (update_backward_delete_link(info, next_delete_block, 00735 info->s->state.dellink)) 00736 goto err; 00737 } 00738 00739 DBUG_RETURN(0); 00740 err: 00741 DBUG_PRINT("exit",("errno: %d",my_errno)); 00742 DBUG_RETURN(1); 00743 } /*_mi_write_part_record */
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 22 of file mi_statrec.c.
References _mi_rec_pos(), st_myisam_info::append_insert_at_end, st_mi_isam_share::base, bzero, st_mi_status_info::data_file_length, st_mi_status_info::del, st_mi_state_info::dellink, st_mi_status_info::empty, err, st_mi_isam_share::file_read, st_mi_isam_share::file_write, HA_ERR_RECORD_FILE_FULL, HA_OFFSET_ERROR, st_mi_base_info::max_data_file_length, my_b_write, my_errno, MY_NABP, MYF, st_myisam_info::opt_flag, st_mi_base_info::pack_reclength, st_myisam_info::rec_cache, st_mi_base_info::rec_reflength, st_mi_base_info::reclength, st_myisam_info::s, st_io_cache::seek_not_done, st_mi_state_info::split, st_myisam_info::state, st_mi_isam_share::state, WRITE_CACHE_USED, and st_mi_isam_share::write_flag.
Referenced by mi_setup_functions().
00023 { 00024 uchar temp[8]; /* max pointer length */ 00025 if (info->s->state.dellink != HA_OFFSET_ERROR && 00026 !info->append_insert_at_end) 00027 { 00028 my_off_t filepos=info->s->state.dellink; 00029 info->rec_cache.seek_not_done=1; /* We have done a seek */ 00030 if (info->s->file_read(info,(char*) &temp[0],info->s->base.rec_reflength, 00031 info->s->state.dellink+1, 00032 MYF(MY_NABP))) 00033 goto err; 00034 info->s->state.dellink= _mi_rec_pos(info->s,temp); 00035 info->state->del--; 00036 info->state->empty-=info->s->base.pack_reclength; 00037 if (info->s->file_write(info, (char*) record, info->s->base.reclength, 00038 filepos, 00039 MYF(MY_NABP))) 00040 goto err; 00041 } 00042 else 00043 { 00044 if (info->state->data_file_length > info->s->base.max_data_file_length- 00045 info->s->base.pack_reclength) 00046 { 00047 my_errno=HA_ERR_RECORD_FILE_FULL; 00048 return(2); 00049 } 00050 if (info->opt_flag & WRITE_CACHE_USED) 00051 { /* Cash in use */ 00052 if (my_b_write(&info->rec_cache, (byte*) record, 00053 info->s->base.reclength)) 00054 goto err; 00055 if (info->s->base.pack_reclength != info->s->base.reclength) 00056 { 00057 uint length=info->s->base.pack_reclength - info->s->base.reclength; 00058 bzero((char*) temp,length); 00059 if (my_b_write(&info->rec_cache, (byte*) temp,length)) 00060 goto err; 00061 } 00062 } 00063 else 00064 { 00065 info->rec_cache.seek_not_done=1; /* We have done a seek */ 00066 if (info->s->file_write(info,(char*) record,info->s->base.reclength, 00067 info->state->data_file_length, 00068 info->s->write_flag)) 00069 goto err; 00070 if (info->s->base.pack_reclength != info->s->base.reclength) 00071 { 00072 uint length=info->s->base.pack_reclength - info->s->base.reclength; 00073 bzero((char*) temp,length); 00074 if (info->s->file_write(info, (byte*) temp,length, 00075 info->state->data_file_length+ 00076 info->s->base.reclength, 00077 info->s->write_flag)) 00078 goto err; 00079 } 00080 } 00081 info->state->data_file_length+=info->s->base.pack_reclength; 00082 info->s->state.split++; 00083 } 00084 return 0; 00085 err: 00086 return 1; 00087 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1252 of file mi_dynrec.c.
References _mi_calc_blob_length(), st_mi_isam_share::base, st_mi_base_info::blobs, st_myisam_info::blobs, st_mi_blob::length, st_mi_blob::offset, st_mi_blob::pack_length, and st_myisam_info::s.
Referenced by _mi_cmp_dynamic_record(), _mi_update_blob_record(), _mi_write_blob_record(), _myisam_log_record(), and sort_write_record().
01253 { 01254 ulong length; 01255 MI_BLOB *blob,*end; 01256 01257 for (length=0, blob= info->blobs, end=blob+info->s->base.blobs ; 01258 blob != end; 01259 blob++) 01260 { 01261 blob->length=_mi_calc_blob_length(blob->pack_length,record + blob->offset); 01262 length+=blob->length; 01263 } 01264 return length; 01265 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1286 of file mi_dynrec.c.
References int2store, int3store, and int4store.
Referenced by _mi_put_key_in_record(), and uf_blob().
01287 { 01288 switch (pack_length) { 01289 case 1: 01290 *pos= (uchar) length; 01291 break; 01292 case 2: 01293 int2store(pos,length); 01294 break; 01295 case 3: 01296 int3store(pos,length); 01297 break; 01298 case 4: 01299 int4store(pos,length); 01300 default: 01301 break; 01302 } 01303 return; 01304 }
Here is the caller graph for this function:

| void _myisam_log | ( | enum myisam_log_commands | command, | |
| MI_INFO * | info, | |||
| const byte * | buffert, | |||
| uint | length | |||
| ) |
Definition at line 77 of file mi_log.c.
References bzero, st_myisam_info::dfile, error, F_TO_EOF, F_UNLCK, F_WRLCK, GETPID, mi_int2store, mi_int4store, my_errno, my_lock(), MY_SEEK_NOT_DONE, my_write, MYF, myisam_log_file, pthread_mutex_lock, pthread_mutex_unlock, and VOID.
00079 { 00080 char buff[11]; 00081 int error,old_errno; 00082 ulong pid=(ulong) GETPID(); 00083 old_errno=my_errno; 00084 bzero(buff,sizeof(buff)); 00085 buff[0]=(char) command; 00086 mi_int2store(buff+1,info->dfile); 00087 mi_int4store(buff+3,pid); 00088 mi_int2store(buff+9,length); 00089 00090 pthread_mutex_lock(&THR_LOCK_myisam); 00091 error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); 00092 VOID(my_write(myisam_log_file,buff,sizeof(buff),MYF(0))); 00093 VOID(my_write(myisam_log_file,buffert,length,MYF(0))); 00094 if (!error) 00095 error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); 00096 pthread_mutex_unlock(&THR_LOCK_myisam); 00097 my_errno=old_errno; 00098 }
Here is the call graph for this function:

| void _myisam_log_command | ( | enum myisam_log_commands | command, | |
| MI_INFO * | info, | |||
| const byte * | buffert, | |||
| uint | length, | |||
| int | result | |||
| ) |
Definition at line 101 of file mi_log.c.
References st_myisam_info::dfile, error, F_TO_EOF, F_UNLCK, F_WRLCK, GETPID, mi_int2store, mi_int4store, my_errno, my_lock(), MY_SEEK_NOT_DONE, my_write, MYF, myisam_log_file, pthread_mutex_lock, pthread_mutex_unlock, and VOID.
00103 { 00104 char buff[9]; 00105 int error,old_errno; 00106 ulong pid=(ulong) GETPID(); 00107 00108 old_errno=my_errno; 00109 buff[0]=(char) command; 00110 mi_int2store(buff+1,info->dfile); 00111 mi_int4store(buff+3,pid); 00112 mi_int2store(buff+7,result); 00113 pthread_mutex_lock(&THR_LOCK_myisam); 00114 error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); 00115 VOID(my_write(myisam_log_file,buff,sizeof(buff),MYF(0))); 00116 if (buffert) 00117 VOID(my_write(myisam_log_file,buffert,length,MYF(0))); 00118 if (!error) 00119 error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); 00120 pthread_mutex_unlock(&THR_LOCK_myisam); 00121 my_errno=old_errno; 00122 }
Here is the call graph for this function:

| void _myisam_log_record | ( | enum myisam_log_commands | command, | |
| MI_INFO * | info, | |||
| const byte * | record, | |||
| my_off_t | filepos, | |||
| int | result | |||
| ) |
Definition at line 125 of file mi_log.c.
References _my_calc_total_blob_length(), st_mi_isam_share::base, st_myisam_info::blobs, st_mi_base_info::blobs, st_myisam_info::dfile, error, F_TO_EOF, F_UNLCK, F_WRLCK, GETPID, st_mi_blob::length, memcpy_fixed, mi_int2store, mi_int4store, mi_sizestore, my_errno, my_lock(), MY_SEEK_NOT_DONE, my_write, MYF, myisam_log_file, st_mi_blob::offset, st_mi_blob::pack_length, pos(), pthread_mutex_lock, pthread_mutex_unlock, st_mi_base_info::reclength, st_myisam_info::s, and VOID.
00127 { 00128 char buff[21],*pos; 00129 int error,old_errno; 00130 uint length; 00131 ulong pid=(ulong) GETPID(); 00132 00133 old_errno=my_errno; 00134 if (!info->s->base.blobs) 00135 length=info->s->base.reclength; 00136 else 00137 length=info->s->base.reclength+ _my_calc_total_blob_length(info,record); 00138 buff[0]=(char) command; 00139 mi_int2store(buff+1,info->dfile); 00140 mi_int4store(buff+3,pid); 00141 mi_int2store(buff+7,result); 00142 mi_sizestore(buff+9,filepos); 00143 mi_int4store(buff+17,length); 00144 pthread_mutex_lock(&THR_LOCK_myisam); 00145 error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); 00146 VOID(my_write(myisam_log_file,buff,sizeof(buff),MYF(0))); 00147 VOID(my_write(myisam_log_file,(byte*) record,info->s->base.reclength,MYF(0))); 00148 if (info->s->base.blobs) 00149 { 00150 MI_BLOB *blob,*end; 00151 00152 for (end=info->blobs+info->s->base.blobs, blob= info->blobs; 00153 blob != end ; 00154 blob++) 00155 { 00156 memcpy_fixed(&pos,record+blob->offset+blob->pack_length,sizeof(char*)); 00157 VOID(my_write(myisam_log_file,pos,blob->length,MYF(0))); 00158 } 00159 } 00160 if (!error) 00161 error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); 00162 pthread_mutex_unlock(&THR_LOCK_myisam); 00163 my_errno=old_errno; 00164 }
Here is the call graph for this function:

| void mi_check_print_info _VARARGS | ( | (MI_CHECK *param, const char *fmt,...) | ) |
Definition at line 1342 of file mi_packrec.c.
01343 { 01344 return (length < 254) ? 1 : (length < 65536) ? 3 : (version == 1) ? 4 : 5; 01345 }
| my_bool check_table_is_closed | ( | const char * | name, | |
| const char * | where | |||
| ) |
Definition at line 1705 of file mi_check.c.
References end_key_cache(), flush_key_blocks(), FLUSH_RELEASE, mi_check_print_error(), my_errno, and st_mi_check_param::using_global_keycache.
Referenced by myisamchk().
01706 { 01707 if (flush_key_blocks(key_cache, file, FLUSH_RELEASE)) 01708 { 01709 mi_check_print_error(param,"%d when trying to write bufferts",my_errno); 01710 return(1); 01711 } 01712 if (!param->using_global_keycache) 01713 end_key_cache(key_cache,1); 01714 return 0; 01715 } /* flush_blocks */
Here is the call graph for this function:

Here is the caller graph for this function:

| int flush_pending_blocks | ( | MI_SORT_PARAM * | param | ) |
Definition at line 3737 of file mi_check.c.
References _mi_kpointer(), _mi_new(), _mi_write_keypage(), st_mi_keydef::block_length, st_sort_key_blocks::buff, bzero, DBUG_DUMP, DBUG_ENTER, DBUG_RETURN, DFLT_INIT_HITS, st_sort_key_blocks::end_pos, HA_OFFSET_ERROR, st_sort_info::info, st_sort_key_blocks::inited, st_mi_sort_param::key, st_sort_info::key_block, st_mi_state_info::key_root, st_mi_sort_param::keyinfo, keyinfo, mi_getint, my_pwrite(), st_mi_check_param::myf_rw, st_sort_info::param, st_myisam_info::s, st_mi_sort_param::sort_info, and st_mi_isam_share::state.
Referenced by _create_index_by_sort(), and sort_ft_buf_flush().
03738 { 03739 uint nod_flag,length; 03740 my_off_t filepos,key_file_length; 03741 SORT_KEY_BLOCKS *key_block; 03742 SORT_INFO *sort_info= sort_param->sort_info; 03743 myf myf_rw=sort_info->param->myf_rw; 03744 MI_INFO *info=sort_info->info; 03745 MI_KEYDEF *keyinfo=sort_param->keyinfo; 03746 DBUG_ENTER("flush_pending_blocks"); 03747 03748 filepos= HA_OFFSET_ERROR; /* if empty file */ 03749 nod_flag=0; 03750 for (key_block=sort_info->key_block ; key_block->inited ; key_block++) 03751 { 03752 key_block->inited=0; 03753 length=mi_getint(key_block->buff); 03754 if (nod_flag) 03755 _mi_kpointer(info,key_block->end_pos,filepos); 03756 key_file_length=info->state->key_file_length; 03757 bzero((byte*) key_block->buff+length, keyinfo->block_length-length); 03758 if ((filepos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR) 03759 DBUG_RETURN(1); 03760 03761 /* If we read the page from the key cache, we have to write it back */ 03762 if (key_file_length == info->state->key_file_length) 03763 { 03764 if (_mi_write_keypage(info, keyinfo, filepos, 03765 DFLT_INIT_HITS, key_block->buff)) 03766 DBUG_RETURN(1); 03767 } 03768 else if (my_pwrite(info->s->kfile,(byte*) key_block->buff, 03769 (uint) keyinfo->block_length,filepos, myf_rw)) 03770 DBUG_RETURN(1); 03771 DBUG_DUMP("buff",(byte*) key_block->buff,length); 03772 nod_flag=1; 03773 } 03774 info->s->state.key_root[sort_param->key]=filepos; /* Last is root for tree */ 03775 DBUG_RETURN(0); 03776 } /* flush_pending_blocks */
Here is the call graph for this function:

Here is the caller graph for this function:

| int ha_key_cmp | ( | HA_KEYSEG * | keyseg, | |
| uchar * | a, | |||
| uchar * | b, | |||
| uint | key_length, | |||
| uint | nextflag, | |||
| uint * | diff_length | |||
| ) |
| volatile int* killed_ptr | ( | MI_CHECK * | param | ) |
Definition at line 103 of file ha_myisam.cc.
References st_mi_check_param::thd.
00104 { 00105 /* In theory Unsafe conversion, but should be ok for now */ 00106 return (int*) &(((THD *)(param->thd))->killed); 00107 }
Definition at line 661 of file mi_open.c.
References ALIGN_SIZE, st_mi_isam_share::base, LINT_INIT, max, st_mi_base_info::max_key_length, mi_get_rec_buff_len, MI_MAX_DYN_BLOCK_HEADER, MI_REC_BUFF_OFFSET, MI_SPLIT_LENGTH, MY_ALLOW_ZERO_PTR, my_realloc(), MYF, st_mi_isam_share::options, st_mi_base_info::pack_reclength, and st_myisam_info::s.
Referenced by _mi_pack_get_block_info(), _mi_read_dynamic_record(), _mi_read_rnd_dynamic_record(), mi_repair(), mi_repair_by_sort(), mi_repair_parallel(), and mi_reset().
00662 { 00663 uint extra; 00664 uint32 old_length; 00665 LINT_INIT(old_length); 00666 00667 if (! *buf || length > (old_length=mi_get_rec_buff_len(info, *buf))) 00668 { 00669 byte *newptr = *buf; 00670 00671 /* to simplify initial init of info->rec_buf in mi_open and mi_extra */ 00672 if (length == (ulong) -1) 00673 { 00674 length= max(info->s->base.pack_reclength, 00675 info->s->base.max_key_length); 00676 /* Avoid unnecessary realloc */ 00677 if (newptr && length == old_length) 00678 return newptr; 00679 } 00680 00681 extra= ((info->s->options & HA_OPTION_PACK_RECORD) ? 00682 ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+ 00683 MI_REC_BUFF_OFFSET : 0); 00684 if (extra && newptr) 00685 newptr-= MI_REC_BUFF_OFFSET; 00686 if (!(newptr=(byte*) my_realloc((gptr)newptr, length+extra+8, 00687 MYF(MY_ALLOW_ZERO_PTR)))) 00688 return newptr; 00689 *((uint32 *) newptr)= (uint32) length; 00690 *buf= newptr+(extra ? MI_REC_BUFF_OFFSET : 0); 00691 } 00692 return *buf; 00693 }
Here is the call graph for this function:

Here is the caller graph for this function:

| uint mi_base_info_write | ( | File | file, | |
| MI_BASE_INFO * | base | |||
| ) |
Definition at line 959 of file mi_open.c.
References st_mi_base_info::auto_key, st_mi_base_info::blobs, bzero, st_mi_base_info::extra_alloc_bytes, st_mi_base_info::extra_alloc_procent, st_mi_base_info::fields, st_mi_base_info::key_reflength, st_mi_base_info::keys, st_mi_base_info::keystart, st_mi_base_info::max_data_file_length, st_mi_base_info::max_key_block_length, st_mi_base_info::max_key_file_length, st_mi_base_info::max_key_length, st_mi_base_info::max_pack_length, st_mi_base_info::mean_row_length, MI_BASE_INFO_SIZE, mi_int2store, mi_int4store, mi_rowstore, mi_sizestore, st_mi_base_info::min_block_length, st_mi_base_info::min_pack_length, MY_NABP, my_write, MYF, st_mi_base_info::pack_bits, st_mi_base_info::pack_fields, st_mi_base_info::pack_reclength, st_mi_base_info::raid_chunks, st_mi_base_info::raid_chunksize, st_mi_base_info::raid_type, st_mi_base_info::rec_reflength, st_mi_base_info::reclength, st_mi_base_info::records, and st_mi_base_info::reloc.
00960 { 00961 uchar buff[MI_BASE_INFO_SIZE], *ptr=buff; 00962 00963 mi_sizestore(ptr,base->keystart); ptr +=8; 00964 mi_sizestore(ptr,base->max_data_file_length); ptr +=8; 00965 mi_sizestore(ptr,base->max_key_file_length); ptr +=8; 00966 mi_rowstore(ptr,base->records); ptr +=8; 00967 mi_rowstore(ptr,base->reloc); ptr +=8; 00968 mi_int4store(ptr,base->mean_row_length); ptr +=4; 00969 mi_int4store(ptr,base->reclength); ptr +=4; 00970 mi_int4store(ptr,base->pack_reclength); ptr +=4; 00971 mi_int4store(ptr,base->min_pack_length); ptr +=4; 00972 mi_int4store(ptr,base->max_pack_length); ptr +=4; 00973 mi_int4store(ptr,base->min_block_length); ptr +=4; 00974 mi_int4store(ptr,base->fields); ptr +=4; 00975 mi_int4store(ptr,base->pack_fields); ptr +=4; 00976 *ptr++=base->rec_reflength; 00977 *ptr++=base->key_reflength; 00978 *ptr++=base->keys; 00979 *ptr++=base->auto_key; 00980 mi_int2store(ptr,base->pack_bits); ptr +=2; 00981 mi_int2store(ptr,base->blobs); ptr +=2; 00982 mi_int2store(ptr,base->max_key_block_length); ptr +=2; 00983 mi_int2store(ptr,base->max_key_length); ptr +=2; 00984 mi_int2store(ptr,base->extra_alloc_bytes); ptr +=2; 00985 *ptr++= base->extra_alloc_procent; 00986 *ptr++= base->raid_type; 00987 mi_int2store(ptr,base->raid_chunks); ptr +=2; 00988 mi_int4store(ptr,base->raid_chunksize); ptr +=4; 00989 bzero(ptr,6); ptr +=6; /* extra */ 00990 return my_write(file,(char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); 00991 }
| my_bool mi_check_status | ( | void * | param | ) |
Definition at line 354 of file mi_locking.c.
References DBUG_PRINT, st_mi_state_info::dellink, HA_OFFSET_ERROR, info, myisam_concurrent_insert, st_mi_isam_share::r_locks, st_myisam_info::s, st_mi_isam_share::state, and st_mi_isam_share::w_locks.
00355 { 00356 MI_INFO *info=(MI_INFO*) param; 00357 /* 00358 The test for w_locks == 1 is here because this thread has already done an 00359 external lock (in other words: w_locks == 1 means no other threads has 00360 a write lock) 00361 */ 00362 DBUG_PRINT("info",("dellink: %ld r_locks: %u w_locks: %u", 00363 (long) info->s->state.dellink, (uint) info->s->r_locks, 00364 (uint) info->s->w_locks)); 00365 return (my_bool) !(info->s->state.dellink == HA_OFFSET_ERROR || 00366 (myisam_concurrent_insert == 2 && info->s->r_locks && 00367 info->s->w_locks == 1)); 00368 }
| my_bool mi_check_unique | ( | MI_INFO * | info, | |
| MI_UNIQUEDEF * | def, | |||
| byte * | record, | |||
| ha_checksum | unique_hash, | |||
| my_off_t | pos | |||
| ) |
Definition at line 22 of file mi_unique.c.
References _mi_make_key(), _mi_search(), _mi_search_next(), bcmp, st_mi_isam_share::compare_unique, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_myisam_info::dupp_key_pos, st_myisam_info::errkey, HA_ERR_FOUND_DUPP_UNIQUE, HA_STATE_RNEXT_SAME, st_unique_def::key, key, st_mi_state_info::key_root, st_mi_isam_share::keyinfo, st_myisam_info::lastkey, st_myisam_info::lastkey2, st_myisam_info::lastpos, MI_UNIQUE_HASH_LENGTH, mi_unique_store, my_errno, st_myisam_info::page_changed, st_myisam_info::s, SEARCH_BIGGER, SEARCH_FIND, st_mi_isam_share::state, and st_myisam_info::update.
00024 { 00025 my_off_t lastpos=info->lastpos; 00026 MI_KEYDEF *key= &info->s->keyinfo[def->key]; 00027 uchar *key_buff=info->lastkey2; 00028 DBUG_ENTER("mi_check_unique"); 00029 00030 mi_unique_store(record+key->seg->start, unique_hash); 00031 _mi_make_key(info,def->key,key_buff,record,0); 00032 00033 /* The above changed info->lastkey2. Inform mi_rnext_same(). */ 00034 info->update&= ~HA_STATE_RNEXT_SAME; 00035 00036 if (_mi_search(info,info->s->keyinfo+def->key,key_buff,MI_UNIQUE_HASH_LENGTH, 00037 SEARCH_FIND,info->s->state.key_root[def->key])) 00038 { 00039 info->page_changed=1; /* Can't optimize read next */ 00040 info->lastpos= lastpos; 00041 DBUG_RETURN(0); /* No matching rows */ 00042 } 00043 00044 for (;;) 00045 { 00046 if (info->lastpos != disk_pos && 00047 !(*info->s->compare_unique)(info,def,record,info->lastpos)) 00048 { 00049 my_errno=HA_ERR_FOUND_DUPP_UNIQUE; 00050 info->errkey= (int) def->key; 00051 info->dupp_key_pos= info->lastpos; 00052 info->page_changed=1; /* Can't optimize read next */ 00053 info->lastpos=lastpos; 00054 DBUG_PRINT("info",("Found duplicate")); 00055 DBUG_RETURN(1); /* Found identical */ 00056 } 00057 if (_mi_search_next(info,info->s->keyinfo+def->key, info->lastkey, 00058 MI_UNIQUE_HASH_LENGTH, SEARCH_BIGGER, 00059 info->s->state.key_root[def->key]) || 00060 bcmp(info->lastkey, key_buff, MI_UNIQUE_HASH_LENGTH)) 00061 { 00062 info->page_changed=1; /* Can't optimize read next */ 00063 info->lastpos=lastpos; 00064 DBUG_RETURN(0); /* end of tree */ 00065 } 00066 } 00067 }
Here is the call graph for this function:

| ha_checksum mi_checksum | ( | MI_INFO * | info, | |
| const byte * | buf | |||
| ) |
Definition at line 21 of file mi_checksum.c.
References _mi_calc_blob_length(), st_mi_isam_share::base, FIELD_BLOB, FIELD_VARCHAR, st_mi_base_info::fields, HA_VARCHAR_PACKLENGTH, st_columndef::length, memcpy, mi_portable_sizeof_char_ptr, my_checksum(), pos(), st_mi_isam_share::rec, st_myisam_info::s, st_columndef::type, and uint2korr.
Referenced by mi_setup_functions(), and sort_write_record().
00022 { 00023 uint i; 00024 ha_checksum crc=0; 00025 MI_COLUMNDEF *rec=info->s->rec; 00026 00027 for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length) 00028 { 00029 const byte *pos; 00030 ulong length; 00031 switch (rec->type) { 00032 case FIELD_BLOB: 00033 { 00034 length=_mi_calc_blob_length(rec->length- 00035 mi_portable_sizeof_char_ptr, 00036 buf); 00037 memcpy((char*) &pos, buf+rec->length- mi_portable_sizeof_char_ptr, 00038 sizeof(char*)); 00039 break; 00040 } 00041 case FIELD_VARCHAR: 00042 { 00043 uint pack_length= HA_VARCHAR_PACKLENGTH(rec->length-1); 00044 if (pack_length == 1) 00045 length= (ulong) *(uchar*) buf; 00046 else 00047 length= uint2korr(buf); 00048 pos= buf+pack_length; 00049 break; 00050 } 00051 default: 00052 length=rec->length; 00053 pos=buf; 00054 break; 00055 } 00056 crc=my_checksum(crc, pos ? pos : "", length); 00057 } 00058 return crc; 00059 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void mi_copy_status | ( | void * | to, | |
| void * | from | |||
| ) |
| int mi_disable_indexes | ( | MI_INFO * | info | ) |
Definition at line 1222 of file mi_open.c.
References st_mi_state_info::key_map, mi_clear_all_keys_active, st_myisam_info::s, and st_mi_isam_share::state.
Referenced by ha_myisam::disable_indexes().
01223 { 01224 MYISAM_SHARE *share= info->s; 01225 01226 mi_clear_all_keys_active(share->state.key_map); 01227 return 0; 01228 }
Here is the caller graph for this function:

Definition at line 4267 of file mi_check.c.
References st_mi_base_info::auto_key, st_mi_isam_share::base, DBUG_ASSERT, HA_AUTO_KEY, HA_NOSAME, HA_SPATIAL, HA_STATE_CHANGED, key, st_mi_state_info::key_map, st_mi_isam_share::keyinfo, st_mi_base_info::keys, mi_clear_key_active, MI_MIN_ROWS_TO_DISABLE_INDEXES, mi_too_big_key_for_sort(), st_mi_status_info::records, st_myisam_info::s, st_mi_isam_share::state, st_myisam_info::state, and st_myisam_info::update.
04268 { 04269 MYISAM_SHARE *share=info->s; 04270 MI_KEYDEF *key=share->keyinfo; 04271 uint i; 04272 04273 DBUG_ASSERT(info->state->records == 0 && 04274 (!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES)); 04275 for (i=0 ; i < share->base.keys ; i++,key++) 04276 { 04277 if (!(key->flag & (HA_NOSAME | HA_SPATIAL | HA_AUTO_KEY)) && 04278 ! mi_too_big_key_for_sort(key,rows) && info->s->base.auto_key != i+1) 04279 { 04280 mi_clear_key_active(share->state.key_map, i); 04281 info->update|= HA_STATE_CHANGED; 04282 } 04283 } 04284 }
Here is the call graph for this function:

| int mi_enable_indexes | ( | MI_INFO * | info | ) |
Definition at line 1250 of file mi_open.c.
References st_mi_isam_share::base, st_mi_status_info::data_file_length, error, HA_ERR_CRASHED, st_mi_status_info::key_file_length, st_mi_state_info::key_map, st_mi_base_info::keys, st_mi_base_info::keystart, mi_print_error, mi_set_all_keys_active, st_myisam_info::s, st_mi_state_info::state, and st_mi_isam_share::state.
Referenced by ha_myisam::enable_indexes().
01251 { 01252 int error= 0; 01253 MYISAM_SHARE *share= info->s; 01254 01255 if (share->state.state.data_file_length || 01256 (share->state.state.key_file_length != share->base.keystart)) 01257 { 01258 mi_print_error(info->s, HA_ERR_CRASHED); 01259 error= HA_ERR_CRASHED; 01260 } 01261 else 01262 mi_set_all_keys_active(share->state.key_map, share->base.keys); 01263 return error; 01264 }
Here is the caller graph for this function:

| void mi_get_status | ( | void * | param, | |
| int | concurrent_insert | |||
| ) |
Definition at line 264 of file mi_locking.c.
References st_myisam_info::append_insert_at_end, st_mi_status_info::data_file_length, DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, info, st_mi_status_info::key_file_length, st_myisam_info::s, st_myisam_info::save_state, st_myisam_info::state, st_mi_state_info::state, and st_mi_isam_share::state.
00265 { 00266 MI_INFO *info=(MI_INFO*) param; 00267 DBUG_ENTER("mi_get_status"); 00268 DBUG_PRINT("info",("key_file: %ld data_file: %ld concurrent_insert: %d", 00269 (long) info->s->state.state.key_file_length, 00270 (long) info->s->state.state.data_file_length, 00271 concurrent_insert)); 00272 #ifndef DBUG_OFF 00273 if (info->state->key_file_length > info->s->state.state.key_file_length || 00274 info->state->data_file_length > info->s->state.state.data_file_length) 00275 DBUG_PRINT("warning",("old info: key_file: %ld data_file: %ld", 00276 (long) info->state->key_file_length, 00277 (long) info->state->data_file_length)); 00278 #endif 00279 info->save_state=info->s->state.state; 00280 info->state= &info->save_state; 00281 info->append_insert_at_end= concurrent_insert; 00282 DBUG_VOID_RETURN; 00283 }
| int mi_indexes_are_disabled | ( | MI_INFO * | info | ) |
Definition at line 1283 of file mi_open.c.
References st_mi_isam_share::base, st_mi_state_info::key_map, st_mi_base_info::keys, mi_is_any_key_active, st_myisam_info::s, and st_mi_isam_share::state.
Referenced by ha_myisam::indexes_are_disabled().
01284 { 01285 MYISAM_SHARE *share= info->s; 01286 01287 return (! mi_is_any_key_active(share->state.key_map) && share->base.keys); 01288 }
Here is the caller graph for this function:

| char* mi_keydef_read | ( | char * | ptr, | |
| MI_KEYDEF * | keydef | |||
| ) |
Definition at line 1053 of file mi_open.c.
References st_mi_keydef::block_length, st_mi_keydef::block_size_index, st_mi_keydef::flag, ft_default_parser, st_mi_keydef::ftparser_nr, st_mi_keydef::key_alg, st_mi_keydef::keylength, st_mi_keydef::keysegs, st_mi_keydef::maxlength, MI_MIN_KEY_BLOCK_LENGTH, mi_uint2korr, st_mi_keydef::minlength, st_mi_keydef::parser, st_mi_keydef::underflow_block_length, and st_mi_keydef::version.
Referenced by mi_open().
01054 { 01055 keydef->keysegs = (uint) *ptr++; 01056 keydef->key_alg = *ptr++; /* Rtree or Btree */ 01057 01058 keydef->flag = mi_uint2korr(ptr); ptr +=2; 01059 keydef->block_length = mi_uint2korr(ptr); ptr +=2; 01060 keydef->keylength = mi_uint2korr(ptr); ptr +=2; 01061 keydef->minlength = mi_uint2korr(ptr); ptr +=2; 01062 keydef->maxlength = mi_uint2korr(ptr); ptr +=2; 01063 keydef->block_size_index= keydef->block_length/MI_MIN_KEY_BLOCK_LENGTH-1; 01064 keydef->underflow_block_length=keydef->block_length/3; 01065 keydef->version = 0; /* Not saved */ 01066 keydef->parser = &ft_default_parser; 01067 keydef->ftparser_nr = 0; 01068 return ptr; 01069 }
Here is the caller graph for this function:

Definition at line 1038 of file mi_open.c.
References st_mi_keydef::block_length, st_mi_keydef::flag, st_mi_keydef::key_alg, st_mi_keydef::keylength, st_mi_keydef::keysegs, st_mi_keydef::maxlength, mi_int2store, MI_KEYDEF_SIZE, st_mi_keydef::minlength, MY_NABP, my_write, and MYF.
01039 { 01040 uchar buff[MI_KEYDEF_SIZE]; 01041 uchar *ptr=buff; 01042 01043 *ptr++ = (uchar) keydef->keysegs; 01044 *ptr++ = keydef->key_alg; /* Rtree or Btree */ 01045 mi_int2store(ptr,keydef->flag); ptr +=2; 01046 mi_int2store(ptr,keydef->block_length); ptr +=2; 01047 mi_int2store(ptr,keydef->keylength); ptr +=2; 01048 mi_int2store(ptr,keydef->minlength); ptr +=2; 01049 mi_int2store(ptr,keydef->maxlength); ptr +=2; 01050 return my_write(file,(char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); 01051 }
| char* mi_keyseg_read | ( | char * | ptr, | |
| HA_KEYSEG * | keyseg | |||
| ) |
Definition at line 1098 of file mi_open.c.
References st_HA_KEYSEG::bit_end, st_HA_KEYSEG::bit_length, st_HA_KEYSEG::bit_pos, st_HA_KEYSEG::bit_start, st_HA_KEYSEG::charset, st_HA_KEYSEG::flag, keyseg, st_HA_KEYSEG::language, st_HA_KEYSEG::length, mi_uint2korr, mi_uint4korr, st_HA_KEYSEG::null_bit, st_HA_KEYSEG::null_pos, st_HA_KEYSEG::start, and st_HA_KEYSEG::type.
Referenced by mi_open().
01099 { 01100 keyseg->type = *ptr++; 01101 keyseg->language = *ptr++; 01102 keyseg->null_bit = *ptr++; 01103 keyseg->bit_start = *ptr++; 01104 keyseg->bit_end = *ptr++; 01105 keyseg->bit_length = *ptr++; 01106 keyseg->flag = mi_uint2korr(ptr); ptr +=2; 01107 keyseg->length = mi_uint2korr(ptr); ptr +=2; 01108 keyseg->start = mi_uint4korr(ptr); ptr +=4; 01109 keyseg->null_pos = mi_uint4korr(ptr); ptr +=4; 01110 keyseg->charset=0; /* Will be filled in later */ 01111 if (keyseg->null_bit) 01112 keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == 7)); 01113 else 01114 { 01115 keyseg->bit_pos= (uint16)keyseg->null_pos; 01116 keyseg->null_pos= 0; 01117 } 01118 return ptr; 01119 }
Here is the caller graph for this function:

Definition at line 1075 of file mi_open.c.
References st_HA_KEYSEG::bit_end, st_HA_KEYSEG::bit_length, st_HA_KEYSEG::bit_pos, st_HA_KEYSEG::bit_start, st_HA_KEYSEG::flag, keyseg, st_HA_KEYSEG::language, st_HA_KEYSEG::length, mi_int2store, mi_int4store, MY_NABP, my_write, MYF, st_HA_KEYSEG::null_bit, st_HA_KEYSEG::null_pos, pos(), st_HA_KEYSEG::start, and st_HA_KEYSEG::type.
01076 { 01077 uchar buff[HA_KEYSEG_SIZE]; 01078 uchar *ptr=buff; 01079 ulong pos; 01080 01081 *ptr++= keyseg->type; 01082 *ptr++= keyseg->language; 01083 *ptr++= keyseg->null_bit; 01084 *ptr++= keyseg->bit_start; 01085 *ptr++= keyseg->bit_end; 01086 *ptr++= keyseg->bit_length; 01087 mi_int2store(ptr,keyseg->flag); ptr+=2; 01088 mi_int2store(ptr,keyseg->length); ptr+=2; 01089 mi_int4store(ptr,keyseg->start); ptr+=4; 01090 pos= keyseg->null_bit ? keyseg->null_pos : keyseg->bit_pos; 01091 mi_int4store(ptr, pos); 01092 ptr+=4; 01093 01094 return my_write(file,(char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); 01095 }
Here is the call graph for this function:

Definition at line 131 of file mi_dynrec.c.
References st_mi_isam_share::concurrent_insert, DBUG_PRINT, st_myisam_info::dfile, st_mi_isam_share::file_map, memcpy, st_mi_isam_share::mmap_lock, st_mi_isam_share::mmaped_length, my_pread(), rw_rdlock, rw_unlock, and st_myisam_info::s.
00133 { 00134 DBUG_PRINT("info", ("mi_read with mmap %d\n", info->dfile)); 00135 if (info->s->concurrent_insert) 00136 rw_rdlock(&info->s->mmap_lock); 00137 00138 /* 00139 The following test may fail in the following cases: 00140 - We failed to remap a memory area (fragmented memory?) 00141 - This thread has done some writes, but not yet extended the 00142 memory mapped area. 00143 */ 00144 00145 if (info->s->mmaped_length >= offset + Count) 00146 { 00147 memcpy(Buffer, info->s->file_map + offset, Count); 00148 if (info->s->concurrent_insert) 00149 rw_unlock(&info->s->mmap_lock); 00150 return 0; 00151 } 00152 else 00153 { 00154 if (info->s->concurrent_insert) 00155 rw_unlock(&info->s->mmap_lock); 00156 return my_pread(info->dfile, Buffer, Count, offset, MyFlags); 00157 } 00158 }
Here is the call graph for this function:

Definition at line 186 of file mi_dynrec.c.
References st_mi_isam_share::concurrent_insert, DBUG_PRINT, st_myisam_info::dfile, st_mi_isam_share::file_map, memcpy, st_mi_isam_share::mmap_lock, st_mi_isam_share::mmaped_length, my_pwrite(), st_mi_isam_share::nonmmaped_inserts, rw_rdlock, rw_unlock, and st_myisam_info::s.
00188 { 00189 DBUG_PRINT("info", ("mi_write with mmap %d\n", info->dfile)); 00190 if (info->s->concurrent_insert) 00191 rw_rdlock(&info->s->mmap_lock); 00192 00193 /* 00194 The following test may fail in the following cases: 00195 - We failed to remap a memory area (fragmented memory?) 00196 - This thread has done some writes, but not yet extended the 00197 memory mapped area. 00198 */ 00199 00200 if (info->s->mmaped_length >= offset + Count) 00201 { 00202 memcpy(info->s->file_map + offset, Buffer, Count); 00203 if (info->s->concurrent_insert) 00204 rw_unlock(&info->s->mmap_lock); 00205 return 0; 00206 } 00207 else 00208 { 00209 info->s->nonmmaped_inserts++; 00210 if (info->s->concurrent_insert) 00211 rw_unlock(&info->s->mmap_lock); 00212 return my_pwrite(info->dfile, Buffer, Count, offset, MyFlags); 00213 } 00214 00215 }
Here is the call graph for this function:

Definition at line 163 of file mi_dynrec.c.
References st_myisam_info::dfile, and my_pread().
Referenced by mi_setup_functions().
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 220 of file mi_dynrec.c.
References st_myisam_info::dfile, and my_pwrite().
Referenced by mi_setup_functions().
Here is the call graph for this function:

Here is the caller graph for this function:

| int mi_open_datafile | ( | MI_INFO * | info, | |
| MYISAM_SHARE * | share, | |||
| File | file_to_dup | |||
| ) |
| int mi_open_keyfile | ( | MYISAM_SHARE * | share | ) |
Definition at line 1199 of file mi_open.c.
References st_mi_isam_share::kfile, st_mi_isam_share::mode, my_open(), MY_WME, MYF, O_SHARE, and st_mi_isam_share::unique_file_name.
Referenced by mi_sort_index().
01200 { 01201 if ((share->kfile=my_open(share->unique_file_name, share->mode | O_SHARE, 01202 MYF(MY_WME))) < 0) 01203 return 1; 01204 return 0; 01205 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* mi_recinfo_read | ( | char * | ptr, | |
| MI_COLUMNDEF * | recinfo | |||
| ) |
Definition at line 1161 of file mi_open.c.
References st_columndef::length, mi_sint2korr, mi_uint2korr, st_columndef::null_bit, st_columndef::null_pos, recinfo, and st_columndef::type.
01162 { 01163 recinfo->type= mi_sint2korr(ptr); ptr +=2; 01164 recinfo->length=mi_uint2korr(ptr); ptr +=2; 01165 recinfo->null_bit= (uint8) *ptr++; 01166 recinfo->null_pos=mi_uint2korr(ptr); ptr +=2; 01167 return ptr; 01168 }
| uint mi_recinfo_write | ( | File | file, | |
| MI_COLUMNDEF * | recinfo | |||
| ) |
Definition at line 1149 of file mi_open.c.
References st_columndef::length, MI_COLUMNDEF_SIZE, mi_int2store, MY_NABP, my_write, MYF, st_columndef::null_bit, st_columndef::null_pos, recinfo, and st_columndef::type.
01150 { 01151 uchar buff[MI_COLUMNDEF_SIZE]; 01152 uchar *ptr=buff; 01153 01154 mi_int2store(ptr,recinfo->type); ptr +=2; 01155 mi_int2store(ptr,recinfo->length); ptr +=2; 01156 *ptr++ = recinfo->null_bit; 01157 mi_int2store(ptr,recinfo->null_pos); ptr+= 2; 01158 return my_write(file,(char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); 01159 }
Referenced by mi_delete_all_rows(), and mi_lock_database().
Here is the caller graph for this function:

| void mi_report_error | ( | int | errcode, | |
| const char * | file_name | |||
| ) |
Definition at line 122 of file mi_info.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, ME_NOREFRESH, my_error(), MYF, and strlen().
00123 { 00124 size_t lgt; 00125 DBUG_ENTER("mi_report_error"); 00126 DBUG_PRINT("enter",("errcode %d, table '%s'", errcode, file_name)); 00127 00128 if ((lgt= strlen(file_name)) > 64) 00129 file_name+= lgt - 64; 00130 my_error(errcode, MYF(ME_NOREFRESH), file_name); 00131 DBUG_VOID_RETURN; 00132 }
Here is the call graph for this function:


