#include <my_base.h>#include "my_handler.h"#include "my_tree.h"Include dependency graph for heap.h:

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

Go to the source code of this file.
| #define HP_MAX_LEVELS 4 |
| #define HP_PTRS_IN_NOD 128 |
Definition at line 40 of file heap.h.
Referenced by hp_free_level(), hp_get_new_block(), and init_block().
| typedef struct st_heapinfo HEAPINFO |
| typedef struct st_heap_block HP_BLOCK |
| typedef struct st_heap_create_info HP_CREATE_INFO |
| typedef struct st_heap_info HP_INFO |
| typedef struct st_hp_keydef HP_KEYDEF |
| typedef struct st_heap_ptrs HP_PTRS |
| typedef struct st_heap_share HP_SHARE |
Definition at line 43 of file _check.c.
References st_hp_keydef::algorithm, st_heap_share::blength, st_heap_share::block, check_one_key(), check_one_rb_key(), st_heap_info::current_ptr, DBUG_ENTER, st_heap_share::deleted, error, HA_KEY_ALG_BTREE, hp_find_record, key, st_heap_share::keydef, st_heap_share::keys, pos(), st_heap_block::recbuffer, st_heap_share::reclength, records, st_heap_share::records, st_heap_block::records_in_block, and st_heap_info::s.
Referenced by heap_delete(), heap_update(), heap_write(), hp_close(), and main().
00044 { 00045 int error; 00046 uint key; 00047 ulong records=0, deleted=0, pos, next_block; 00048 HP_SHARE *share=info->s; 00049 HP_INFO save_info= *info; /* Needed because scan_init */ 00050 DBUG_ENTER("heap_check_heap"); 00051 00052 for (error=key= 0 ; key < share->keys ; key++) 00053 { 00054 if (share->keydef[key].algorithm == HA_KEY_ALG_BTREE) 00055 error|= check_one_rb_key(info, key, share->records, print_status); 00056 else 00057 error|= check_one_key(share->keydef + key, key, share->records, 00058 share->blength, print_status); 00059 } 00060 /* 00061 This is basicly the same code as in hp_scan, but we repeat it here to 00062 get shorter DBUG log file. 00063 */ 00064 for (pos=next_block= 0 ; ; pos++) 00065 { 00066 if (pos < next_block) 00067 { 00068 info->current_ptr+= share->block.recbuffer; 00069 } 00070 else 00071 { 00072 next_block+= share->block.records_in_block; 00073 if (next_block >= share->records+share->deleted) 00074 { 00075 next_block= share->records+share->deleted; 00076 if (pos >= next_block) 00077 break; /* End of file */ 00078 } 00079 } 00080 hp_find_record(info,pos); 00081 00082 if (!info->current_ptr[share->reclength]) 00083 deleted++; 00084 else 00085 records++; 00086 } 00087 00088 if (records != share->records || deleted != share->deleted) 00089 { 00090 DBUG_PRINT("error",("Found rows: %lu (%lu) deleted %lu (%lu)", 00091 records, share->records, deleted, share->deleted)); 00092 error= 1; 00093 } 00094 *info= save_info; 00095 DBUG_RETURN(error); 00096 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void heap_clear | ( | HP_INFO * | info | ) |
Definition at line 25 of file hp_clear.c.
References hp_clear(), and st_heap_info::s.
Referenced by ha_heap::delete_all_rows(), and main().
Here is the call graph for this function:

Here is the caller graph for this function:

| void heap_clear_keys | ( | HP_INFO * | info | ) |
Definition at line 61 of file hp_clear.c.
References hp_clear(), and st_heap_info::s.
Here is the call graph for this function:

| int heap_close | ( | HP_INFO * | info | ) |
Definition at line 24 of file hp_close.c.
References DBUG_ENTER, DBUG_RETURN, hp_close(), pthread_mutex_lock, and pthread_mutex_unlock.
Referenced by ha_heap::close(), and main().
00025 { 00026 int tmp; 00027 DBUG_ENTER("heap_close"); 00028 pthread_mutex_lock(&THR_LOCK_heap); 00029 tmp= hp_close(info); 00030 pthread_mutex_unlock(&THR_LOCK_heap); 00031 DBUG_RETURN(tmp); 00032 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int heap_create | ( | const char * | name, | |
| uint | keys, | |||
| HP_KEYDEF * | keydef, | |||
| uint | reclength, | |||
| ulong | max_records, | |||
| ulong | min_records, | |||
| HP_CREATE_INFO * | create_info | |||
| ) |
Definition at line 23 of file hp_create.c.
References st_HA_KEYSEG::bit_start, bzero, st_HA_KEYSEG::charset, DBUG_ENTER, DBUG_PRINT, st_mi_keydef::flag, st_HA_KEYSEG::flag, HA_END_SPACE_ARE_EQUAL, HA_END_SPACE_KEY, HA_KEY_ALG_BTREE, HA_KEYTYPE_DOUBLE, HA_KEYTYPE_FLOAT, HA_KEYTYPE_INT24, HA_KEYTYPE_INT8, HA_KEYTYPE_LONG_INT, HA_KEYTYPE_LONGLONG, HA_KEYTYPE_SHORT_INT, HA_KEYTYPE_UINT24, HA_KEYTYPE_ULONG_INT, HA_KEYTYPE_ULONGLONG, HA_KEYTYPE_USHORT_INT, HA_KEYTYPE_VARBINARY1, HA_KEYTYPE_VARBINARY2, HA_KEYTYPE_VARTEXT1, HA_KEYTYPE_VARTEXT2, HA_NULL_ARE_EQUAL, HA_NULL_PART_KEY, HA_SWAP_KEY, HA_VAR_LENGTH_KEY, hp_find_named_heap(), hp_free(), hp_rb_key_length(), hp_rb_null_key_length(), hp_rb_var_key_length(), keyinfo, keyseg, st_mi_keydef::keysegs, st_HA_KEYSEG::length, my_binary_compare, NULL, st_HA_KEYSEG::null_bit, st_heap_share::open_count, pthread_mutex_lock, st_mi_keydef::seg, set_if_bigger, and st_HA_KEYSEG::type.
Referenced by main().
00026 { 00027 uint i, j, key_segs, max_length, length; 00028 HP_SHARE *share; 00029 HA_KEYSEG *keyseg; 00030 00031 DBUG_ENTER("heap_create"); 00032 pthread_mutex_lock(&THR_LOCK_heap); 00033 00034 if ((share= hp_find_named_heap(name)) && share->open_count == 0) 00035 { 00036 hp_free(share); 00037 share= NULL; 00038 } 00039 00040 if (!share) 00041 { 00042 HP_KEYDEF *keyinfo; 00043 DBUG_PRINT("info",("Initializing new table")); 00044 00045 /* 00046 We have to store sometimes byte* del_link in records, 00047 so the record length should be at least sizeof(byte*) 00048 */ 00049 set_if_bigger(reclength, sizeof (byte*)); 00050 00051 for (i= key_segs= max_length= 0, keyinfo= keydef; i < keys; i++, keyinfo++) 00052 { 00053 bzero((char*) &keyinfo->block,sizeof(keyinfo->block)); 00054 bzero((char*) &keyinfo->rb_tree ,sizeof(keyinfo->rb_tree)); 00055 for (j= length= 0; j < keyinfo->keysegs; j++) 00056 { 00057 length+= keyinfo->seg[j].length; 00058 if (keyinfo->seg[j].null_bit) 00059 { 00060 length++; 00061 if (!(keyinfo->flag & HA_NULL_ARE_EQUAL)) 00062 keyinfo->flag|= HA_NULL_PART_KEY; 00063 if (keyinfo->algorithm == HA_KEY_ALG_BTREE) 00064 keyinfo->rb_tree.size_of_element++; 00065 } 00066 switch (keyinfo->seg[j].type) { 00067 case HA_KEYTYPE_SHORT_INT: 00068 case HA_KEYTYPE_LONG_INT: 00069 case HA_KEYTYPE_FLOAT: 00070 case HA_KEYTYPE_DOUBLE: 00071 case HA_KEYTYPE_USHORT_INT: 00072 case HA_KEYTYPE_ULONG_INT: 00073 case HA_KEYTYPE_LONGLONG: 00074 case HA_KEYTYPE_ULONGLONG: 00075 case HA_KEYTYPE_INT24: 00076 case HA_KEYTYPE_UINT24: 00077 case HA_KEYTYPE_INT8: 00078 keyinfo->seg[j].flag|= HA_SWAP_KEY; 00079 break; 00080 case HA_KEYTYPE_VARBINARY1: 00081 /* Case-insensitiveness is handled in coll->hash_sort */ 00082 keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1; 00083 /* fall_through */ 00084 case HA_KEYTYPE_VARTEXT1: 00085 if (!my_binary_compare(keyinfo->seg[j].charset)) 00086 keyinfo->flag|= HA_END_SPACE_KEY; 00087 keyinfo->flag|= HA_VAR_LENGTH_KEY; 00088 length+= 2; 00089 /* Save number of bytes used to store length */ 00090 keyinfo->seg[j].bit_start= 1; 00091 break; 00092 case HA_KEYTYPE_VARBINARY2: 00093 /* Case-insensitiveness is handled in coll->hash_sort */ 00094 /* fall_through */ 00095 case HA_KEYTYPE_VARTEXT2: 00096 if (!my_binary_compare(keyinfo->seg[j].charset)) 00097 keyinfo->flag|= HA_END_SPACE_KEY; 00098 keyinfo->flag|= HA_VAR_LENGTH_KEY; 00099 length+= 2; 00100 /* Save number of bytes used to store length */ 00101 keyinfo->seg[j].bit_start= 2; 00102 /* 00103 Make future comparison simpler by only having to check for 00104 one type 00105 */ 00106 keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1; 00107 break; 00108 default: 00109 break; 00110 } 00111 if (keyinfo->seg[j].flag & HA_END_SPACE_ARE_EQUAL) 00112 keyinfo->flag|= HA_END_SPACE_KEY; 00113 } 00114 keyinfo->length= length; 00115 length+= keyinfo->rb_tree.size_of_element + 00116 ((keyinfo->algorithm == HA_KEY_ALG_BTREE) ? sizeof(byte*) : 0); 00117 if (length > max_length) 00118 max_length= length; 00119 key_segs+= keyinfo->keysegs; 00120 if (keyinfo->algorithm == HA_KEY_ALG_BTREE) 00121 { 00122 key_segs++; /* additional HA_KEYTYPE_END segment */ 00123 if (keyinfo->flag & HA_VAR_LENGTH_KEY) 00124 keyinfo->get_key_length= hp_rb_var_key_length; 00125 else if (keyinfo->flag & HA_NULL_PART_KEY) 00126 keyinfo->get_key_length= hp_rb_null_key_length; 00127 else 00128 keyinfo->get_key_length= hp_rb_key_length; 00129 } 00130 } 00131 if (!(share= (HP_SHARE*) my_malloc((uint) sizeof(HP_SHARE)+ 00132 keys*sizeof(HP_KEYDEF)+ 00133 key_segs*sizeof(HA_KEYSEG), 00134 MYF(MY_ZEROFILL)))) 00135 { 00136 pthread_mutex_unlock(&THR_LOCK_heap); 00137 DBUG_RETURN(1); 00138 } 00139 share->keydef= (HP_KEYDEF*) (share + 1); 00140 share->key_stat_version= 1; 00141 keyseg= (HA_KEYSEG*) (share->keydef + keys); 00142 init_block(&share->block, reclength + 1, min_records, max_records); 00143 /* Fix keys */ 00144 memcpy(share->keydef, keydef, (size_t) (sizeof(keydef[0]) * keys)); 00145 for (i= 0, keyinfo= share->keydef; i < keys; i++, keyinfo++) 00146 { 00147 keyinfo->seg= keyseg; 00148 memcpy(keyseg, keydef[i].seg, 00149 (size_t) (sizeof(keyseg[0]) * keydef[i].keysegs)); 00150 keyseg+= keydef[i].keysegs; 00151 00152 if (keydef[i].algorithm == HA_KEY_ALG_BTREE) 00153 { 00154 /* additional HA_KEYTYPE_END keyseg */ 00155 keyseg->type= HA_KEYTYPE_END; 00156 keyseg->length= sizeof(byte*); 00157 keyseg->flag= 0; 00158 keyseg->null_bit= 0; 00159 keyseg++; 00160 00161 init_tree(&keyinfo->rb_tree, 0, 0, sizeof(byte*), 00162 (qsort_cmp2)keys_compare, 1, NULL, NULL); 00163 keyinfo->delete_key= hp_rb_delete_key; 00164 keyinfo->write_key= hp_rb_write_key; 00165 } 00166 else 00167 { 00168 init_block(&keyinfo->block, sizeof(HASH_INFO), min_records, 00169 max_records); 00170 keyinfo->delete_key= hp_delete_key; 00171 keyinfo->write_key= hp_write_key; 00172 keyinfo->hash_buckets= 0; 00173 } 00174 if ((keyinfo->flag & HA_AUTO_KEY) && create_info->with_auto_increment) 00175 share->auto_key= i + 1; 00176 } 00177 share->min_records= min_records; 00178 share->max_records= max_records; 00179 share->max_table_size= create_info->max_table_size; 00180 share->data_length= share->index_length= 0; 00181 share->reclength= reclength; 00182 share->blength= 1; 00183 share->keys= keys; 00184 share->max_key_length= max_length; 00185 share->changed= 0; 00186 share->auto_key= create_info->auto_key; 00187 share->auto_key_type= create_info->auto_key_type; 00188 share->auto_increment= create_info->auto_increment; 00189 /* Must be allocated separately for rename to work */ 00190 if (!(share->name= my_strdup(name,MYF(0)))) 00191 { 00192 my_free((gptr) share,MYF(0)); 00193 pthread_mutex_unlock(&THR_LOCK_heap); 00194 DBUG_RETURN(1); 00195 } 00196 #ifdef THREAD 00197 thr_lock_init(&share->lock); 00198 VOID(pthread_mutex_init(&share->intern_lock,MY_MUTEX_INIT_FAST)); 00199 #endif 00200 share->open_list.data= (void*) share; 00201 heap_share_list= list_add(heap_share_list,&share->open_list); 00202 } 00203 pthread_mutex_unlock(&THR_LOCK_heap); 00204 DBUG_RETURN(0); 00205 } /* heap_create */
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 21 of file hp_delete.c.
References st_heap_share::blength, st_heap_share::changed, st_heap_info::current_hash_ptr, st_heap_info::current_ptr, DBUG_ENTER, DBUG_EXECUTE, DBUG_PRINT, DBUG_RETURN, st_heap_share::del_link, st_hp_keydef::delete_key, st_heap_share::deleted, err, HA_STATE_DELETED, heap_check_heap(), hp_rectest(), st_heap_share::keydef, st_heap_share::keys, st_heap_info::lastinx, my_errno, st_heap_info::opt_flag, pos(), READ_CHECK_USED, st_heap_share::reclength, st_heap_share::records, st_heap_info::s, test_active, and st_heap_info::update.
Referenced by ha_heap::delete_row(), and main().
00022 { 00023 byte *pos; 00024 HP_SHARE *share=info->s; 00025 HP_KEYDEF *keydef, *end, *p_lastinx; 00026 DBUG_ENTER("heap_delete"); 00027 DBUG_PRINT("enter",("info: %lx record: 0x%lx",info,record)); 00028 00029 test_active(info); 00030 00031 if (info->opt_flag & READ_CHECK_USED && hp_rectest(info,record)) 00032 DBUG_RETURN(my_errno); /* Record changed */ 00033 share->changed=1; 00034 00035 if ( --(share->records) < share->blength >> 1) share->blength>>=1; 00036 pos=info->current_ptr; 00037 00038 p_lastinx = share->keydef + info->lastinx; 00039 for (keydef = share->keydef, end = keydef + share->keys; keydef < end; 00040 keydef++) 00041 { 00042 if ((*keydef->delete_key)(info, keydef, record, pos, keydef == p_lastinx)) 00043 goto err; 00044 } 00045 00046 info->update=HA_STATE_DELETED; 00047 *((byte**) pos)=share->del_link; 00048 share->del_link=pos; 00049 pos[share->reclength]=0; /* Record deleted */ 00050 share->deleted++; 00051 info->current_hash_ptr=0; 00052 #if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG) 00053 DBUG_EXECUTE("check_heap",heap_check_heap(info, 0);); 00054 #endif 00055 00056 DBUG_RETURN(0); 00057 err: 00058 if (++(share->records) == share->blength) 00059 share->blength+= share->blength; 00060 DBUG_RETURN(my_errno); 00061 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int heap_delete_table | ( | const char * | name | ) |
Definition at line 250 of file hp_create.c.
References DBUG_ENTER, DBUG_RETURN, heap_try_free(), hp_find_named_heap(), my_errno, pthread_mutex_lock, pthread_mutex_unlock, and reg1.
Referenced by ha_heap::delete_table(), and main().
00251 { 00252 int result; 00253 reg1 HP_SHARE *share; 00254 DBUG_ENTER("heap_delete_table"); 00255 00256 pthread_mutex_lock(&THR_LOCK_heap); 00257 if ((share= hp_find_named_heap(name))) 00258 { 00259 heap_try_free(share); 00260 result= 0; 00261 } 00262 else 00263 { 00264 result= my_errno=ENOENT; 00265 } 00266 pthread_mutex_unlock(&THR_LOCK_heap); 00267 DBUG_RETURN(result); 00268 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int heap_disable_indexes | ( | HP_INFO * | info | ) |
Definition at line 122 of file hp_clear.c.
References st_heap_share::currently_disabled_keys, hp_clear_keys(), st_heap_share::keys, and st_heap_info::s.
Referenced by ha_heap::disable_indexes().
00123 { 00124 HP_SHARE *share= info->s; 00125 00126 if (share->keys) 00127 { 00128 hp_clear_keys(share); 00129 share->currently_disabled_keys= share->keys; 00130 share->keys= 0; 00131 } 00132 return 0; 00133 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void heap_drop_table | ( | HP_INFO * | info | ) |
Definition at line 271 of file hp_create.c.
References DBUG_ENTER, DBUG_VOID_RETURN, heap_try_free(), pthread_mutex_lock, pthread_mutex_unlock, and st_heap_info::s.
Referenced by ha_heap::drop_table().
00272 { 00273 DBUG_ENTER("heap_drop_table"); 00274 pthread_mutex_lock(&THR_LOCK_heap); 00275 heap_try_free(info->s); 00276 pthread_mutex_unlock(&THR_LOCK_heap); 00277 DBUG_VOID_RETURN; 00278 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int heap_enable_indexes | ( | HP_INFO * | info | ) |
Definition at line 155 of file hp_clear.c.
References st_heap_share::currently_disabled_keys, st_heap_share::data_length, error, HA_ERR_CRASHED, st_heap_share::index_length, st_heap_share::keys, and st_heap_info::s.
Referenced by ha_heap::enable_indexes().
00156 { 00157 int error= 0; 00158 HP_SHARE *share= info->s; 00159 00160 if (share->data_length || share->index_length) 00161 error= HA_ERR_CRASHED; 00162 else 00163 if (share->currently_disabled_keys) 00164 { 00165 share->keys= share->currently_disabled_keys; 00166 share->currently_disabled_keys= 0; 00167 } 00168 return error; 00169 }
Here is the caller graph for this function:

| int heap_extra | ( | HP_INFO * | info, | |
| enum ha_extra_function | function | |||
| ) |
Definition at line 78 of file hp_rkey.c.
References hp_search(), st_heap_share::keydef, and st_heap_info::s.
Here is the call graph for this function:

| int heap_indexes_are_disabled | ( | HP_INFO * | info | ) |
Definition at line 188 of file hp_clear.c.
References st_heap_share::currently_disabled_keys, st_heap_share::keys, and st_heap_info::s.
Referenced by ha_heap::indexes_are_disabled().
00189 { 00190 HP_SHARE *share= info->s; 00191 00192 return (! share->keys && share->currently_disabled_keys); 00193 }
Here is the caller graph for this function:

| HP_INFO* heap_open | ( | const char * | name, | |
| int | mode | |||
| ) |
Definition at line 26 of file hp_open.c.
References st_heap_share::block, st_heap_info::current_hash_ptr, st_heap_info::current_ptr, st_heap_info::current_record, st_list::data, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_heap_info::errkey, heap_open_list, hp_find_named_heap(), info, st_heap_info::lastinx, st_heap_info::lastkey, list_add(), st_heap_share::max_key_length, st_heap_info::mode, my_errno, my_malloc(), MY_ZEROFILL, MYF, NULL, st_heap_share::open_count, st_heap_info::open_list, st_heap_info::opt_flag, pthread_mutex_lock, pthread_mutex_unlock, READ_CHECK_USED, st_heap_info::recbuf, st_heap_share::reclength, st_heap_block::records_in_block, st_heap_info::s, thr_lock_data_init(), and st_heap_info::update.
Referenced by main(), and ha_heap::open().
00027 { 00028 HP_INFO *info; 00029 HP_SHARE *share; 00030 00031 DBUG_ENTER("heap_open"); 00032 pthread_mutex_lock(&THR_LOCK_heap); 00033 if (!(share= hp_find_named_heap(name))) 00034 { 00035 my_errno= ENOENT; 00036 pthread_mutex_unlock(&THR_LOCK_heap); 00037 DBUG_RETURN(0); 00038 } 00039 if (!(info= (HP_INFO*) my_malloc((uint) sizeof(HP_INFO) + 00040 2 * share->max_key_length, 00041 MYF(MY_ZEROFILL)))) 00042 { 00043 pthread_mutex_unlock(&THR_LOCK_heap); 00044 DBUG_RETURN(0); 00045 } 00046 share->open_count++; 00047 #ifdef THREAD 00048 thr_lock_data_init(&share->lock,&info->lock,NULL); 00049 #endif 00050 info->open_list.data= (void*) info; 00051 heap_open_list= list_add(heap_open_list,&info->open_list); 00052 pthread_mutex_unlock(&THR_LOCK_heap); 00053 00054 info->s= share; 00055 info->lastkey= (byte*) (info + 1); 00056 info->recbuf= (byte*) (info->lastkey + share->max_key_length); 00057 info->mode= mode; 00058 info->current_record= (ulong) ~0L; /* No current record */ 00059 info->current_ptr= 0; 00060 info->current_hash_ptr= 0; 00061 info->lastinx= info->errkey= -1; 00062 info->update= 0; 00063 #ifndef DBUG_OFF 00064 info->opt_flag= READ_CHECK_USED; /* Check when changing */ 00065 #endif 00066 DBUG_PRINT("exit",("heap: 0x%lx reclength: %d records_in_block: %d", 00067 info,share->reclength,share->block.records_in_block)); 00068 DBUG_RETURN(info); 00069 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int heap_panic | ( | enum ha_panic_function | flag | ) |
Definition at line 22 of file hp_panic.c.
References st_list::data, DBUG_ENTER, DBUG_RETURN, HA_PANIC_CLOSE, heap_open_list, heap_share_list, hp_close(), hp_free(), info, st_list::next, pthread_mutex_lock, and pthread_mutex_unlock.
Referenced by endprog(), heap_init(), and main().
00023 { 00024 LIST *element,*next_open; 00025 DBUG_ENTER("heap_panic"); 00026 00027 pthread_mutex_lock(&THR_LOCK_heap); 00028 for (element=heap_open_list ; element ; element=next_open) 00029 { 00030 HP_INFO *info=(HP_INFO*) element->data; 00031 next_open=element->next; /* Save if close */ 00032 switch (flag) { 00033 case HA_PANIC_CLOSE: 00034 hp_close(info); 00035 break; 00036 default: 00037 break; 00038 } 00039 } 00040 for (element=heap_share_list ; element ; element=next_open) 00041 { 00042 HP_SHARE *share=(HP_SHARE*) element->data; 00043 next_open=element->next; /* Save if close */ 00044 switch (flag) { 00045 case HA_PANIC_CLOSE: 00046 { 00047 if (!share->open_count) 00048 hp_free(share); 00049 break; 00050 } 00051 default: 00052 break; 00053 } 00054 } 00055 pthread_mutex_unlock(&THR_LOCK_heap); 00056 DBUG_RETURN(0); 00057 } /* heap_panic */
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 22 of file hp_info.c.
References st_heap_info::current_ptr, HA_STATE_AKTIV, and st_heap_info::update.
Referenced by main(), and ha_heap::position().
00023 { 00024 return ((info->update & HA_STATE_AKTIV) ? info->current_ptr : 00025 (HEAP_PTR) 0); 00026 }
Here is the caller graph for this function:

| int heap_rename | ( | const char * | old_name, | |
| const char * | new_name | |||
| ) |
Definition at line 23 of file hp_rename.c.
References DBUG_ENTER, DBUG_RETURN, hp_find_named_heap(), info, my_errno, my_free, my_strdup(), MY_WME, MYF, pthread_mutex_lock, pthread_mutex_unlock, and reg1.
Referenced by ha_heap::rename_table().
00024 { 00025 reg1 HP_SHARE *info; 00026 char *name_buff; 00027 DBUG_ENTER("heap_rename"); 00028 00029 pthread_mutex_lock(&THR_LOCK_heap); 00030 if ((info = hp_find_named_heap(old_name))) 00031 { 00032 if (!(name_buff=(char*) my_strdup(new_name,MYF(MY_WME)))) 00033 { 00034 pthread_mutex_unlock(&THR_LOCK_heap); 00035 DBUG_RETURN(my_errno); 00036 } 00037 my_free(info->name,MYF(0)); 00038 info->name=name_buff; 00039 } 00040 pthread_mutex_unlock(&THR_LOCK_heap); 00041 DBUG_RETURN(0); 00042 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int heap_reset | ( | HP_INFO * | info | ) |
Definition at line 54 of file hp_extra.c.
References st_heap_info::current_hash_ptr, st_heap_info::current_record, st_heap_info::lastinx, st_heap_info::next_block, and st_heap_info::update.
Referenced by heap_extra(), main(), and ha_heap::reset().
00055 { 00056 info->lastinx= -1; 00057 info->current_record= (ulong) ~0L; 00058 info->current_hash_ptr=0; 00059 info->update=0; 00060 info->next_block=0; 00061 return 0; 00062 }
Here is the caller graph for this function:

Definition at line 21 of file hp_rfirst.c.
References st_heap_info::current_hash_ptr, st_heap_info::current_ptr, st_heap_info::current_record, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, HA_ERR_END_OF_FILE, HA_KEY_ALG_BTREE, HA_STATE_AKTIV, HA_STATE_PREV_FOUND, heap_rnext(), st_heap_share::keydef, keyinfo, st_heap_info::last_pos, st_heap_info::lastinx, memcpy, my_errno, offsetof, st_heap_info::parents, pos(), st_heap_share::reclength, st_heap_share::records, st_heap_info::s, tree_search_edge(), and st_heap_info::update.
Referenced by ha_heap::index_first().
00022 { 00023 HP_SHARE *share = info->s; 00024 HP_KEYDEF *keyinfo = share->keydef + inx; 00025 00026 DBUG_ENTER("heap_rfirst"); 00027 info->lastinx= inx; 00028 if (keyinfo->algorithm == HA_KEY_ALG_BTREE) 00029 { 00030 byte *pos; 00031 00032 if ((pos = tree_search_edge(&keyinfo->rb_tree, info->parents, 00033 &info->last_pos, offsetof(TREE_ELEMENT, left)))) 00034 { 00035 memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), 00036 sizeof(byte*)); 00037 info->current_ptr = pos; 00038 memcpy(record, pos, (size_t)share->reclength); 00039 info->update = HA_STATE_AKTIV; 00040 } 00041 else 00042 { 00043 my_errno = HA_ERR_END_OF_FILE; 00044 DBUG_RETURN(my_errno); 00045 } 00046 DBUG_RETURN(0); 00047 } 00048 else 00049 { 00050 if (!(info->s->records)) 00051 { 00052 my_errno=HA_ERR_END_OF_FILE; 00053 DBUG_RETURN(my_errno); 00054 } 00055 DBUG_ASSERT(0); /* TODO fix it */ 00056 info->current_record=0; 00057 info->current_hash_ptr=0; 00058 info->update=HA_STATE_PREV_FOUND; 00059 DBUG_RETURN(heap_rnext(info,record)); 00060 } 00061 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int heap_rkey | ( | HP_INFO * | info, | |
| byte * | record, | |||
| int | inx, | |||
| const byte * | key, | |||
| uint | key_len, | |||
| enum ha_rkey_function | find_flag | |||
| ) |
Definition at line 19 of file hp_rkey.c.
References st_heap_info::current_ptr, st_heap_info::current_record, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_mi_keydef::flag, HA_END_SPACE_KEY, HA_ERR_KEY_NOT_FOUND, HA_ERR_WRONG_INDEX, HA_KEY_ALG_BTREE, HA_NOSAME, HA_READ_AFTER_KEY, HA_READ_BEFORE_KEY, HA_READ_KEY_OR_NEXT, HA_READ_KEY_OR_PREV, HA_STATE_AKTIV, hp_rb_pack_key(), hp_search(), heap_rb_param::key_length, st_heap_share::keydef, keyinfo, st_heap_share::keys, heap_rb_param::keyseg, st_heap_info::last_find_flag, st_heap_info::last_pos, st_heap_info::lastinx, st_heap_info::lastkey, st_heap_info::lastkey_len, memcpy, my_errno, st_heap_info::parents, pos(), st_heap_share::reclength, st_heap_info::s, SEARCH_FIND, heap_rb_param::search_flag, SEARCH_SAME, st_hp_keydef::seg, tree_search_key(), and st_heap_info::update.
Referenced by ha_heap::index_read(), ha_heap::index_read_idx(), ha_heap::index_read_last(), and main().
00021 { 00022 byte *pos; 00023 HP_SHARE *share= info->s; 00024 HP_KEYDEF *keyinfo= share->keydef + inx; 00025 DBUG_ENTER("heap_rkey"); 00026 DBUG_PRINT("enter",("base: 0x%lx inx: %d",info,inx)); 00027 00028 if ((uint) inx >= share->keys) 00029 { 00030 DBUG_RETURN(my_errno= HA_ERR_WRONG_INDEX); 00031 } 00032 info->lastinx= inx; 00033 info->current_record= (ulong) ~0L; /* For heap_rrnd() */ 00034 00035 if (keyinfo->algorithm == HA_KEY_ALG_BTREE) 00036 { 00037 heap_rb_param custom_arg; 00038 00039 custom_arg.keyseg= info->s->keydef[inx].seg; 00040 custom_arg.key_length= info->lastkey_len= 00041 hp_rb_pack_key(keyinfo, (uchar*) info->lastkey, 00042 (uchar*) key, key_len); 00043 custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME; 00044 /* for next rkey() after deletion */ 00045 if (find_flag == HA_READ_AFTER_KEY) 00046 info->last_find_flag= HA_READ_KEY_OR_NEXT; 00047 else if (find_flag == HA_READ_BEFORE_KEY) 00048 info->last_find_flag= HA_READ_KEY_OR_PREV; 00049 else 00050 info->last_find_flag= find_flag; 00051 if (!(pos= tree_search_key(&keyinfo->rb_tree, info->lastkey, info->parents, 00052 &info->last_pos, find_flag, &custom_arg))) 00053 { 00054 info->update= 0; 00055 DBUG_RETURN(my_errno= HA_ERR_KEY_NOT_FOUND); 00056 } 00057 memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), sizeof(byte*)); 00058 info->current_ptr= pos; 00059 } 00060 else 00061 { 00062 if (!(pos= hp_search(info, share->keydef + inx, key, 0))) 00063 { 00064 info->update= 0; 00065 DBUG_RETURN(my_errno); 00066 } 00067 if (!(keyinfo->flag & HA_NOSAME) || (keyinfo->flag & HA_END_SPACE_KEY)) 00068 memcpy(info->lastkey, key, (size_t) keyinfo->length); 00069 } 00070 memcpy(record, pos, (size_t) share->reclength); 00071 info->update= HA_STATE_AKTIV; 00072 DBUG_RETURN(0); 00073 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 22 of file hp_rlast.c.
References st_heap_info::current_hash_ptr, st_heap_info::current_ptr, DBUG_ENTER, DBUG_RETURN, HA_ERR_END_OF_FILE, HA_KEY_ALG_BTREE, HA_STATE_AKTIV, HA_STATE_NEXT_FOUND, heap_rprev(), st_heap_share::keydef, keyinfo, st_heap_info::last_pos, st_heap_info::lastinx, memcpy, my_errno, offsetof, st_heap_info::parents, pos(), st_heap_share::reclength, st_heap_info::s, tree_search_edge(), and st_heap_info::update.
Referenced by ha_heap::index_last(), and main().
00023 { 00024 HP_SHARE *share= info->s; 00025 HP_KEYDEF *keyinfo= share->keydef + inx; 00026 00027 DBUG_ENTER("heap_rlast"); 00028 info->lastinx= inx; 00029 if (keyinfo->algorithm == HA_KEY_ALG_BTREE) 00030 { 00031 byte *pos; 00032 00033 if ((pos = tree_search_edge(&keyinfo->rb_tree, info->parents, 00034 &info->last_pos, offsetof(TREE_ELEMENT, right)))) 00035 { 00036 memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), 00037 sizeof(byte*)); 00038 info->current_ptr = pos; 00039 memcpy(record, pos, (size_t)share->reclength); 00040 info->update = HA_STATE_AKTIV; 00041 } 00042 else 00043 { 00044 my_errno = HA_ERR_END_OF_FILE; 00045 DBUG_RETURN(my_errno); 00046 } 00047 DBUG_RETURN(0); 00048 } 00049 else 00050 { 00051 info->current_ptr=0; 00052 info->current_hash_ptr=0; 00053 info->update=HA_STATE_NEXT_FOUND; 00054 DBUG_RETURN(heap_rprev(info,record)); 00055 } 00056 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 21 of file hp_rnext.c.
References st_heap_info::current_hash_ptr, st_heap_info::current_ptr, DBUG_ENTER, DBUG_RETURN, HA_ERR_END_OF_FILE, HA_ERR_KEY_NOT_FOUND, HA_ERR_WRONG_INDEX, HA_KEY_ALG_BTREE, HA_STATE_AKTIV, HA_STATE_NEXT_FOUND, hp_search(), hp_search_next(), heap_rb_param::key_length, st_heap_share::keydef, keyinfo, heap_rb_param::keyseg, st_heap_info::last_find_flag, st_heap_info::last_pos, st_heap_info::lastinx, st_heap_info::lastkey, st_heap_info::lastkey_len, memcpy, my_errno, offsetof, st_heap_info::parents, pos(), st_heap_share::reclength, st_heap_info::s, SEARCH_FIND, heap_rb_param::search_flag, SEARCH_SAME, st_mi_keydef::seg, tree_search_key(), tree_search_next(), and st_heap_info::update.
Referenced by heap_rfirst(), ha_heap::index_next(), and main().
00022 { 00023 byte *pos; 00024 HP_SHARE *share=info->s; 00025 HP_KEYDEF *keyinfo; 00026 DBUG_ENTER("heap_rnext"); 00027 00028 if (info->lastinx < 0) 00029 DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); 00030 00031 keyinfo = share->keydef + info->lastinx; 00032 if (keyinfo->algorithm == HA_KEY_ALG_BTREE) 00033 { 00034 heap_rb_param custom_arg; 00035 00036 if (info->last_pos) 00037 pos = tree_search_next(&keyinfo->rb_tree, &info->last_pos, 00038 offsetof(TREE_ELEMENT, left), 00039 offsetof(TREE_ELEMENT, right)); 00040 else 00041 { 00042 custom_arg.keyseg = keyinfo->seg; 00043 custom_arg.key_length = info->lastkey_len; 00044 custom_arg.search_flag = SEARCH_SAME | SEARCH_FIND; 00045 pos = tree_search_key(&keyinfo->rb_tree, info->lastkey, info->parents, 00046 &info->last_pos, info->last_find_flag, &custom_arg); 00047 } 00048 if (pos) 00049 { 00050 memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), 00051 sizeof(byte*)); 00052 info->current_ptr = pos; 00053 } 00054 else 00055 { 00056 my_errno = HA_ERR_KEY_NOT_FOUND; 00057 } 00058 } 00059 else 00060 { 00061 if (info->current_hash_ptr) 00062 pos= hp_search_next(info, keyinfo, info->lastkey, 00063 info->current_hash_ptr); 00064 else 00065 { 00066 if (!info->current_ptr && (info->update & HA_STATE_NEXT_FOUND)) 00067 { 00068 pos=0; /* Read next after last */ 00069 my_errno=HA_ERR_KEY_NOT_FOUND; 00070 } 00071 else if (!info->current_ptr) /* Deleted or first call */ 00072 pos= hp_search(info, keyinfo, info->lastkey, 0); 00073 else 00074 pos= hp_search(info, keyinfo, info->lastkey, 1); 00075 } 00076 } 00077 if (!pos) 00078 { 00079 info->update=HA_STATE_NEXT_FOUND; /* For heap_rprev */ 00080 if (my_errno == HA_ERR_KEY_NOT_FOUND) 00081 my_errno=HA_ERR_END_OF_FILE; 00082 DBUG_RETURN(my_errno); 00083 } 00084 memcpy(record,pos,(size_t) share->reclength); 00085 info->update=HA_STATE_AKTIV | HA_STATE_NEXT_FOUND; 00086 DBUG_RETURN(0); 00087 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 22 of file hp_rprev.c.
References st_heap_info::current_ptr, DBUG_ENTER, DBUG_RETURN, HA_ERR_END_OF_FILE, HA_ERR_KEY_NOT_FOUND, HA_ERR_WRONG_INDEX, HA_KEY_ALG_BTREE, HA_STATE_AKTIV, HA_STATE_DELETED, HA_STATE_NEXT_FOUND, HA_STATE_PREV_FOUND, hp_search(), heap_rb_param::key_length, st_heap_share::keydef, keyinfo, heap_rb_param::keyseg, st_heap_info::last_find_flag, st_heap_info::last_pos, st_heap_info::lastinx, st_heap_info::lastkey, memcpy, my_errno, offsetof, st_heap_info::parents, pos(), st_heap_share::reclength, st_heap_info::s, heap_rb_param::search_flag, SEARCH_SAME, st_mi_keydef::seg, tree_search_key(), tree_search_next(), and st_heap_info::update.
Referenced by heap_rlast(), ha_heap::index_prev(), and main().
00023 { 00024 byte *pos; 00025 HP_SHARE *share=info->s; 00026 HP_KEYDEF *keyinfo; 00027 DBUG_ENTER("heap_rprev"); 00028 00029 if (info->lastinx < 0) 00030 DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); 00031 keyinfo = share->keydef + info->lastinx; 00032 if (keyinfo->algorithm == HA_KEY_ALG_BTREE) 00033 { 00034 heap_rb_param custom_arg; 00035 00036 if (info->last_pos) 00037 pos = tree_search_next(&keyinfo->rb_tree, &info->last_pos, 00038 offsetof(TREE_ELEMENT, right), 00039 offsetof(TREE_ELEMENT, left)); 00040 else 00041 { 00042 custom_arg.keyseg = keyinfo->seg; 00043 custom_arg.key_length = keyinfo->length; 00044 custom_arg.search_flag = SEARCH_SAME; 00045 pos = tree_search_key(&keyinfo->rb_tree, info->lastkey, info->parents, 00046 &info->last_pos, info->last_find_flag, &custom_arg); 00047 } 00048 if (pos) 00049 { 00050 memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), 00051 sizeof(byte*)); 00052 info->current_ptr = pos; 00053 } 00054 else 00055 { 00056 my_errno = HA_ERR_KEY_NOT_FOUND; 00057 } 00058 } 00059 else 00060 { 00061 if (info->current_ptr || (info->update & HA_STATE_NEXT_FOUND)) 00062 { 00063 if ((info->update & HA_STATE_DELETED)) 00064 pos= hp_search(info, share->keydef + info->lastinx, info->lastkey, 3); 00065 else 00066 pos= hp_search(info, share->keydef + info->lastinx, info->lastkey, 2); 00067 } 00068 else 00069 { 00070 pos=0; /* Read next after last */ 00071 my_errno=HA_ERR_KEY_NOT_FOUND; 00072 } 00073 } 00074 if (!pos) 00075 { 00076 info->update=HA_STATE_PREV_FOUND; /* For heap_rprev */ 00077 if (my_errno == HA_ERR_KEY_NOT_FOUND) 00078 my_errno=HA_ERR_END_OF_FILE; 00079 DBUG_RETURN(my_errno); 00080 } 00081 memcpy(record,pos,(size_t) share->reclength); 00082 info->update=HA_STATE_AKTIV | HA_STATE_PREV_FOUND; 00083 DBUG_RETURN(0); 00084 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 38 of file hp_scan.c.
References st_heap_share::block, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_heap_share::deleted, HA_ERR_END_OF_FILE, HA_ERR_RECORD_DELETED, HA_STATE_AKTIV, HA_STATE_NEXT_FOUND, HA_STATE_PREV_FOUND, hp_find_record, memcpy, my_errno, pos(), st_heap_block::recbuffer, st_heap_share::reclength, st_heap_share::records, and st_heap_block::records_in_block.
Referenced by main(), and ha_heap::rnd_next().
00039 { 00040 HP_SHARE *share=info->s; 00041 ulong pos; 00042 DBUG_ENTER("heap_scan"); 00043 00044 pos= ++info->current_record; 00045 if (pos < info->next_block) 00046 { 00047 info->current_ptr+=share->block.recbuffer; 00048 } 00049 else 00050 { 00051 info->next_block+=share->block.records_in_block; 00052 if (info->next_block >= share->records+share->deleted) 00053 { 00054 info->next_block= share->records+share->deleted; 00055 if (pos >= info->next_block) 00056 { 00057 info->update= 0; 00058 DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE); 00059 } 00060 } 00061 hp_find_record(info, pos); 00062 } 00063 if (!info->current_ptr[share->reclength]) 00064 { 00065 DBUG_PRINT("warning",("Found deleted record")); 00066 info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND; 00067 DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED); 00068 } 00069 info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; 00070 memcpy(record,info->current_ptr,(size_t) share->reclength); 00071 info->current_hash_ptr=0; /* Can't use read_next */ 00072 DBUG_RETURN(0); 00073 } /* heap_scan */
Here is the call graph for this function:

Here is the caller graph for this function:

| int heap_scan_init | ( | HP_INFO * | info | ) |
Definition at line 21 of file hp_update.c.
References st_hp_keydef::algorithm, st_heap_share::auto_key, st_heap_share::blength, st_heap_share::changed, st_heap_info::current_ptr, DBUG_ENTER, DBUG_EXECUTE, DBUG_RETURN, st_hp_keydef::delete_key, err, HA_ERR_FOUND_DUPP_KEY, HA_KEY_ALG_BTREE, heap_check_heap(), heap_update_auto_increment(), hp_rec_key_cmp(), hp_rectest(), int(), st_heap_share::keydef, st_heap_share::keys, st_heap_info::lastinx, memcpy, my_errno, st_heap_info::opt_flag, pos(), READ_CHECK_USED, st_heap_share::reclength, st_heap_share::records, st_heap_info::s, test_active, and st_hp_keydef::write_key.
Referenced by main(), and ha_heap::update_row().
00022 { 00023 HP_KEYDEF *keydef, *end, *p_lastinx; 00024 byte *pos; 00025 bool auto_key_changed= 0; 00026 HP_SHARE *share= info->s; 00027 DBUG_ENTER("heap_update"); 00028 00029 test_active(info); 00030 pos=info->current_ptr; 00031 00032 if (info->opt_flag & READ_CHECK_USED && hp_rectest(info,old)) 00033 DBUG_RETURN(my_errno); /* Record changed */ 00034 if (--(share->records) < share->blength >> 1) share->blength>>= 1; 00035 share->changed=1; 00036 00037 p_lastinx= share->keydef + info->lastinx; 00038 for (keydef= share->keydef, end= keydef + share->keys; keydef < end; keydef++) 00039 { 00040 if (hp_rec_key_cmp(keydef, old, heap_new, 0)) 00041 { 00042 if ((*keydef->delete_key)(info, keydef, old, pos, keydef == p_lastinx) || 00043 (*keydef->write_key)(info, keydef, heap_new, pos)) 00044 goto err; 00045 if (share->auto_key == (uint) (keydef - share->keydef + 1)) 00046 auto_key_changed= 1; 00047 } 00048 } 00049 00050 memcpy(pos,heap_new,(size_t) share->reclength); 00051 if (++(share->records) == share->blength) share->blength+= share->blength; 00052 00053 #if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG) 00054 DBUG_EXECUTE("check_heap",heap_check_heap(info, 0);); 00055 #endif 00056 if (auto_key_changed) 00057 heap_update_auto_increment(info, heap_new); 00058 DBUG_RETURN(0); 00059 00060 err: 00061 if (my_errno == HA_ERR_FOUND_DUPP_KEY) 00062 { 00063 info->errkey = (int) (keydef - share->keydef); 00064 if (keydef->algorithm == HA_KEY_ALG_BTREE) 00065 { 00066 /* we don't need to delete non-inserted key from rb-tree */ 00067 if ((*keydef->write_key)(info, keydef, old, pos)) 00068 { 00069 if (++(share->records) == share->blength) 00070 share->blength+= share->blength; 00071 DBUG_RETURN(my_errno); 00072 } 00073 keydef--; 00074 } 00075 while (keydef >= share->keydef) 00076 { 00077 if (hp_rec_key_cmp(keydef, old, heap_new, 0)) 00078 { 00079 if ((*keydef->delete_key)(info, keydef, heap_new, pos, 0) || 00080 (*keydef->write_key)(info, keydef, old, pos)) 00081 break; 00082 } 00083 keydef--; 00084 } 00085 } 00086 if (++(share->records) == share->blength) 00087 share->blength+= share->blength; 00088 DBUG_RETURN(my_errno); 00089 } /* heap_update */
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 928 of file hp_hash.c.
References st_heap_share::auto_increment, st_heap_share::auto_key, st_heap_share::auto_key_type, DBUG_ASSERT, float4get, float8get, HA_KEYTYPE_BINARY, HA_KEYTYPE_DOUBLE, HA_KEYTYPE_FLOAT, HA_KEYTYPE_INT24, HA_KEYTYPE_INT8, HA_KEYTYPE_LONG_INT, HA_KEYTYPE_LONGLONG, HA_KEYTYPE_SHORT_INT, HA_KEYTYPE_UINT24, HA_KEYTYPE_ULONG_INT, HA_KEYTYPE_ULONGLONG, HA_KEYTYPE_USHORT_INT, st_heap_share::keydef, keyseg, st_heap_info::s, st_hp_keydef::seg, set_if_bigger, sint2korr, sint3korr, sint4korr, sint8korr, st_HA_KEYSEG::start, uint2korr, uint3korr, uint4korr, uint8korr, and value.
Referenced by heap_update(), and heap_write().
00929 { 00930 ulonglong value= 0; /* Store unsigned values here */ 00931 longlong s_value= 0; /* Store signed values here */ 00932 00933 HA_KEYSEG *keyseg= info->s->keydef[info->s->auto_key - 1].seg; 00934 const uchar *key= (uchar*) record + keyseg->start; 00935 00936 switch (info->s->auto_key_type) { 00937 case HA_KEYTYPE_INT8: 00938 s_value= (longlong) *(char*)key; 00939 break; 00940 case HA_KEYTYPE_BINARY: 00941 value=(ulonglong) *(uchar*) key; 00942 break; 00943 case HA_KEYTYPE_SHORT_INT: 00944 s_value= (longlong) sint2korr(key); 00945 break; 00946 case HA_KEYTYPE_USHORT_INT: 00947 value=(ulonglong) uint2korr(key); 00948 break; 00949 case HA_KEYTYPE_LONG_INT: 00950 s_value= (longlong) sint4korr(key); 00951 break; 00952 case HA_KEYTYPE_ULONG_INT: 00953 value=(ulonglong) uint4korr(key); 00954 break; 00955 case HA_KEYTYPE_INT24: 00956 s_value= (longlong) sint3korr(key); 00957 break; 00958 case HA_KEYTYPE_UINT24: 00959 value=(ulonglong) uint3korr(key); 00960 break; 00961 case HA_KEYTYPE_FLOAT: /* This shouldn't be used */ 00962 { 00963 float f_1; 00964 float4get(f_1,key); 00965 /* Ignore negative values */ 00966 value = (f_1 < (float) 0.0) ? 0 : (ulonglong) f_1; 00967 break; 00968 } 00969 case HA_KEYTYPE_DOUBLE: /* This shouldn't be used */ 00970 { 00971 double f_1; 00972 float8get(f_1,key); 00973 /* Ignore negative values */ 00974 value = (f_1 < 0.0) ? 0 : (ulonglong) f_1; 00975 break; 00976 } 00977 case HA_KEYTYPE_LONGLONG: 00978 s_value= sint8korr(key); 00979 break; 00980 case HA_KEYTYPE_ULONGLONG: 00981 value= uint8korr(key); 00982 break; 00983 default: 00984 DBUG_ASSERT(0); 00985 value=0; /* Error */ 00986 break; 00987 } 00988 00989 /* 00990 The following code works becasue if s_value < 0 then value is 0 00991 and if s_value == 0 then value will contain either s_value or the 00992 correct value. 00993 */ 00994 set_if_bigger(info->s->auto_increment, 00995 (s_value > 0) ? (ulonglong) s_value : value); 00996 }
Here is the caller graph for this function:

Definition at line 33 of file hp_write.c.
References st_hp_keydef::algorithm, st_heap_share::auto_key, st_heap_share::blength, st_heap_share::changed, st_heap_info::current_hash_ptr, st_heap_info::current_ptr, DBUG_ENTER, DBUG_EXECUTE, DBUG_PRINT, DBUG_RETURN, st_heap_share::del_link, st_hp_keydef::delete_key, st_heap_share::deleted, err, st_heap_info::errkey, HA_KEY_ALG_BTREE, HA_STATE_AKTIV, heap_check_heap(), heap_update_auto_increment(), st_heap_share::keydef, st_heap_share::keys, memcpy, st_heap_info::mode, my_errno, next_free_record_pos(), pos(), st_heap_share::reclength, st_heap_share::records, st_heap_info::s, st_heap_info::update, and st_hp_keydef::write_key.
Referenced by main(), and ha_heap::write_row().
00034 { 00035 HP_KEYDEF *keydef, *end; 00036 byte *pos; 00037 HP_SHARE *share=info->s; 00038 DBUG_ENTER("heap_write"); 00039 #ifndef DBUG_OFF 00040 if (info->mode & O_RDONLY) 00041 { 00042 DBUG_RETURN(my_errno=EACCES); 00043 } 00044 #endif 00045 if (!(pos=next_free_record_pos(share))) 00046 DBUG_RETURN(my_errno); 00047 share->changed=1; 00048 00049 for (keydef = share->keydef, end = keydef + share->keys; keydef < end; 00050 keydef++) 00051 { 00052 if ((*keydef->write_key)(info, keydef, record, pos)) 00053 goto err; 00054 } 00055 00056 memcpy(pos,record,(size_t) share->reclength); 00057 pos[share->reclength]=1; /* Mark record as not deleted */ 00058 if (++share->records == share->blength) 00059 share->blength+= share->blength; 00060 info->current_ptr=pos; 00061 info->current_hash_ptr=0; 00062 info->update|=HA_STATE_AKTIV; 00063 #if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG) 00064 DBUG_EXECUTE("check_heap",heap_check_heap(info, 0);); 00065 #endif 00066 if (share->auto_key) 00067 heap_update_auto_increment(info, record); 00068 DBUG_RETURN(0); 00069 00070 err: 00071 DBUG_PRINT("info",("Duplicate key: %d", keydef - share->keydef)); 00072 info->errkey= keydef - share->keydef; 00073 if (keydef->algorithm == HA_KEY_ALG_BTREE) 00074 { 00075 /* we don't need to delete non-inserted key from rb-tree */ 00076 keydef--; 00077 } 00078 while (keydef >= share->keydef) 00079 { 00080 if ((*keydef->delete_key)(info, keydef, record, pos, 0)) 00081 break; 00082 keydef--; 00083 } 00084 00085 share->deleted++; 00086 *((byte**) pos)=share->del_link; 00087 share->del_link=pos; 00088 pos[share->reclength]=0; /* Record deleted */ 00089 00090 DBUG_RETURN(my_errno); 00091 } /* heap_write */
Here is the call graph for this function:

Here is the caller graph for this function:

| ha_rows hp_rb_records_in_range | ( | HP_INFO * | info, | |
| int | inx, | |||
| key_range * | min_key, | |||
| key_range * | max_key | |||
| ) |
Definition at line 50 of file hp_hash.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_tree::elements_in_tree, st_key_range::flag, HA_POS_ERROR, hp_rb_pack_key(), st_key_range::key, heap_rb_param::key_length, st_heap_share::keydef, keyinfo, heap_rb_param::keyseg, st_heap_info::lastinx, st_key_range::length, st_heap_info::recbuf, st_heap_info::s, SEARCH_FIND, heap_rb_param::search_flag, SEARCH_SAME, st_mi_keydef::seg, and tree_record_pos().
Referenced by ha_heap::records_in_range().
00052 { 00053 ha_rows start_pos, end_pos; 00054 HP_KEYDEF *keyinfo= info->s->keydef + inx; 00055 TREE *rb_tree = &keyinfo->rb_tree; 00056 heap_rb_param custom_arg; 00057 DBUG_ENTER("hp_rb_records_in_range"); 00058 00059 info->lastinx= inx; 00060 custom_arg.keyseg= keyinfo->seg; 00061 custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME; 00062 if (min_key) 00063 { 00064 custom_arg.key_length= hp_rb_pack_key(keyinfo, (uchar*) info->recbuf, 00065 (uchar*) min_key->key, 00066 min_key->length); 00067 start_pos= tree_record_pos(rb_tree, info->recbuf, min_key->flag, 00068 &custom_arg); 00069 } 00070 else 00071 { 00072 start_pos= 0; 00073 } 00074 00075 if (max_key) 00076 { 00077 custom_arg.key_length= hp_rb_pack_key(keyinfo, (uchar*) info->recbuf, 00078 (uchar*) max_key->key, 00079 max_key->length); 00080 end_pos= tree_record_pos(rb_tree, info->recbuf, max_key->flag, 00081 &custom_arg); 00082 } 00083 else 00084 { 00085 end_pos= rb_tree->elements_in_tree + (ha_rows)1; 00086 } 00087 00088 DBUG_PRINT("info",("start_pos: %lu end_pos: %lu", (ulong) start_pos, 00089 (ulong) end_pos)); 00090 if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR) 00091 DBUG_RETURN(HA_POS_ERROR); 00092 DBUG_RETURN(end_pos < start_pos ? (ha_rows) 0 : 00093 (end_pos == start_pos ? (ha_rows) 1 : end_pos - start_pos)); 00094 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

