14
12
You should have received a copy of the GNU General Public License
15
13
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18
16
/* This file should be included when using heap_database_functions */
19
17
/* Author: Michael Widenius */
21
#ifndef PLUGIN_MEMORY_HEAP_H
22
#define PLUGIN_MEMORY_HEAP_H
19
#ifndef PLUGIN_HEAP_HEAP_H
20
#define PLUGIN_HEAP_HEAP_H
24
26
#include <drizzled/base.h>
25
27
#include <drizzled/common.h>
26
#include "drizzled/internal/my_pthread.h"
27
#include <drizzled/thr_lock.h>
28
#include <mysys/my_pthread.h>
29
#include <mysys/thr_lock.h>
29
31
#include <plugin/myisam/my_handler.h>
30
#include "drizzled/tree.h"
32
#include <mysys/my_tree.h>
34
34
/* defines used by heap-funktions */
138
111
uint32_t flag; /* HA_NOSAME | HA_NULL_PART_KEY */
139
112
uint32_t keysegs; /* Number of key-segment */
140
113
uint32_t length; /* Length of key (automatic) */
114
uint8_t algorithm; /* HASH / BTREE */
142
116
HP_BLOCK block; /* Where keys are saved */
144
118
Number of buckets used in hash table. Used only to provide
145
119
#records estimates for heap key scans.
147
drizzled::ha_rows hash_buckets;
121
ha_rows hash_buckets;
123
int (*write_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
124
const unsigned char *record, unsigned char *recpos);
125
int (*delete_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
126
const unsigned char *record, unsigned char *recpos, int flag);
127
uint32_t (*get_key_length)(struct st_hp_keydef *keydef, const unsigned char *key);
130
typedef struct st_heap_columndef /* column information */
132
int16_t type; /* en_fieldtype */
133
uint32_t length; /* length of field */
134
uint32_t offset; /* Offset to position in row */
135
uint8_t null_bit; /* If column may be 0 */
136
uint16_t null_pos; /* position for null marker */
137
uint8_t length_bytes; /* length of the size, 1 o 2 bytes */
150
140
typedef struct st_heap_dataspace /* control data for data space */
157
147
uint32_t chunk_dataspace_length; /* Length of payload that will be placed into one chunk */
158
148
uint32_t offset_status; /* Offset of the status flag relative to the chunk start */
159
149
uint32_t offset_link; /* Offset of the linking pointer relative to the chunk start */
150
uint32_t is_variable_size; /* Test whether records have variable size and so "next" pointer */
160
151
uint64_t total_data_length; /* Total size allocated within this data space */
162
st_heap_dataspace() :
167
chunk_dataspace_length(0),
176
155
typedef struct st_heap_share
178
157
HP_KEYDEF *keydef;
158
HP_COLUMNDEF *column_defs;
179
159
HP_DATASPACE recordspace; /* Describes "block", which contains actual records */
181
161
uint32_t min_records,max_records; /* Params to open */
192
172
uint32_t open_count;
195
std::string name; /* Name of "memory-file" */
175
char * name; /* Name of "memory-file" */
177
pthread_mutex_t intern_lock; /* Locking for use with _locking */
196
178
bool delete_on_close;
197
179
uint32_t auto_key;
198
180
uint32_t auto_key_type; /* real type of the auto key segment */
199
181
uint64_t auto_increment;
210
fixed_data_length(0),
211
fixed_column_count(0),
216
currently_disabled_keys(0),
226
184
struct st_hp_hash_info;
228
186
typedef struct st_heap_info
239
void setShare(HP_SHARE *s_arg)
244
189
unsigned char *current_ptr;
245
190
struct st_hp_hash_info *current_hash_ptr;
246
191
uint32_t current_record,next_block;
247
192
int lastinx,errkey;
248
193
int mode; /* Mode of file (READONLY..) */
249
194
uint32_t opt_flag,update;
250
std::vector <unsigned char> lastkey; /* Last used key with rkey */
251
enum drizzled::ha_rkey_function last_find_flag;
195
unsigned char *lastkey; /* Last used key with rkey */
196
unsigned char *recbuf; /* Record buffer for rb-tree keys */
197
enum ha_rkey_function last_find_flag;
198
TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1];
199
TREE_ELEMENT **last_pos;
252
200
uint32_t lastkey_len;
253
drizzled::THR_LOCK_DATA lock;
201
bool implicit_emptied;
279
229
extern int heap_delete(HP_INFO *info,const unsigned char *buff);
280
230
extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag);
281
231
extern int heap_create(const char *name, uint32_t keys, HP_KEYDEF *keydef,
283
uint32_t key_part_size,
232
uint32_t columns, HP_COLUMNDEF *columndef,
233
uint32_t max_key_fieldnr, uint32_t key_part_size,
284
234
uint32_t reclength, uint32_t keys_memory_size,
285
235
uint32_t max_records, uint32_t min_records,
286
236
HP_CREATE_INFO *create_info, HP_SHARE **share);
288
238
extern int heap_delete_table(const char *name);
289
extern int heap_extra(HP_INFO *info,enum drizzled::ha_extra_function function);
239
extern void heap_drop_table(HP_INFO *info);
240
extern int heap_extra(HP_INFO *info,enum ha_extra_function function);
290
241
extern int heap_reset(HP_INFO *info);
291
242
extern int heap_rename(const char *old_name,const char *new_name);
292
extern int heap_panic(enum drizzled::ha_panic_function flag);
243
extern int heap_panic(enum ha_panic_function flag);
293
244
extern int heap_rsame(HP_INFO *info,unsigned char *record,int inx);
294
245
extern int heap_rnext(HP_INFO *info,unsigned char *record);
295
246
extern int heap_rprev(HP_INFO *info,unsigned char *record);
296
247
extern int heap_rfirst(HP_INFO *info,unsigned char *record,int inx);
297
248
extern int heap_rlast(HP_INFO *info,unsigned char *record,int inx);
298
249
extern void heap_clear(HP_INFO *info);
250
extern void heap_clear_keys(HP_INFO *info);
299
251
extern int heap_disable_indexes(HP_INFO *info);
300
252
extern int heap_enable_indexes(HP_INFO *info);
301
253
extern int heap_indexes_are_disabled(HP_INFO *info);
302
254
extern void heap_update_auto_increment(HP_INFO *info, const unsigned char *record);
303
int hp_panic(enum drizzled::ha_panic_function flag);
255
ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key,
257
int hp_panic(enum ha_panic_function flag);
304
258
int heap_rkey(HP_INFO *info, unsigned char *record, int inx, const unsigned char *key,
305
drizzled::key_part_map keypart_map,
306
enum drizzled::ha_rkey_function find_flag);
259
key_part_map keypart_map, enum ha_rkey_function find_flag);
307
260
extern unsigned char * heap_find(HP_INFO *info,int inx,const unsigned char *key);
261
extern int heap_check_heap(HP_INFO *info, bool print_status);
308
262
extern unsigned char *heap_position(HP_INFO *info);
310
264
/* The following is for programs that uses the old HEAP interface where