98
101
HP_PTRS *root; /* Top-level block */
99
102
struct st_level_info level_info[HP_MAX_LEVELS+1];
100
uint32_t levels; /* number of used levels */
101
uint32_t records_in_block; /* Records in one heap-block */
102
uint32_t recbuffer; /* Length of one saved record */
103
uint32_t last_allocated; /* number of records there is allocated space for */
103
uint levels; /* number of used levels */
104
uint records_in_block; /* Records in one heap-block */
105
uint recbuffer; /* Length of one saved record */
106
ulong last_allocated; /* number of records there is allocated space for */
106
109
struct st_heap_info; /* For referense */
108
111
typedef struct st_hp_keydef /* Key definition with open */
110
uint32_t flag; /* HA_NOSAME | HA_NULL_PART_KEY */
111
uint32_t keysegs; /* Number of key-segment */
112
uint32_t length; /* Length of key (automatic) */
113
uint8_t algorithm; /* HASH / BTREE */
113
uint flag; /* HA_NOSAME | HA_NULL_PART_KEY */
114
uint keysegs; /* Number of key-segment */
115
uint length; /* Length of key (automatic) */
116
uint8 algorithm; /* HASH / BTREE */
115
118
HP_BLOCK block; /* Where keys are saved */
120
123
ha_rows hash_buckets;
122
125
int (*write_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
123
const unsigned char *record, unsigned char *recpos);
126
const uchar *record, uchar *recpos);
124
127
int (*delete_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
125
const unsigned char *record, unsigned char *recpos, int flag);
126
uint32_t (*get_key_length)(struct st_hp_keydef *keydef, const unsigned char *key);
128
const uchar *record, uchar *recpos, int flag);
129
uint (*get_key_length)(struct st_hp_keydef *keydef, const uchar *key);
129
typedef struct st_heap_columndef /* column information */
131
int16_t type; /* en_fieldtype */
132
uint32_t length; /* length of field */
133
uint32_t offset; /* Offset to position in row */
134
uint8_t null_bit; /* If column may be 0 */
135
uint16_t null_pos; /* position for null marker */
136
uint8_t length_bytes; /* length of the size, 1 o 2 bytes */
139
typedef struct st_heap_dataspace /* control data for data space */
132
typedef struct st_heap_share
142
uint32_t chunk_count; /* Total chunks ever allocated in this dataspace */
143
uint32_t del_chunk_count; /* Deleted chunks count */
144
unsigned char *del_link; /* Link to last deleted chunk */
145
uint32_t chunk_length; /* Total length of one chunk */
146
uint32_t chunk_dataspace_length; /* Length of payload that will be placed into one chunk */
147
uint32_t offset_status; /* Offset of the status flag relative to the chunk start */
148
uint32_t offset_link; /* Offset of the linking pointer relative to the chunk start */
149
uint32_t is_variable_size; /* Test whether records have variable size and so "next" pointer */
150
uint64_t total_data_length; /* Total size allocated within this data space */
154
typedef struct st_heap_share
156
135
HP_KEYDEF *keydef;
157
HP_COLUMNDEF *column_defs;
158
HP_DATASPACE recordspace; /* Describes "block", which contains actual records */
160
uint32_t min_records,max_records; /* Params to open */
161
uint64_t index_length,max_table_size;
162
uint32_t key_stat_version; /* version to indicate insert/delete */
163
uint32_t records; /* Actual record (row) count */
164
uint32_t blength; /* used_chunk_count rounded up to 2^n */
165
uint32_t fixed_data_length; /* Length of record's fixed part, which contains keys and always fits into the first chunk */
166
uint32_t fixed_column_count; /* Number of columns stored in fixed_data_length */
168
uint32_t keys,max_key_length;
169
uint32_t column_count;
170
uint32_t currently_disabled_keys; /* saved value from "keys" when disabled */
136
ulong min_records,max_records; /* Params to open */
137
ulonglong data_length,index_length,max_table_size;
138
uint key_stat_version; /* version to indicate insert/delete */
139
uint records; /* records */
140
uint blength; /* records rounded up to 2^n */
141
uint deleted; /* Deleted records in database */
142
uint reclength; /* Length of one record */
144
uint keys,max_key_length;
145
uint currently_disabled_keys; /* saved value from "keys" when disabled */
147
uchar *del_link; /* Link to next block with del. rec */
174
148
char * name; /* Name of "memory-file" */
176
151
pthread_mutex_t intern_lock; /* Locking for use with _locking */
177
bool delete_on_close;
153
my_bool delete_on_close;
180
uint32_t auto_key_type; /* real type of the auto key segment */
181
uint64_t auto_increment;
156
uint auto_key_type; /* real type of the auto key segment */
157
ulonglong auto_increment;
184
160
struct st_hp_hash_info;
186
162
typedef struct st_heap_info
189
unsigned char *current_ptr;
190
166
struct st_hp_hash_info *current_hash_ptr;
191
uint32_t current_record,next_block;
167
ulong current_record,next_block;
192
168
int lastinx,errkey;
193
169
int mode; /* Mode of file (READONLY..) */
194
uint32_t opt_flag,update;
195
unsigned char *lastkey; /* Last used key with rkey */
196
unsigned char *recbuf; /* Record buffer for rb-tree keys */
170
uint opt_flag,update;
171
uchar *lastkey; /* Last used key with rkey */
172
uchar *recbuf; /* Record buffer for rb-tree keys */
197
173
enum ha_rkey_function last_find_flag;
198
174
TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1];
199
175
TREE_ELEMENT **last_pos;
200
uint32_t lastkey_len;
201
bool implicit_emptied;
177
my_bool implicit_emptied;
202
179
THR_LOCK_DATA lock;
207
185
typedef struct st_heap_create_info
209
uint32_t auto_key; /* keynr [1 - maxkey] for auto key */
210
uint32_t auto_key_type;
211
uint32_t max_chunk_size;
213
uint64_t max_table_size;
214
uint64_t auto_increment;
215
bool with_auto_increment;
187
uint auto_key; /* keynr [1 - maxkey] for auto key */
189
ulonglong max_table_size;
190
ulonglong auto_increment;
191
my_bool with_auto_increment;
192
my_bool internal_table;
217
193
} HP_CREATE_INFO;
219
195
/* Prototypes for heap-functions */
222
198
extern HP_INFO *heap_open_from_share(HP_SHARE *share, int mode);
223
199
extern HP_INFO *heap_open_from_share_and_register(HP_SHARE *share, int mode);
224
200
extern int heap_close(HP_INFO *info);
225
extern int heap_write(HP_INFO *info,const unsigned char *record);
226
extern int heap_update(HP_INFO *info,const unsigned char *old_record,const unsigned char *new_record);
227
extern int heap_rrnd(HP_INFO *info,unsigned char *buf,unsigned char *pos);
201
extern int heap_write(HP_INFO *info,const uchar *buff);
202
extern int heap_update(HP_INFO *info,const uchar *old,const uchar *newdata);
203
extern int heap_rrnd(HP_INFO *info,uchar *buf,uchar *pos);
228
204
extern int heap_scan_init(HP_INFO *info);
229
extern int heap_scan(register HP_INFO *info, unsigned char *record);
230
extern int heap_delete(HP_INFO *info,const unsigned char *buff);
205
extern int heap_scan(register HP_INFO *info, uchar *record);
206
extern int heap_delete(HP_INFO *info,const uchar *buff);
231
207
extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag);
232
extern int heap_create(const char *name, uint32_t keys, HP_KEYDEF *keydef,
233
uint32_t columns, HP_COLUMNDEF *columndef,
234
uint32_t max_key_fieldnr, uint32_t key_part_size,
235
uint32_t reclength, uint32_t keys_memory_size,
236
uint32_t max_records, uint32_t min_records,
237
HP_CREATE_INFO *create_info, HP_SHARE **share);
208
extern int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
209
uint reclength, ulong max_records, ulong min_records,
210
HP_CREATE_INFO *create_info, HP_SHARE **share);
239
211
extern int heap_delete_table(const char *name);
240
212
extern void heap_drop_table(HP_INFO *info);
241
213
extern int heap_extra(HP_INFO *info,enum ha_extra_function function);
242
214
extern int heap_reset(HP_INFO *info);
243
215
extern int heap_rename(const char *old_name,const char *new_name);
244
216
extern int heap_panic(enum ha_panic_function flag);
245
extern int heap_rsame(HP_INFO *info,unsigned char *record,int inx);
246
extern int heap_rnext(HP_INFO *info,unsigned char *record);
247
extern int heap_rprev(HP_INFO *info,unsigned char *record);
248
extern int heap_rfirst(HP_INFO *info,unsigned char *record,int inx);
249
extern int heap_rlast(HP_INFO *info,unsigned char *record,int inx);
217
extern int heap_rsame(HP_INFO *info,uchar *record,int inx);
218
extern int heap_rnext(HP_INFO *info,uchar *record);
219
extern int heap_rprev(HP_INFO *info,uchar *record);
220
extern int heap_rfirst(HP_INFO *info,uchar *record,int inx);
221
extern int heap_rlast(HP_INFO *info,uchar *record,int inx);
250
222
extern void heap_clear(HP_INFO *info);
251
223
extern void heap_clear_keys(HP_INFO *info);
252
224
extern int heap_disable_indexes(HP_INFO *info);
253
225
extern int heap_enable_indexes(HP_INFO *info);
254
226
extern int heap_indexes_are_disabled(HP_INFO *info);
255
extern void heap_update_auto_increment(HP_INFO *info, const unsigned char *record);
227
extern void heap_update_auto_increment(HP_INFO *info, const uchar *record);
256
228
ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key,
257
229
key_range *max_key);
258
230
int hp_panic(enum ha_panic_function flag);
259
int heap_rkey(HP_INFO *info, unsigned char *record, int inx, const unsigned char *key,
231
int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key,
260
232
key_part_map keypart_map, enum ha_rkey_function find_flag);
261
extern unsigned char * heap_find(HP_INFO *info,int inx,const unsigned char *key);
262
extern int heap_check_heap(HP_INFO *info, bool print_status);
263
extern unsigned char *heap_position(HP_INFO *info);
233
extern uchar * heap_find(HP_INFO *info,int inx,const uchar *key);
234
extern int heap_check_heap(HP_INFO *info, my_bool print_status);
235
extern uchar *heap_position(HP_INFO *info);
265
237
/* The following is for programs that uses the old HEAP interface where
266
pointer to rows where a long instead of a (unsigned char*).
238
pointer to rows where a long instead of a (uchar*).
269
241
#if defined(WANT_OLD_HEAP_VERSION) || defined(OLD_HEAP_VERSION)
270
extern int heap_rrnd_old(HP_INFO *info,unsigned char *buf,uint32_t pos);
271
extern uint32_t heap_position_old(HP_INFO *info);
242
extern int heap_rrnd_old(HP_INFO *info,uchar *buf,ulong pos);
243
extern ulong heap_position_old(HP_INFO *info);
273
245
#ifdef OLD_HEAP_VERSION
274
typedef uint32_t HEAP_PTR;
246
typedef ulong HEAP_PTR;
275
247
#define heap_position(A) heap_position_old(A)
276
248
#define heap_rrnd(A,B,C) heap_rrnd_old(A,B,C)
278
typedef unsigned char *HEAP_PTR;
250
typedef uchar *HEAP_PTR;
281
253
#ifdef __cplusplus