~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/myisam.h

  • Committer: Lee
  • Date: 2008-10-03 23:31:06 UTC
  • mfrom: (413.2.3 drizzle)
  • mto: This revision was merged to the branch mainline in revision 459.
  • Revision ID: lbieber@lbieber-desktop-20081003233106-tgvzu0fh25gb3xeg
breaking out enum field classes

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <drizzled/base.h>
25
25
#ifndef _m_ctype_h
26
 
#include <mystrings/m_ctype.h>
 
26
#include <m_ctype.h>
27
27
#endif
28
28
#ifndef _keycache_h
29
29
#include "keycache.h"
30
30
#endif
31
31
#include <mysys/my_handler.h>
32
 
#include <mysys/iocache.h>
33
32
#include <drizzled/plugin.h>
34
33
 
35
34
/*
70
69
  This means that clearing of high keys is ignored, setting one high key
71
70
  sets all high keys.
72
71
*/
73
 
#define MI_KEYMAP_BITS      (64)
 
72
#define MI_KEYMAP_BITS      (8 * SIZEOF_LONG_LONG)
74
73
#define MI_KEYMAP_HIGH_MASK (1UL << (MI_KEYMAP_BITS - 1))
75
74
#define mi_get_mask_all_keys_active(_keys_) \
76
75
                            (((_keys_) < MI_KEYMAP_BITS) ? \
139
138
  uint64_t auto_increment;
140
139
  uint64_t key_map;                     /* Which keys are used */
141
140
  char  *data_file_name, *index_file_name;
142
 
  uint32_t  keys;                               /* Number of keys in use */
 
141
  uint  keys;                           /* Number of keys in use */
143
142
  uint  options;                        /* HA_OPTION_... used */
144
143
  int   errkey,                         /* With key was dupplicated on err */
145
144
        sortkey;                        /* clustered by this key */
147
146
  time_t create_time;                   /* When table was created */
148
147
  time_t check_time;
149
148
  time_t update_time;
150
 
  uint32_t  reflength;
 
149
  uint  reflength;
151
150
  ulong record_offset;
152
151
  ulong *rec_per_key;                   /* for sql optimizing */
153
152
} MI_ISAMINFO;
161
160
  uint64_t auto_increment;
162
161
  uint64_t data_file_length;
163
162
  uint64_t key_file_length;
164
 
  uint32_t old_options;
 
163
  uint old_options;
165
164
  uint8_t language;
166
165
  bool with_auto_increment;
167
166
} MI_CREATE_INFO;
189
188
  HA_KEYSEG *seg,*end;
190
189
 
191
190
  int (*bin_search)(struct st_myisam_info *info,struct st_mi_keydef *keyinfo,
192
 
                    unsigned char *page,unsigned char *key,
193
 
                    uint32_t key_len,uint32_t comp_flag,unsigned char * *ret_pos,
194
 
                    unsigned char *buff, bool *was_last_key);
195
 
  uint32_t (*get_key)(struct st_mi_keydef *keyinfo,uint32_t nod_flag,unsigned char * *page,
196
 
                  unsigned char *key);
197
 
  int (*pack_key)(struct st_mi_keydef *keyinfo,uint32_t nod_flag,unsigned char *next_key,
198
 
                  unsigned char *org_key, unsigned char *prev_key, unsigned char *key,
 
191
                    uchar *page,uchar *key,
 
192
                    uint key_len,uint comp_flag,uchar * *ret_pos,
 
193
                    uchar *buff, bool *was_last_key);
 
194
  uint (*get_key)(struct st_mi_keydef *keyinfo,uint nod_flag,uchar * *page,
 
195
                  uchar *key);
 
196
  int (*pack_key)(struct st_mi_keydef *keyinfo,uint nod_flag,uchar *next_key,
 
197
                  uchar *org_key, uchar *prev_key, uchar *key,
199
198
                  struct st_mi_s_param *s_temp);
200
 
  void (*store_key)(struct st_mi_keydef *keyinfo, unsigned char *key_pos,
 
199
  void (*store_key)(struct st_mi_keydef *keyinfo, uchar *key_pos,
201
200
                    struct st_mi_s_param *s_temp);
202
 
  int (*ck_insert)(struct st_myisam_info *inf, uint32_t k_nr, unsigned char *k, uint32_t klen);
203
 
  int (*ck_delete)(struct st_myisam_info *inf, uint32_t k_nr, unsigned char *k, uint32_t klen);
 
201
  int (*ck_insert)(struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
 
202
  int (*ck_delete)(struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
204
203
} MI_KEYDEF;
205
204
 
206
205
 
209
208
typedef struct st_unique_def            /* Segment definition of unique */
210
209
{
211
210
  uint16_t keysegs;                     /* Number of key-segment */
212
 
  unsigned char key;                            /* Mapped to which key */
 
211
  uchar key;                            /* Mapped to which key */
213
212
  uint8_t null_are_equal;
214
213
  HA_KEYSEG *seg,*end;
215
214
} MI_UNIQUEDEF;
218
217
{
219
218
  uint16_t *table;
220
219
  uint   quick_table_bits;
221
 
  unsigned char  *intervalls;
 
220
  uchar  *intervalls;
222
221
} MI_DECODE_TREE;
223
222
 
224
223
 
240
239
 
241
240
#ifndef NOT_PACKED_DATABASES
242
241
  void (*unpack)(struct st_columndef *rec,struct st_mi_bit_buff *buff,
243
 
                 unsigned char *start,unsigned char *end);
 
242
                 uchar *start,uchar *end);
244
243
  enum en_fieldtype base_type;
245
 
  uint32_t space_length_bits,pack_type;
 
244
  uint space_length_bits,pack_type;
246
245
  MI_DECODE_TREE *huff_tree;
247
246
#endif
248
247
} MI_COLUMNDEF;
258
257
        /* Prototypes for myisam-functions */
259
258
 
260
259
extern int mi_close(struct st_myisam_info *file);
261
 
extern int mi_delete(struct st_myisam_info *file,const unsigned char *buff);
 
260
extern int mi_delete(struct st_myisam_info *file,const uchar *buff);
262
261
extern struct st_myisam_info *mi_open(const char *name,int mode,
263
 
                                      uint32_t wait_if_locked);
 
262
                                      uint wait_if_locked);
264
263
extern int mi_panic(enum ha_panic_function function);
265
 
extern int mi_rfirst(struct st_myisam_info *file,unsigned char *buf,int inx);
266
 
extern int mi_rkey(MI_INFO *info, unsigned char *buf, int inx, const unsigned char *key,
 
264
extern int mi_rfirst(struct st_myisam_info *file,uchar *buf,int inx);
 
265
extern int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key,
267
266
                   key_part_map keypart_map, enum ha_rkey_function search_flag);
268
 
extern int mi_rlast(struct st_myisam_info *file,unsigned char *buf,int inx);
269
 
extern int mi_rnext(struct st_myisam_info *file,unsigned char *buf,int inx);
270
 
extern int mi_rnext_same(struct st_myisam_info *info, unsigned char *buf);
271
 
extern int mi_rprev(struct st_myisam_info *file,unsigned char *buf,int inx);
272
 
extern int mi_rrnd(struct st_myisam_info *file,unsigned char *buf, my_off_t pos);
 
267
extern int mi_rlast(struct st_myisam_info *file,uchar *buf,int inx);
 
268
extern int mi_rnext(struct st_myisam_info *file,uchar *buf,int inx);
 
269
extern int mi_rnext_same(struct st_myisam_info *info, uchar *buf);
 
270
extern int mi_rprev(struct st_myisam_info *file,uchar *buf,int inx);
 
271
extern int mi_rrnd(struct st_myisam_info *file,uchar *buf, my_off_t pos);
273
272
extern int mi_scan_init(struct st_myisam_info *file);
274
 
extern int mi_scan(struct st_myisam_info *file,unsigned char *buf);
275
 
extern int mi_rsame(struct st_myisam_info *file,unsigned char *record,int inx);
276
 
extern int mi_rsame_with_pos(struct st_myisam_info *file,unsigned char *record,
 
273
extern int mi_scan(struct st_myisam_info *file,uchar *buf);
 
274
extern int mi_rsame(struct st_myisam_info *file,uchar *record,int inx);
 
275
extern int mi_rsame_with_pos(struct st_myisam_info *file,uchar *record,
277
276
                             int inx, my_off_t pos);
278
 
extern int mi_update(struct st_myisam_info *file,const unsigned char *old,
279
 
                     unsigned char *new_record);
280
 
extern int mi_write(struct st_myisam_info *file,unsigned char *buff);
 
277
extern int mi_update(struct st_myisam_info *file,const uchar *old,
 
278
                     uchar *new_record);
 
279
extern int mi_write(struct st_myisam_info *file,uchar *buff);
281
280
extern my_off_t mi_position(struct st_myisam_info *file);
282
 
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint32_t flag);
 
281
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint flag);
283
282
extern int mi_lock_database(struct st_myisam_info *file,int lock_type);
284
 
extern int mi_create(const char *name,uint32_t keys,MI_KEYDEF *keydef,
285
 
                     uint32_t columns, MI_COLUMNDEF *columndef,
286
 
                     uint32_t uniques, MI_UNIQUEDEF *uniquedef,
287
 
                     MI_CREATE_INFO *create_info, uint32_t flags);
 
283
extern int mi_create(const char *name,uint keys,MI_KEYDEF *keydef,
 
284
                     uint columns, MI_COLUMNDEF *columndef,
 
285
                     uint uniques, MI_UNIQUEDEF *uniquedef,
 
286
                     MI_CREATE_INFO *create_info, uint flags);
288
287
extern int mi_delete_table(const char *name);
289
288
extern int mi_rename(const char *from, const char *to);
290
289
extern int mi_extra(struct st_myisam_info *file,
296
295
extern int mi_log(int activate_log);
297
296
extern int mi_is_changed(struct st_myisam_info *info);
298
297
extern int mi_delete_all_rows(struct st_myisam_info *info);
299
 
extern ulong _mi_calc_blob_length(uint32_t length , const unsigned char *pos);
300
 
extern uint32_t mi_get_pointer_length(uint64_t file_length, uint32_t def);
 
298
extern ulong _mi_calc_blob_length(uint length , const uchar *pos);
 
299
extern uint mi_get_pointer_length(uint64_t file_length, uint def);
301
300
 
302
301
/* this is used to pass to mysql_myisamchk_table */
303
302
 
365
364
 
366
365
typedef struct st_sort_key_blocks               /* Used when sorting */
367
366
{
368
 
  unsigned char *buff,*end_pos;
369
 
  unsigned char lastkey[MI_MAX_POSSIBLE_KEY_BUFF];
370
 
  uint32_t last_length;
 
367
  uchar *buff,*end_pos;
 
368
  uchar lastkey[MI_MAX_POSSIBLE_KEY_BUFF];
 
369
  uint last_length;
371
370
  int inited;
372
371
} SORT_KEY_BLOCKS;
373
372
 
401
400
  ha_checksum record_checksum,glob_crc;
402
401
  ulong use_buffers,read_buffer_length,write_buffer_length,
403
402
        sort_buffer_length,sort_key_blocks;
404
 
  uint32_t out_flag,warning_printed,error_printed,verbose;
405
 
  uint32_t opt_sort_key,total_files,max_level;
406
 
  uint32_t testflag, key_cache_block_size;
 
403
  uint out_flag,warning_printed,error_printed,verbose;
 
404
  uint opt_sort_key,total_files,max_level;
 
405
  uint testflag, key_cache_block_size;
407
406
  uint8_t language;
408
407
  bool using_global_keycache, opt_lock_memory, opt_follow_links;
409
408
  bool retry_repair, force_sort;
432
431
{
433
432
  my_off_t filelength,dupp,buff_length;
434
433
  ha_rows max_records;
435
 
  uint32_t current_key, total_keys;
 
434
  uint current_key, total_keys;
436
435
  myf myf_rw;
437
436
  enum data_file_type new_data_file_type;
438
437
  MI_INFO *info;
439
438
  MI_CHECK *param;
440
 
  unsigned char *buff;
 
439
  uchar *buff;
441
440
  SORT_KEY_BLOCKS *key_block,*key_block_end;
442
441
  /* sync things */
443
 
  uint32_t got_error, threads_running;
 
442
  uint got_error, threads_running;
444
443
  pthread_mutex_t mutex;
445
444
  pthread_cond_t  cond;
446
445
} SORT_INFO;
448
447
/* functions in mi_check */
449
448
void myisamchk_init(MI_CHECK *param);
450
449
int chk_status(MI_CHECK *param, MI_INFO *info);
451
 
int chk_del(MI_CHECK *param, register MI_INFO *info, uint32_t test_flag);
 
450
int chk_del(MI_CHECK *param, register MI_INFO *info, uint test_flag);
452
451
int chk_size(MI_CHECK *param, MI_INFO *info);
453
452
int chk_key(MI_CHECK *param, MI_INFO *info);
454
453
int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend);
460
459
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
461
460
                      const char * name, int rep_quick);
462
461
int change_to_newfile(const char * filename, const char * old_ext,
463
 
                      const char * new_ext, uint32_t raid_chunks,
 
462
                      const char * new_ext, uint raid_chunks,
464
463
                      myf myflags);
465
464
void lock_memory(MI_CHECK *param);
466
465
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
467
466
                               bool repair);
468
 
int update_state_info(MI_CHECK *param, MI_INFO *info,uint32_t update);
 
467
int update_state_info(MI_CHECK *param, MI_INFO *info,uint update);
469
468
void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part,
470
469
                      uint64_t *unique, uint64_t *notnull, 
471
470
                      uint64_t records);
472
471
int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
473
472
             my_off_t length, const char *type);
474
 
int movepoint(MI_INFO *info,unsigned char *record,my_off_t oldpos,
475
 
              my_off_t newpos, uint32_t prot_key);
 
473
int movepoint(MI_INFO *info,uchar *record,my_off_t oldpos,
 
474
              my_off_t newpos, uint prot_key);
476
475
int write_data_suffix(SORT_INFO *sort_info, bool fix_datafile);
477
476
int test_if_almost_full(MI_INFO *info);
478
477
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
480
479
                            bool force);
481
480
 
482
481
int mi_init_bulk_insert(MI_INFO *info, uint32_t cache_size, ha_rows rows);
483
 
void mi_flush_bulk_insert(MI_INFO *info, uint32_t inx);
 
482
void mi_flush_bulk_insert(MI_INFO *info, uint inx);
484
483
void mi_end_bulk_insert(MI_INFO *info);
485
484
int mi_assign_to_key_cache(MI_INFO *info, uint64_t key_map, 
486
485
                           KEY_CACHE *key_cache);