~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/myisam_priv.h

MergedĀ latestĀ out-of-tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
{
44
44
  ha_rows records;                      /* Rows in table */
45
45
  ha_rows del;                          /* Removed rows */
46
 
  uint64_t empty;                       /* lost space in datafile */
47
 
  uint64_t key_empty;                   /* lost space in indexfile */
48
 
  uint64_t key_file_length;
49
 
  uint64_t data_file_length;
 
46
  my_off_t empty;                       /* lost space in datafile */
 
47
  my_off_t key_empty;                   /* lost space in indexfile */
 
48
  my_off_t key_file_length;
 
49
  my_off_t data_file_length;
50
50
  ha_checksum checksum;
51
51
} MI_STATUS_INFO;
52
52
 
71
71
 
72
72
  MI_STATUS_INFO state;
73
73
  ha_rows split;                        /* number of split blocks */
74
 
  uint64_t dellink;                     /* Link to next removed block */
 
74
  my_off_t dellink;                     /* Link to next removed block */
75
75
  uint64_t auto_increment;
76
76
  ulong process;                        /* process that updated table last */
77
77
  ulong unique;                         /* Unique number for this process */
78
78
  ulong update_count;                   /* Updated for each write lock */
79
79
  ulong status;
80
80
  ulong *rec_per_key_part;
81
 
  uint64_t *key_root;                   /* Start of key trees */
82
 
  uint64_t *key_del;                    /* delete links for trees */
83
 
  uint64_t rec_per_key_rows;            /* Rows when calculating rec_per_key */
 
81
  my_off_t *key_root;                   /* Start of key trees */
 
82
  my_off_t *key_del;                    /* delete links for trees */
 
83
  my_off_t rec_per_key_rows;            /* Rows when calculating rec_per_key */
84
84
 
85
85
  ulong sec_index_changed;              /* Updated when new sec_index */
86
86
  ulong sec_index_used;                 /* which extra index are in use */
114
114
 
115
115
typedef struct st_mi_base_info
116
116
{
117
 
  uint64_t keystart;                    /* Start of keys */
118
 
  uint64_t max_data_file_length;
119
 
  uint64_t max_key_file_length;
120
 
  uint64_t margin_key_file_length;
 
117
  my_off_t keystart;                    /* Start of keys */
 
118
  my_off_t max_data_file_length;
 
119
  my_off_t max_key_file_length;
 
120
  my_off_t margin_key_file_length;
121
121
  ha_rows records,reloc;                /* Create information */
122
122
  ulong mean_row_length;                /* Create information */
123
123
  ulong reclength;                      /* length of unpacked record */
184
184
  KEY_CACHE *key_cache;                 /* ref to the current key cache */
185
185
  MI_DECODE_TREE *decode_trees;
186
186
  uint16_t *decode_tables;
187
 
  int (*read_record)(struct st_myisam_info*, uint64_t, unsigned char*);
 
187
  int (*read_record)(struct st_myisam_info*, my_off_t, unsigned char*);
188
188
  int (*write_record)(struct st_myisam_info*, const unsigned char*);
189
 
  int (*update_record)(struct st_myisam_info*, uint64_t, const unsigned char*);
 
189
  int (*update_record)(struct st_myisam_info*, my_off_t, const unsigned char*);
190
190
  int (*delete_record)(struct st_myisam_info*);
191
 
  int (*read_rnd)(struct st_myisam_info*, unsigned char*, uint64_t, bool);
 
191
  int (*read_rnd)(struct st_myisam_info*, unsigned char*, my_off_t, bool);
192
192
  int (*compare_record)(struct st_myisam_info*, const unsigned char *);
193
193
  /* Function to use for a row checksum. */
194
194
  ha_checksum (*calc_checksum)(struct st_myisam_info*, const unsigned char *);
195
195
  int (*compare_unique)(struct st_myisam_info*, MI_UNIQUEDEF *,
196
 
                        const unsigned char *record, uint64_t pos);
197
 
  size_t (*file_read)(MI_INFO *, unsigned char *, size_t, uint64_t, myf);
198
 
  size_t (*file_write)(MI_INFO *, const unsigned char *, size_t, uint64_t, myf);
 
196
                        const unsigned char *record, my_off_t pos);
 
197
  size_t (*file_read)(MI_INFO *, unsigned char *, size_t, my_off_t, myf);
 
198
  size_t (*file_write)(MI_INFO *, const unsigned char *, size_t, my_off_t, myf);
199
199
  ulong this_process;                   /* processid */
200
200
  ulong last_process;                   /* For table-change-check */
201
201
  ulong last_version;                   /* Version on start */
224
224
  THR_LOCK lock;
225
225
  pthread_mutex_t intern_lock;          /* Locking for use with _locking */
226
226
  pthread_rwlock_t *key_root_lock;
227
 
  uint64_t mmaped_length;
 
227
  my_off_t mmaped_length;
228
228
  uint32_t     nonmmaped_inserts;           /* counter of writing in non-mmaped
229
229
                                           area */
230
230
  pthread_rwlock_t mmap_lock;
260
260
        *int_maxpos;                    /*  -""-  */
261
261
  uint32_t  int_nod_flag;                       /*  -""-  */
262
262
  uint32_t int_keytree_version;         /*  -""-  */
263
 
  int (*read_record)(struct st_myisam_info*, uint64_t, unsigned char*);
 
263
  int (*read_record)(struct st_myisam_info*, my_off_t, unsigned char*);
264
264
  ulong this_unique;                    /* uniq filenumber or thread */
265
265
  ulong last_unique;                    /* last unique number */
266
266
  ulong this_loop;                      /* counter for this open */
267
267
  ulong last_loop;                      /* last used counter */
268
 
  uint64_t lastpos,                     /* Last record position */
 
268
  my_off_t lastpos,                     /* Last record position */
269
269
        nextpos;                        /* Position to next record */
270
 
  uint64_t save_lastpos;
271
 
  uint64_t pos;                         /* Intern variable */
272
 
  uint64_t last_keypage;                /* Last key page read */
273
 
  uint64_t last_search_keypage;         /* Last keypage when searching */
274
 
  uint64_t dupp_key_pos;
 
270
  my_off_t save_lastpos;
 
271
  my_off_t pos;                         /* Intern variable */
 
272
  my_off_t last_keypage;                /* Last key page read */
 
273
  my_off_t last_search_keypage;         /* Last keypage when searching */
 
274
  my_off_t dupp_key_pos;
275
275
  ha_checksum checksum;                 /* Temp storage for row checksum */
276
276
  /* QQ: the folloing two xxx_length fields should be removed,
277
277
     as they are not compatible with parallel repair */
310
310
};
311
311
 
312
312
typedef struct st_buffpek {
313
 
  uint64_t file_pos;                    /* Where we are in the sort file */
 
313
  my_off_t file_pos;                    /* Where we are in the sort file */
314
314
  unsigned char *base,*key;                     /* Key pointers */
315
315
  ha_rows count;                        /* Number of rows in table */
316
316
  ulong mem_count;                      /* numbers of keys in memory */
331
331
  uint64_t unique[MI_MAX_KEY_SEG+1];
332
332
  uint64_t notnull[MI_MAX_KEY_SEG+1];
333
333
 
334
 
  uint64_t pos,max_pos,filepos,start_recpos;
 
334
  my_off_t pos,max_pos,filepos,start_recpos;
335
335
  uint32_t key, key_length,real_key_length,sortbuff_size;
336
336
  uint32_t maxbuffers, keys, find_length, sort_keys_length;
337
337
  bool fix_datafile, master;
488
488
 
489
489
        /* Prototypes for intern functions */
490
490
 
491
 
extern int _mi_read_dynamic_record(MI_INFO *info,uint64_t filepos,unsigned char *buf);
 
491
extern int _mi_read_dynamic_record(MI_INFO *info,my_off_t filepos,unsigned char *buf);
492
492
extern int _mi_write_dynamic_record(MI_INFO*, const unsigned char*);
493
 
extern int _mi_update_dynamic_record(MI_INFO*, uint64_t, const unsigned char*);
 
493
extern int _mi_update_dynamic_record(MI_INFO*, my_off_t, const unsigned char*);
494
494
extern int _mi_delete_dynamic_record(MI_INFO *info);
495
495
extern int _mi_cmp_dynamic_record(MI_INFO *info,const unsigned char *record);
496
 
extern int _mi_read_rnd_dynamic_record(MI_INFO *, unsigned char *,uint64_t, bool);
 
496
extern int _mi_read_rnd_dynamic_record(MI_INFO *, unsigned char *,my_off_t, bool);
497
497
extern int _mi_write_blob_record(MI_INFO*, const unsigned char*);
498
 
extern int _mi_update_blob_record(MI_INFO*, uint64_t, const unsigned char*);
499
 
extern int _mi_read_static_record(MI_INFO *info, uint64_t filepos,unsigned char *buf);
 
498
extern int _mi_update_blob_record(MI_INFO*, my_off_t, const unsigned char*);
 
499
extern int _mi_read_static_record(MI_INFO *info, my_off_t filepos,unsigned char *buf);
500
500
extern int _mi_write_static_record(MI_INFO*, const unsigned char*);
501
 
extern int _mi_update_static_record(MI_INFO*, uint64_t, const unsigned char*);
 
501
extern int _mi_update_static_record(MI_INFO*, my_off_t, const unsigned char*);
502
502
extern int _mi_delete_static_record(MI_INFO *info);
503
503
extern int _mi_cmp_static_record(MI_INFO *info,const unsigned char *record);
504
 
extern int _mi_read_rnd_static_record(MI_INFO*, unsigned char *,uint64_t, bool);
 
504
extern int _mi_read_rnd_static_record(MI_INFO*, unsigned char *,my_off_t, bool);
505
505
extern int _mi_ck_write(MI_INFO *info,uint32_t keynr,unsigned char *key,uint32_t length);
506
506
extern int _mi_ck_real_write_btree(MI_INFO *info, MI_KEYDEF *keyinfo,
507
507
                                   unsigned char *key, uint32_t key_length,
508
 
                                   uint64_t *root, uint32_t comp_flag);
509
 
extern int _mi_enlarge_root(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key, uint64_t *root);
 
508
                                   my_off_t *root, uint32_t comp_flag);
 
509
extern int _mi_enlarge_root(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key, my_off_t *root);
510
510
extern int _mi_insert(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,
511
511
                      unsigned char *anc_buff,unsigned char *key_pos,unsigned char *key_buff,
512
512
                      unsigned char *father_buff, unsigned char *father_keypos,
513
 
                      uint64_t father_page, bool insert_last);
 
513
                      my_off_t father_page, bool insert_last);
514
514
extern int _mi_split_page(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,
515
515
                          unsigned char *buff,unsigned char *key_buff, bool insert_last);
516
516
extern unsigned char *_mi_find_half_pos(uint32_t nod_flag,MI_KEYDEF *keyinfo,unsigned char *page,
551
551
extern int _mi_decrement_open_count(MI_INFO *info);
552
552
extern int _mi_check_index(MI_INFO *info,int inx);
553
553
extern int _mi_search(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,uint32_t key_len,
554
 
                      uint32_t nextflag,uint64_t pos);
 
554
                      uint32_t nextflag,my_off_t pos);
555
555
extern int _mi_bin_search(struct st_myisam_info *info,MI_KEYDEF *keyinfo,
556
556
                          unsigned char *page,unsigned char *key,uint32_t key_len,uint32_t comp_flag,
557
557
                          unsigned char * *ret_pos,unsigned char *buff, bool *was_last_key);
561
561
extern int _mi_prefix_search(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *page,
562
562
                          unsigned char *key,uint32_t key_len,uint32_t comp_flag,
563
563
                          unsigned char **ret_pos,unsigned char *buff, bool *was_last_key);
564
 
extern uint64_t _mi_kpos(uint32_t nod_flag,unsigned char *after_key);
565
 
extern void _mi_kpointer(MI_INFO *info,unsigned char *buff,uint64_t pos);
566
 
extern uint64_t _mi_dpos(MI_INFO *info, uint32_t nod_flag,unsigned char *after_key);
567
 
extern uint64_t _mi_rec_pos(MYISAM_SHARE *info, unsigned char *ptr);
568
 
void _mi_dpointer(MI_INFO *info, unsigned char *buff,uint64_t pos);
 
564
extern my_off_t _mi_kpos(uint32_t nod_flag,unsigned char *after_key);
 
565
extern void _mi_kpointer(MI_INFO *info,unsigned char *buff,my_off_t pos);
 
566
extern my_off_t _mi_dpos(MI_INFO *info, uint32_t nod_flag,unsigned char *after_key);
 
567
extern my_off_t _mi_rec_pos(MYISAM_SHARE *info, unsigned char *ptr);
 
568
void _mi_dpointer(MI_INFO *info, unsigned char *buff,my_off_t pos);
569
569
extern uint32_t _mi_get_static_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char * *page,
570
570
                               unsigned char *key);
571
571
extern uint32_t _mi_get_pack_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char * *page,
582
582
                               HA_KEYSEG *end);
583
583
extern unsigned char *_mi_move_key(MI_KEYDEF *keyinfo,unsigned char *to,unsigned char *from);
584
584
extern int _mi_search_next(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,
585
 
                           uint32_t key_length,uint32_t nextflag,uint64_t pos);
586
 
extern int _mi_search_first(MI_INFO *info,MI_KEYDEF *keyinfo,uint64_t pos);
587
 
extern int _mi_search_last(MI_INFO *info,MI_KEYDEF *keyinfo,uint64_t pos);
588
 
extern unsigned char *_mi_fetch_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,uint64_t page,
 
585
                           uint32_t key_length,uint32_t nextflag,my_off_t pos);
 
586
extern int _mi_search_first(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos);
 
587
extern int _mi_search_last(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos);
 
588
extern unsigned char *_mi_fetch_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page,
589
589
                                int level,unsigned char *buff,int return_buffer);
590
 
extern int _mi_write_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,uint64_t page,
 
590
extern int _mi_write_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page,
591
591
                             int level, unsigned char *buff);
592
 
extern int _mi_dispose(MI_INFO *info,MI_KEYDEF *keyinfo,uint64_t pos,
 
592
extern int _mi_dispose(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos,
593
593
                      int level);
594
 
extern uint64_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo,int level);
 
594
extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo,int level);
595
595
extern uint32_t _mi_make_key(MI_INFO *info,uint32_t keynr,unsigned char *key,
596
 
                         const unsigned char *record,uint64_t filepos);
 
596
                         const unsigned char *record,my_off_t filepos);
597
597
extern uint32_t _mi_pack_key(register MI_INFO *info, uint32_t keynr, unsigned char *key,
598
598
                         unsigned char *old, key_part_map keypart_map,
599
599
                         HA_KEYSEG **last_used_keyseg);
600
 
extern int _mi_read_key_record(MI_INFO *info,uint64_t filepos,unsigned char *buf);
601
 
extern int _mi_read_cache(IO_CACHE *info,unsigned char *buff,uint64_t pos,
 
600
extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,unsigned char *buf);
 
601
extern int _mi_read_cache(IO_CACHE *info,unsigned char *buff,my_off_t pos,
602
602
                          uint32_t length,int re_read_if_possibly);
603
603
extern uint64_t retrieve_auto_increment(MI_INFO *info,const unsigned char *record);
604
604
 
613
613
                            ulong reclength);
614
614
extern bool _mi_rec_check(MI_INFO *info,const unsigned char *record, unsigned char *packpos,
615
615
                             ulong packed_length, bool with_checkum);
616
 
extern int _mi_write_part_record(MI_INFO *info,uint64_t filepos,ulong length,
617
 
                                 uint64_t next_filepos,unsigned char **record,
 
616
extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length,
 
617
                                 my_off_t next_filepos,unsigned char **record,
618
618
                                 ulong *reclength,int *flag);
619
619
extern void _mi_print_key(FILE *stream,HA_KEYSEG *keyseg,const unsigned char *key,
620
620
                          uint32_t length);
621
621
extern bool _mi_read_pack_info(MI_INFO *info,bool fix_keys);
622
 
extern int _mi_read_pack_record(MI_INFO *info,uint64_t filepos,unsigned char *buf);
623
 
extern int _mi_read_rnd_pack_record(MI_INFO*, unsigned char *,uint64_t, bool);
 
622
extern int _mi_read_pack_record(MI_INFO *info,my_off_t filepos,unsigned char *buf);
 
623
extern int _mi_read_rnd_pack_record(MI_INFO*, unsigned char *,my_off_t, bool);
624
624
extern int _mi_pack_rec_unpack(MI_INFO *info, MI_BIT_BUFF *bit_buff,
625
625
                               unsigned char *to, unsigned char *from, ulong reclength);
626
626
 
633
633
  ulong data_len;
634
634
  ulong block_len;
635
635
  ulong blob_len;
636
 
  uint64_t filepos;
637
 
  uint64_t next_filepos;
638
 
  uint64_t prev_filepos;
 
636
  my_off_t filepos;
 
637
  my_off_t next_filepos;
 
638
  my_off_t prev_filepos;
639
639
  uint32_t second_read;
640
640
  uint32_t offset;
641
641
} MI_BLOCK_INFO;
670
670
#define fast_mi_writeinfo(INFO) if (!(INFO)->s->tot_locks) (void) _mi_writeinfo((INFO),0)
671
671
#define fast_mi_readinfo(INFO) ((INFO)->lock_type == F_UNLCK) && _mi_readinfo((INFO),F_RDLCK,1)
672
672
 
673
 
extern uint32_t _mi_get_block_info(MI_BLOCK_INFO *,int, uint64_t);
 
673
extern uint32_t _mi_get_block_info(MI_BLOCK_INFO *,int, my_off_t);
674
674
extern uint32_t _mi_rec_pack(MI_INFO *info,unsigned char *to,const unsigned char *from);
675
675
extern uint32_t _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
676
676
                                    MI_BLOCK_INFO *info, unsigned char **rec_buff_p,
677
 
                                    int file, uint64_t filepos);
 
677
                                    int file, my_off_t filepos);
678
678
extern void _my_store_blob_length(unsigned char *pos,uint32_t pack_length,uint32_t length);
679
679
extern void mi_report_error(int errcode, const char *file_name);
680
680
extern size_t mi_mmap_pread(MI_INFO *info, unsigned char *Buffer,
681
 
                            size_t Count, uint64_t offset, myf MyFlags);
 
681
                            size_t Count, my_off_t offset, myf MyFlags);
682
682
extern size_t mi_mmap_pwrite(MI_INFO *info, const unsigned char *Buffer,
683
 
                             size_t Count, uint64_t offset, myf MyFlags);
 
683
                             size_t Count, my_off_t offset, myf MyFlags);
684
684
extern size_t mi_nommap_pread(MI_INFO *info, unsigned char *Buffer,
685
 
                              size_t Count, uint64_t offset, myf MyFlags);
 
685
                              size_t Count, my_off_t offset, myf MyFlags);
686
686
extern size_t mi_nommap_pwrite(MI_INFO *info, const unsigned char *Buffer,
687
 
                               size_t Count, uint64_t offset, myf MyFlags);
 
687
                               size_t Count, my_off_t offset, myf MyFlags);
688
688
 
689
689
uint32_t mi_state_info_write(int file, MI_STATE_INFO *state, uint32_t pWrite);
690
690
uint32_t mi_state_info_read_dsk(int file, MI_STATE_INFO *state, bool pRead);
700
700
ha_checksum mi_checksum(MI_INFO *info, const unsigned char *buf);
701
701
ha_checksum mi_static_checksum(MI_INFO *info, const unsigned char *buf);
702
702
bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, unsigned char *record,
703
 
                     ha_checksum unique_hash, uint64_t pos);
 
703
                     ha_checksum unique_hash, my_off_t pos);
704
704
ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const unsigned char *buf);
705
705
int _mi_cmp_static_unique(MI_INFO *info, MI_UNIQUEDEF *def,
706
 
                           const unsigned char *record, uint64_t pos);
 
706
                           const unsigned char *record, my_off_t pos);
707
707
int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def,
708
 
                           const unsigned char *record, uint64_t pos);
 
708
                           const unsigned char *record, my_off_t pos);
709
709
int mi_unique_comp(MI_UNIQUEDEF *def, const unsigned char *a, const unsigned char *b,
710
710
                   bool null_are_equal);
711
711
void mi_get_status(void* param, int concurrent_insert);
719
719
int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, int file_to_dup);
720
720
int mi_open_keyfile(MYISAM_SHARE *share);
721
721
void mi_setup_functions(register MYISAM_SHARE *share);
722
 
bool mi_dynmap_file(MI_INFO *info, uint64_t size);
723
 
void mi_remap_file(MI_INFO *info, uint64_t size);
 
722
bool mi_dynmap_file(MI_INFO *info, my_off_t size);
 
723
void mi_remap_file(MI_INFO *info, my_off_t size);
724
724
 
725
725
int mi_check_index_cond(register MI_INFO *info, uint32_t keynr, unsigned char *record);
726
726
 
741
741
                                   void *func_arg);
742
742
/* Just for myisam legacy */
743
743
extern size_t my_pwrite(int Filedes,const unsigned char *Buffer,size_t Count,
744
 
                      uint64_t offset,myf MyFlags);
745
 
extern size_t my_pread(int Filedes,unsigned char *Buffer,size_t Count,uint64_t offset,
 
744
                      my_off_t offset,myf MyFlags);
 
745
extern size_t my_pread(int Filedes,unsigned char *Buffer,size_t Count,my_off_t offset,
746
746
                     myf MyFlags);
747
747
 
748
748
/* Needed for handler */