~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/myisamdef.h

Finished first pass at Protocol cleanup, still some things to remove but they are a bit more involved.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#ifndef MYISAMDEF_H
19
19
#define MYISAMDEF_H
20
20
 
 
21
#include <drizzled/global.h>
21
22
#include "myisam.h"                     /* Structs & some defines */
22
23
#include "myisampack.h"                 /* packing of keys */
23
24
#include <mysys/my_tree.h>
24
25
#include <mysys/my_pthread.h>
25
26
#include <mysys/thr_lock.h>
26
 
#include <libdrizzle/drizzle_com.h>
27
 
 
28
 
#if defined(my_write) && !defined(MAP_TO_USE_RAID)
 
27
#include <drizzled/common.h>
 
28
 
 
29
#include <string.h>
 
30
#include <list>
 
31
 
 
32
#if defined(my_write)
29
33
#undef my_write                         /* undef map from my_nosys; We need test-if-disk full */
30
34
#endif
31
35
 
 
36
#ifdef  __cplusplus
 
37
extern "C" {
 
38
#endif
 
39
 
32
40
typedef struct st_mi_status_info
33
41
{
34
42
  ha_rows records;                      /* Rows in table */
130
138
  uint32_t extra_alloc_procent;
131
139
  /* Info about raid */
132
140
  uint32_t raid_type,raid_chunks;
133
 
  ulong raid_chunksize;
 
141
  uint32_t raid_chunksize;
134
142
  /* The following are from the header */
135
143
  uint32_t key_parts,all_key_parts;
136
144
} MI_BASE_INFO;
152
160
  unsigned char version;
153
161
} MI_PACK;
154
162
 
155
 
#define MAX_NONMAPPED_INSERTS 1000      
 
163
#define MAX_NONMAPPED_INSERTS 1000
 
164
 
 
165
class Session;
156
166
 
157
167
typedef struct st_mi_isam_share {       /* Shared between opens */
158
168
  MI_STATE_INFO state;
164
174
  MI_COLUMNDEF *rec;                    /* Pointer to field information */
165
175
  MI_PACK    pack;                      /* Data about packed records */
166
176
  MI_BLOB    *blobs;                    /* Pointer to blobs */
167
 
  LIST *in_use;                         /* List of threads using this table */
 
177
  std::list<Session *> *in_use;         /* List of threads using this table */
168
178
  char  *unique_file_name;              /* realpath() of index file */
169
179
  char  *data_file_name,                /* Resolved path names from symlinks */
170
180
        *index_file_name;
184
194
                        const unsigned char *record, my_off_t pos);
185
195
  size_t (*file_read)(MI_INFO *, unsigned char *, size_t, my_off_t, myf);
186
196
  size_t (*file_write)(MI_INFO *, const unsigned char *, size_t, my_off_t, myf);
187
 
  invalidator_by_filename invalidator;  /* query cache invalidator */
188
197
  ulong this_process;                   /* processid */
189
198
  ulong last_process;                   /* For table-change-check */
190
199
  ulong last_version;                   /* Version on start */
212
221
    concurrent_insert;
213
222
  THR_LOCK lock;
214
223
  pthread_mutex_t intern_lock;          /* Locking for use with _locking */
215
 
  rw_lock_t *key_root_lock;
 
224
  pthread_rwlock_t *key_root_lock;
216
225
  my_off_t mmaped_length;
217
226
  uint32_t     nonmmaped_inserts;           /* counter of writing in non-mmaped
218
227
                                           area */
219
 
  rw_lock_t mmap_lock;
 
228
  pthread_rwlock_t mmap_lock;
220
229
} MYISAM_SHARE;
221
230
 
222
231
 
239
248
  MI_BIT_BUFF  bit_buff;
240
249
  /* accumulate indexfile changes between write's */
241
250
  TREE          *bulk_insert;
242
 
  LIST in_use;                          /* Thread using this table          */
 
251
  Session *in_use;                      /* Thread using this table          */
243
252
  char *filename;                       /* parameter to open filename       */
244
253
  unsigned char *buff,                          /* Temp area for key                */
245
254
        *lastkey,*lastkey2;             /* Last used search key             */
250
259
  uint32_t  int_nod_flag;                       /*  -""-  */
251
260
  uint32_t int_keytree_version;         /*  -""-  */
252
261
  int (*read_record)(struct st_myisam_info*, my_off_t, unsigned char*);
253
 
  invalidator_by_filename invalidator;  /* query cache invalidator */
254
262
  ulong this_unique;                    /* uniq filenumber or thread */
255
263
  ulong last_unique;                    /* last unique number */
256
264
  ulong this_loop;                      /* counter for this open */
282
290
  uint  data_changed;                   /* Somebody has changed data */
283
291
  uint  save_update;                    /* When using KEY_READ */
284
292
  int   save_lastinx;
285
 
  LIST  open_list;
286
293
  IO_CACHE rec_cache;                   /* When cacheing records */
287
294
  uint32_t  preload_buff_size;              /* When preloading indexes */
288
295
  myf lock_wait;                        /* is 0 or MY_DONT_WAIT */
335
342
  void *wordlist, *wordptr;
336
343
  MEM_ROOT wordroot;
337
344
  unsigned char *record;
338
 
  MY_TMPDIR *tmpdir;
339
345
  int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
340
346
  int (*key_read)(struct st_mi_sort_param *,void *);
341
347
  int (*key_write)(struct st_mi_sort_param *, const void *);
459
465
 
460
466
        /* Some extern variables */
461
467
 
462
 
extern LIST *myisam_open_list;
 
468
extern std::list<MI_INFO *> myisam_open_list;
463
469
extern unsigned char  myisam_file_magic[], myisam_pack_file_magic[];
464
470
extern uint32_t  myisam_read_vec[], myisam_readnext_vec[];
465
471
extern uint32_t myisam_quick_table_bits;
536
542
                            MI_KEY_PARAM *s_temp);
537
543
 
538
544
extern int _mi_ck_delete(MI_INFO *info,uint32_t keynr,unsigned char *key,uint32_t key_length);
539
 
extern int _mi_readinfo(MI_INFO *info,int lock_flag,int check_keybuffer);
 
545
int _mi_readinfo(MI_INFO *info,int lock_flag,int check_keybuffer);
540
546
extern int _mi_writeinfo(MI_INFO *info,uint32_t options);
541
547
extern int _mi_test_if_changed(MI_INFO *info);
542
548
extern int _mi_mark_file_changed(MI_INFO *info);
557
563
extern void _mi_kpointer(MI_INFO *info,unsigned char *buff,my_off_t pos);
558
564
extern my_off_t _mi_dpos(MI_INFO *info, uint32_t nod_flag,unsigned char *after_key);
559
565
extern my_off_t _mi_rec_pos(MYISAM_SHARE *info, unsigned char *ptr);
560
 
extern void _mi_dpointer(MI_INFO *info, unsigned char *buff,my_off_t pos);
 
566
void _mi_dpointer(MI_INFO *info, unsigned char *buff,my_off_t pos);
561
567
extern uint32_t _mi_get_static_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char * *page,
562
568
                               unsigned char *key);
563
569
extern uint32_t _mi_get_pack_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char * *page,
594
600
                          uint32_t length,int re_read_if_possibly);
595
601
extern uint64_t retrieve_auto_increment(MI_INFO *info,const unsigned char *record);
596
602
 
597
 
extern unsigned char *mi_alloc_rec_buff(MI_INFO *,ulong, unsigned char**);
 
603
unsigned char *mi_alloc_rec_buff(MI_INFO *info, size_t length, unsigned char **buf);
598
604
#define mi_get_rec_buff_ptr(info,buf)                              \
599
605
        ((((info)->s->options & HA_OPTION_PACK_RECORD) && (buf)) ? \
600
606
        (buf) - MI_REC_BUFF_OFFSET : (buf))
663
669
#define fast_mi_writeinfo(INFO) if (!(INFO)->s->tot_locks) (void) _mi_writeinfo((INFO),0)
664
670
#define fast_mi_readinfo(INFO) ((INFO)->lock_type == F_UNLCK) && _mi_readinfo((INFO),F_RDLCK,1)
665
671
 
666
 
#ifdef  __cplusplus
667
 
extern "C" {
668
 
#endif
669
 
 
670
672
extern uint32_t _mi_get_block_info(MI_BLOCK_INFO *,File, my_off_t);
671
673
extern uint32_t _mi_rec_pack(MI_INFO *info,unsigned char *to,const unsigned char *from);
672
674
extern uint32_t _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
738
740
int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file);
739
741
 
740
742
int sort_write_record(MI_SORT_PARAM *sort_param);
741
 
int _create_index_by_sort(MI_SORT_PARAM *info,bool no_messages, uint32_t);
 
743
int _create_index_by_sort(MI_SORT_PARAM *info,bool no_messages, size_t);
742
744
 
743
745
extern void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t func,
744
746
                                   void *func_arg);
750
752
 
751
753
/* Needed for handler */
752
754
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows);
753
 
void _mi_report_crashed(MI_INFO *file __attribute__((unused)),
754
 
                        const char *message __attribute__((unused)),
755
 
                        const char *sfile __attribute__((unused)),
756
 
                        uint32_t sline __attribute__((unused)));
 
755
void _mi_report_crashed(MI_INFO *file, const char *message, const char *sfile,
 
756
                        uint32_t sline);
757
757
 
758
758
#ifdef __cplusplus
759
759
}