~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000-2006 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
/* This file is included by all internal myisam files */
17
243.1.11 by Jay Pipes
* Added include guards in a couple places, and removed unecessary
18
#ifndef MYISAMDEF_H
77.1.3 by Monty Taylor
MyISAM cleanups.
19
#define MYISAMDEF_H
20
612.2.13 by Monty Taylor
Work on removing global.h from headers that should be installed.
21
#include <drizzled/global.h>
1 by brian
clean slate
22
#include "myisam.h"			/* Structs & some defines */
23
#include "myisampack.h"			/* packing of keys */
212.5.15 by Monty Taylor
Moved my_tree.
24
#include <mysys/my_tree.h>
212.5.13 by Monty Taylor
Moved my_sys/my_pthread/my_nosys and mysys_err to mysys.
25
#include <mysys/my_pthread.h>
212.5.7 by Monty Taylor
Move thr_*h to mysys.
26
#include <mysys/thr_lock.h>
543 by Monty Taylor
Renamed drizzle_common again. Removed sql_common. (empty)
27
#include <drizzled/common.h>
1 by brian
clean slate
28
612.2.13 by Monty Taylor
Work on removing global.h from headers that should be installed.
29
#include <string.h>
30
489.1.6 by Monty Taylor
Removed RAID garbage.
31
#if defined(my_write)
1 by brian
clean slate
32
#undef my_write				/* undef map from my_nosys; We need test-if-disk full */
33
#endif
34
598.1.1 by Super-User
Fixed solaris build crap.
35
#ifdef	__cplusplus
36
extern "C" {
37
#endif
38
1 by brian
clean slate
39
typedef struct st_mi_status_info
40
{
41
  ha_rows records;			/* Rows in table */
42
  ha_rows del;				/* Removed rows */
43
  my_off_t empty;			/* lost space in datafile */
44
  my_off_t key_empty;			/* lost space in indexfile */
45
  my_off_t key_file_length;
46
  my_off_t data_file_length;
47
  ha_checksum checksum;
48
} MI_STATUS_INFO;
49
50
typedef struct st_mi_state_info
51
{
52
  struct {				/* Fileheader */
481 by Brian Aker
Remove all of uchar.
53
    unsigned char file_version[4];
54
    unsigned char options[2];
55
    unsigned char header_length[2];
56
    unsigned char state_info_length[2];
57
    unsigned char base_info_length[2];
58
    unsigned char base_pos[2];
59
    unsigned char key_parts[2];			/* Key parts */
60
    unsigned char unique_key_parts[2];		/* Key parts + unique parts */
61
    unsigned char keys;				/* number of keys in file */
62
    unsigned char uniques;			/* number of UNIQUE definitions */
63
    unsigned char language;			/* Language for indexes */
64
    unsigned char max_block_size_index;		/* max keyblock size */
65
    unsigned char fulltext_keys;
66
    unsigned char not_used;                     /* To align to 8 */
1 by brian
clean slate
67
  } header;
68
69
  MI_STATUS_INFO state;
70
  ha_rows split;			/* number of split blocks */
71
  my_off_t dellink;			/* Link to next removed block */
151 by Brian Aker
Ulonglong to uint64_t
72
  uint64_t auto_increment;
1 by brian
clean slate
73
  ulong process;			/* process that updated table last */
74
  ulong unique;				/* Unique number for this process */
75
  ulong update_count;			/* Updated for each write lock */
76
  ulong status;
77
  ulong *rec_per_key_part;
78
  my_off_t *key_root;			/* Start of key trees */
79
  my_off_t *key_del;			/* delete links for trees */
80
  my_off_t rec_per_key_rows;		/* Rows when calculating rec_per_key */
81
82
  ulong sec_index_changed;		/* Updated when new sec_index */
83
  ulong sec_index_used;			/* which extra index are in use */
151 by Brian Aker
Ulonglong to uint64_t
84
  uint64_t key_map;			/* Which keys are in use */
1 by brian
clean slate
85
  ha_checksum checksum;                 /* Table checksum */
86
  ulong version;			/* timestamp of create */
87
  time_t create_time;			/* Time when created database */
88
  time_t recover_time;			/* Time for last recover */
89
  time_t check_time;			/* Time for last check */
90
  uint	sortkey;			/* sorted by this key  (not used) */
482 by Brian Aker
Remove uint.
91
  uint32_t open_count;
206 by Brian Aker
Removed final uint dead types.
92
  uint8_t changed;			/* Changed since myisamchk */
1 by brian
clean slate
93
94
  /* the following isn't saved on disk */
482 by Brian Aker
Remove uint.
95
  uint32_t state_diff_length;		/* Should be 0 */
1 by brian
clean slate
96
  uint	state_length;			/* Length of state header in file */
97
  ulong *key_info;
98
} MI_STATE_INFO;
99
100
#define MI_STATE_INFO_SIZE	(24+14*8+7*4+2*2+8)
101
#define MI_STATE_KEY_SIZE	8
102
#define MI_STATE_KEYBLOCK_SIZE  8
103
#define MI_STATE_KEYSEG_SIZE	4
104
#define MI_STATE_EXTRA_SIZE ((MI_MAX_KEY+MI_MAX_KEY_BLOCK_SIZE)*MI_STATE_KEY_SIZE + MI_MAX_KEY*MI_MAX_KEY_SEG*MI_STATE_KEYSEG_SIZE)
105
#define MI_KEYDEF_SIZE		(2+ 5*2)
106
#define MI_UNIQUEDEF_SIZE	(2+1+1)
107
#define HA_KEYSEG_SIZE		(6+ 2*2 + 4*2)
108
#define MI_COLUMNDEF_SIZE	(2*3+1)
109
#define MI_BASE_INFO_SIZE	(5*8 + 8*4 + 4 + 4*2 + 16)
110
#define MI_INDEX_BLOCK_MARGIN	16	/* Safety margin for .MYI tables */
111
112
typedef struct st_mi_base_info
113
{
114
  my_off_t keystart;			/* Start of keys */
115
  my_off_t max_data_file_length;
116
  my_off_t max_key_file_length;
117
  my_off_t margin_key_file_length;
118
  ha_rows records,reloc;		/* Create information */
119
  ulong mean_row_length;		/* Create information */
120
  ulong reclength;			/* length of unpacked record */
121
  ulong pack_reclength;			/* Length of full packed rec. */
122
  ulong min_pack_length;
123
  ulong max_pack_length;		/* Max possibly length of packed rec.*/
124
  ulong min_block_length;
125
  ulong fields,				/* fields in table */
126
       pack_fields;			/* packed fields in table */
482 by Brian Aker
Remove uint.
127
  uint32_t rec_reflength;			/* = 2-8 */
128
  uint32_t key_reflength;			/* = 2-8 */
129
  uint32_t keys;				/* same as in state.header */
130
  uint32_t auto_key;			/* Which key-1 is a auto key */
131
  uint32_t blobs;				/* Number of blobs */
132
  uint32_t pack_bits;			/* Length of packed bits */
133
  uint32_t max_key_block_length;		/* Max block length */
134
  uint32_t max_key_length;			/* Max key length */
1 by brian
clean slate
135
  /* Extra allocation when using dynamic record format */
482 by Brian Aker
Remove uint.
136
  uint32_t extra_alloc_bytes;
137
  uint32_t extra_alloc_procent;
1 by brian
clean slate
138
  /* Info about raid */
482 by Brian Aker
Remove uint.
139
  uint32_t raid_type,raid_chunks;
489.1.6 by Monty Taylor
Removed RAID garbage.
140
  uint32_t raid_chunksize;
1 by brian
clean slate
141
  /* The following are from the header */
482 by Brian Aker
Remove uint.
142
  uint32_t key_parts,all_key_parts;
1 by brian
clean slate
143
} MI_BASE_INFO;
144
145
146
	/* Structs used intern in database */
147
148
typedef struct st_mi_blob		/* Info of record */
149
{
150
  ulong offset;				/* Offset to blob in record */
482 by Brian Aker
Remove uint.
151
  uint32_t pack_length;			/* Type of packed length */
1 by brian
clean slate
152
  ulong length;				/* Calc:ed for each record */
153
} MI_BLOB;
154
155
156
typedef struct st_mi_isam_pack {
157
  ulong header_length;
482 by Brian Aker
Remove uint.
158
  uint32_t ref_length;
481 by Brian Aker
Remove all of uchar.
159
  unsigned char version;
1 by brian
clean slate
160
} MI_PACK;
161
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
162
#define MAX_NONMAPPED_INSERTS 1000
1 by brian
clean slate
163
164
typedef struct st_mi_isam_share {	/* Shared between opens */
165
  MI_STATE_INFO state;
166
  MI_BASE_INFO base;
167
  MI_KEYDEF  ft2_keyinfo;		/* Second-level ft-key definition */
168
  MI_KEYDEF  *keyinfo;			/* Key definitions */
169
  MI_UNIQUEDEF *uniqueinfo;		/* unique definitions */
170
  HA_KEYSEG *keyparts;			/* key part info */
171
  MI_COLUMNDEF *rec;			/* Pointer to field information */
172
  MI_PACK    pack;			/* Data about packed records */
173
  MI_BLOB    *blobs;			/* Pointer to blobs */
174
  LIST *in_use;                         /* List of threads using this table */
175
  char  *unique_file_name;		/* realpath() of index file */
176
  char  *data_file_name,		/* Resolved path names from symlinks */
177
        *index_file_name;
481 by Brian Aker
Remove all of uchar.
178
  unsigned char *file_map;			/* mem-map of file if possible */
1 by brian
clean slate
179
  KEY_CACHE *key_cache;			/* ref to the current key cache */
180
  MI_DECODE_TREE *decode_trees;
206 by Brian Aker
Removed final uint dead types.
181
  uint16_t *decode_tables;
481 by Brian Aker
Remove all of uchar.
182
  int (*read_record)(struct st_myisam_info*, my_off_t, unsigned char*);
183
  int (*write_record)(struct st_myisam_info*, const unsigned char*);
184
  int (*update_record)(struct st_myisam_info*, my_off_t, const unsigned char*);
1 by brian
clean slate
185
  int (*delete_record)(struct st_myisam_info*);
481 by Brian Aker
Remove all of uchar.
186
  int (*read_rnd)(struct st_myisam_info*, unsigned char*, my_off_t, bool);
187
  int (*compare_record)(struct st_myisam_info*, const unsigned char *);
1 by brian
clean slate
188
  /* Function to use for a row checksum. */
481 by Brian Aker
Remove all of uchar.
189
  ha_checksum (*calc_checksum)(struct st_myisam_info*, const unsigned char *);
1 by brian
clean slate
190
  int (*compare_unique)(struct st_myisam_info*, MI_UNIQUEDEF *,
481 by Brian Aker
Remove all of uchar.
191
			const unsigned char *record, my_off_t pos);
192
  size_t (*file_read)(MI_INFO *, unsigned char *, size_t, my_off_t, myf);
193
  size_t (*file_write)(MI_INFO *, const unsigned char *, size_t, my_off_t, myf);
1 by brian
clean slate
194
  invalidator_by_filename invalidator;  /* query cache invalidator */
195
  ulong this_process;			/* processid */
196
  ulong last_process;			/* For table-change-check */
197
  ulong last_version;			/* Version on start */
198
  ulong options;			/* Options used */
199
  ulong min_pack_length;		/* Theese are used by packed data */
200
  ulong max_pack_length;
201
  ulong state_diff_length;
202
  uint	rec_reflength;			/* rec_reflength in use now */
482 by Brian Aker
Remove uint.
203
  uint32_t  unique_name_length;
1 by brian
clean slate
204
  File	kfile;				/* Shared keyfile */
205
  File	data_file;			/* Shared data file */
206
  int	mode;				/* mode of file on open */
207
  uint	reopen;				/* How many times reopened */
208
  uint	w_locks,r_locks,tot_locks;	/* Number of read/write locks */
209
  uint	blocksize;			/* blocksize of keyfile */
210
  myf write_flag;
211
  enum data_file_type data_file_type;
212
  /* Below flag is needed to make log tables work with concurrent insert */
281 by Brian Aker
Converted myisam away from my_bool
213
  bool is_log_table;
1 by brian
clean slate
214
281 by Brian Aker
Converted myisam away from my_bool
215
  bool  changed,			/* If changed since lock */
1 by brian
clean slate
216
    global_changed,			/* If changed since open */
217
    not_flushed,
218
    temporary,delay_key_write,
219
    concurrent_insert;
220
  THR_LOCK lock;
221
  pthread_mutex_t intern_lock;		/* Locking for use with _locking */
658 by Brian Aker
Part removal of my_pthread.h
222
  pthread_rwlock_t *key_root_lock;
1 by brian
clean slate
223
  my_off_t mmaped_length;
482 by Brian Aker
Remove uint.
224
  uint32_t     nonmmaped_inserts;           /* counter of writing in non-mmaped
1 by brian
clean slate
225
                                           area */
658 by Brian Aker
Part removal of my_pthread.h
226
  pthread_rwlock_t mmap_lock;
1 by brian
clean slate
227
} MYISAM_SHARE;
228
229
482 by Brian Aker
Remove uint.
230
typedef uint32_t mi_bit_type;
1 by brian
clean slate
231
232
typedef struct st_mi_bit_buff {		/* Used for packing of record */
233
  mi_bit_type current_byte;
482 by Brian Aker
Remove uint.
234
  uint32_t bits;
481 by Brian Aker
Remove all of uchar.
235
  unsigned char *pos,*end,*blob_pos,*blob_end;
482 by Brian Aker
Remove uint.
236
  uint32_t error;
1 by brian
clean slate
237
} MI_BIT_BUFF;
238
239
281 by Brian Aker
Converted myisam away from my_bool
240
typedef bool (*index_cond_func_t)(void *param);
1 by brian
clean slate
241
242
struct st_myisam_info {
243
  MYISAM_SHARE *s;			/* Shared between open:s */
244
  MI_STATUS_INFO *state,save_state;
245
  MI_BLOB     *blobs;			/* Pointer to blobs */
246
  MI_BIT_BUFF  bit_buff;
247
  /* accumulate indexfile changes between write's */
248
  TREE	        *bulk_insert;
249
  LIST in_use;                          /* Thread using this table          */
250
  char *filename;			/* parameter to open filename       */
481 by Brian Aker
Remove all of uchar.
251
  unsigned char *buff,				/* Temp area for key                */
1 by brian
clean slate
252
	*lastkey,*lastkey2;		/* Last used search key             */
481 by Brian Aker
Remove all of uchar.
253
  unsigned char *first_mbr_key;			/* Searhed spatial key              */
254
  unsigned char	*rec_buff;			/* Tempbuff for recordpack          */
255
  unsigned char *int_keypos,			/* Save position for next/previous  */
1 by brian
clean slate
256
        *int_maxpos;			/*  -""-  */
482 by Brian Aker
Remove uint.
257
  uint32_t  int_nod_flag;			/*  -""-  */
205 by Brian Aker
uint32 -> uin32_t
258
  uint32_t int_keytree_version;		/*  -""-  */
481 by Brian Aker
Remove all of uchar.
259
  int (*read_record)(struct st_myisam_info*, my_off_t, unsigned char*);
1 by brian
clean slate
260
  invalidator_by_filename invalidator;  /* query cache invalidator */
261
  ulong this_unique;			/* uniq filenumber or thread */
262
  ulong last_unique;			/* last unique number */
263
  ulong this_loop;			/* counter for this open */
264
  ulong last_loop;			/* last used counter */
265
  my_off_t lastpos,			/* Last record position */
266
	nextpos;			/* Position to next record */
267
  my_off_t save_lastpos;
268
  my_off_t pos;				/* Intern variable */
269
  my_off_t last_keypage;		/* Last key page read */
270
  my_off_t last_search_keypage;		/* Last keypage when searching */
271
  my_off_t dupp_key_pos;
272
  ha_checksum checksum;                 /* Temp storage for row checksum */
273
  /* QQ: the folloing two xxx_length fields should be removed,
274
     as they are not compatible with parallel repair */
275
  ulong packed_length,blob_length;	/* Length of found, packed record */
276
  int  dfile;				/* The datafile */
482 by Brian Aker
Remove uint.
277
  uint32_t opt_flag;			/* Optim. for space/speed */
278
  uint32_t update;				/* If file changed since open */
1 by brian
clean slate
279
  int	lastinx;			/* Last used index */
280
  uint	lastkey_length;			/* Length of key in lastkey */
281
  uint	last_rkey_length;		/* Last length in mi_rkey() */
282
  enum ha_rkey_function last_key_func;  /* CONTAIN, OVERLAP, etc */
482 by Brian Aker
Remove uint.
283
  uint32_t  save_lastkey_length;
284
  uint32_t  pack_key_length;                /* For MYISAMMRG */
206 by Brian Aker
Removed final uint dead types.
285
  uint16_t last_used_keyseg;              /* For MyISAMMRG */
1 by brian
clean slate
286
  int	errkey;				/* Got last error on this key */
287
  int   lock_type;			/* How database was locked */
288
  int   tmp_lock_type;			/* When locked by readinfo */
289
  uint	data_changed;			/* Somebody has changed data */
290
  uint	save_update;			/* When using KEY_READ */
291
  int	save_lastinx;
292
  LIST	open_list;
293
  IO_CACHE rec_cache;			/* When cacheing records */
482 by Brian Aker
Remove uint.
294
  uint32_t  preload_buff_size;              /* When preloading indexes */
1 by brian
clean slate
295
  myf lock_wait;			/* is 0 or MY_DONT_WAIT */
281 by Brian Aker
Converted myisam away from my_bool
296
  bool was_locked;			/* Was locked in panic */
297
  bool append_insert_at_end;		/* Set if concurrent insert */
298
  bool quick_mode;
299
  bool page_changed;		/* If info->buff can't be used for rnext */
300
  bool buff_used;		/* If info->buff has to be reread for rnext */
301
  bool once_flags;           /* For MYISAMMRG */
1 by brian
clean slate
302
303
  index_cond_func_t index_cond_func;   /* Index condition function */
304
  void *index_cond_func_arg;           /* parameter for the func */
305
  THR_LOCK_DATA lock;
481 by Brian Aker
Remove all of uchar.
306
  unsigned char  *rtree_recursion_state;	/* For RTREE */
1 by brian
clean slate
307
  int     rtree_recursion_depth;
308
};
309
310
typedef struct st_buffpek {
311
  my_off_t file_pos;                    /* Where we are in the sort file */
481 by Brian Aker
Remove all of uchar.
312
  unsigned char *base,*key;                     /* Key pointers */
1 by brian
clean slate
313
  ha_rows count;                        /* Number of rows in table */
314
  ulong mem_count;                      /* numbers of keys in memory */
315
  ulong max_keys;                       /* Max keys in buffert */
316
} BUFFPEK;
317
318
typedef struct st_mi_sort_param
319
{
320
  pthread_t  thr;
321
  IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
322
  DYNAMIC_ARRAY buffpek;
323
  MI_BIT_BUFF   bit_buff;               /* For parallel repair of packrec. */
324
325
  /*
326
    The next two are used to collect statistics, see update_key_parts for
327
    description.
328
  */
151 by Brian Aker
Ulonglong to uint64_t
329
  uint64_t unique[MI_MAX_KEY_SEG+1];
330
  uint64_t notnull[MI_MAX_KEY_SEG+1];
1 by brian
clean slate
331
332
  my_off_t pos,max_pos,filepos,start_recpos;
482 by Brian Aker
Remove uint.
333
  uint32_t key, key_length,real_key_length,sortbuff_size;
334
  uint32_t maxbuffers, keys, find_length, sort_keys_length;
281 by Brian Aker
Converted myisam away from my_bool
335
  bool fix_datafile, master;
336
  bool calc_checksum;                /* calculate table checksum */
1 by brian
clean slate
337
  MI_KEYDEF *keyinfo;
338
  HA_KEYSEG *seg;
339
  SORT_INFO *sort_info;
481 by Brian Aker
Remove all of uchar.
340
  unsigned char **sort_keys;
341
  unsigned char *rec_buff;
1 by brian
clean slate
342
  void *wordlist, *wordptr;
343
  MEM_ROOT wordroot;
481 by Brian Aker
Remove all of uchar.
344
  unsigned char *record;
1 by brian
clean slate
345
  int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
346
  int (*key_read)(struct st_mi_sort_param *,void *);
347
  int (*key_write)(struct st_mi_sort_param *, const void *);
348
  void (*lock_in_memory)(MI_CHECK *);
481 by Brian Aker
Remove all of uchar.
349
  int (*write_keys)(struct st_mi_sort_param *, register unsigned char **,
482 by Brian Aker
Remove uint.
350
                     uint32_t , struct st_buffpek *, IO_CACHE *);
1 by brian
clean slate
351
  unsigned int (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
481 by Brian Aker
Remove all of uchar.
352
  int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,unsigned char *,
1 by brian
clean slate
353
                       uint, uint);
354
} MI_SORT_PARAM;
355
356
	/* Some defines used by isam-funktions */
357
358
#define USE_WHOLE_KEY	MI_MAX_KEY_BUFF*2 /* Use whole key in _mi_search() */
359
#define F_EXTRA_LCK	-1
360
361
	/* bits in opt_flag */
362
#define MEMMAP_USED	32
363
#define REMEMBER_OLD_POS 64
364
365
#define WRITEINFO_UPDATE_KEYFILE	1
366
#define WRITEINFO_NO_UNLOCK		2
367
368
        /* once_flags */
369
#define USE_PACKED_KEYS         1
370
#define RRND_PRESERVE_LASTINX   2
371
372
	/* bits in state.changed */
373
374
#define STATE_CHANGED		1
375
#define STATE_CRASHED		2
376
#define STATE_CRASHED_ON_REPAIR 4
377
#define STATE_NOT_ANALYZED	8
378
#define STATE_NOT_OPTIMIZED_KEYS 16
379
#define STATE_NOT_SORTED_PAGES	32
380
381
	/* options to mi_read_cache */
382
383
#define READING_NEXT	1
384
#define READING_HEADER	2
385
51.1.127 by Monty Taylor
Fixed the _mi_report_crashed warning (and a couple of others)
386
1 by brian
clean slate
387
#define mi_getint(x)	((uint) mi_uint2korr(x) & 32767)
206 by Brian Aker
Removed final uint dead types.
388
#define mi_putint(x,y,nod) { uint16_t boh=(nod ? (uint16_t) 32768 : 0) + (uint16_t) (y);\
1 by brian
clean slate
389
			  mi_int2store(x,boh); }
390
#define mi_test_if_nod(x) (x[0] & 128 ? info->s->base.key_reflength : 0)
391
#define mi_report_crashed(A, B) _mi_report_crashed((A), (B), __FILE__, __LINE__)
392
#define mi_mark_crashed(x) do{(x)->s->state.changed|= STATE_CRASHED; \
393
                              mi_report_crashed((x), 0); \
394
                           }while(0)
395
#define mi_mark_crashed_on_repair(x) do{(x)->s->state.changed|= \
396
                                        STATE_CRASHED|STATE_CRASHED_ON_REPAIR; \
397
                                        (x)->update|= HA_STATE_CHANGED; \
398
                                     }while(0)
399
#define mi_is_crashed(x) ((x)->s->state.changed & STATE_CRASHED)
400
#define mi_is_crashed_on_repair(x) ((x)->s->state.changed & STATE_CRASHED_ON_REPAIR)
401
#define mi_print_error(SHARE, ERRNO)                     \
402
        mi_report_error((ERRNO), (SHARE)->index_file_name)
403
404
/* Functions to store length of space packed keys, VARCHAR or BLOB keys */
405
406
#define store_key_length(key,length) \
407
{ if ((length) < 255) \
408
  { *(key)=(length); } \
409
  else \
410
  { *(key)=255; mi_int2store((key)+1,(length)); } \
411
}
412
413
#define get_key_full_length(length,key) \
481 by Brian Aker
Remove all of uchar.
414
{ if ((unsigned char) *(key) != 255) \
415
    length= ((uint) (unsigned char) *((key)++))+1; \
1 by brian
clean slate
416
  else \
417
  { length=mi_uint2korr((key)+1)+3; (key)+=3; } \
418
}
419
420
#define get_key_full_length_rdonly(length,key) \
481 by Brian Aker
Remove all of uchar.
421
{ if ((unsigned char) *(key) != 255) \
422
    length= ((uint) (unsigned char) *((key)))+1; \
1 by brian
clean slate
423
  else \
424
  { length=mi_uint2korr((key)+1)+3; } \
425
}
426
427
#define get_pack_length(length) ((length) >= 255 ? 3 : 1)
428
429
#define MI_MIN_BLOCK_LENGTH	20	/* Because of delete-link */
430
#define MI_EXTEND_BLOCK_LENGTH	20	/* Don't use to small record-blocks */
431
#define MI_SPLIT_LENGTH	((MI_EXTEND_BLOCK_LENGTH+4)*2)
432
#define MI_MAX_DYN_BLOCK_HEADER	20	/* Max prefix of record-block */
433
#define MI_BLOCK_INFO_HEADER_LENGTH 20
434
#define MI_DYN_DELETE_BLOCK_HEADER 20	/* length of delete-block-header */
435
#define MI_DYN_MAX_BLOCK_LENGTH	((1L << 24)-4L)
436
#define MI_DYN_MAX_ROW_LENGTH	(MI_DYN_MAX_BLOCK_LENGTH - MI_SPLIT_LENGTH)
437
#define MI_DYN_ALIGN_SIZE	4	/* Align blocks on this */
438
#define MI_MAX_DYN_HEADER_BYTE	13	/* max header byte for dynamic rows */
439
#define MI_MAX_BLOCK_LENGTH	((((ulong) 1 << 24)-1) & (~ (ulong) (MI_DYN_ALIGN_SIZE-1)))
205 by Brian Aker
uint32 -> uin32_t
440
#define MI_REC_BUFF_OFFSET      ALIGN_SIZE(MI_DYN_DELETE_BLOCK_HEADER+sizeof(uint32_t))
1 by brian
clean slate
441
442
#define MEMMAP_EXTRA_MARGIN	7	/* Write this as a suffix for file */
443
444
#define PACK_TYPE_SELECTED	1	/* Bits in field->pack_type */
445
#define PACK_TYPE_SPACE_FIELDS	2
446
#define PACK_TYPE_ZERO_FILL	4
447
#define MI_FOUND_WRONG_KEY 32738	/* Impossible value from ha_key_cmp */
448
449
#define MI_MAX_KEY_BLOCK_SIZE	(MI_MAX_KEY_BLOCK_LENGTH/MI_MIN_KEY_BLOCK_LENGTH)
450
#define MI_BLOCK_SIZE(key_length,data_pointer,key_pointer,block_size) (((((key_length)+(data_pointer)+(key_pointer))*4+(key_pointer)+2)/(block_size)+1)*(block_size))
451
#define MI_MAX_KEYPTR_SIZE	5        /* For calculating block lengths */
452
#define MI_MIN_KEYBLOCK_LENGTH	50         /* When to split delete blocks */
453
454
#define MI_MIN_SIZE_BULK_INSERT_TREE 16384             /* this is per key */
455
#define MI_MIN_ROWS_TO_USE_BULK_INSERT 100
456
#define MI_MIN_ROWS_TO_DISABLE_INDEXES 100
457
#define MI_MIN_ROWS_TO_USE_WRITE_CACHE 10
458
459
/* The UNIQUE check is done with a hashed long key */
460
461
#define MI_UNIQUE_HASH_TYPE	HA_KEYTYPE_ULONG_INT
462
#define mi_unique_store(A,B)    mi_int4store((A),(B))
463
464
extern pthread_mutex_t THR_LOCK_myisam;
465
466
	/* Some extern variables */
467
468
extern LIST *myisam_open_list;
481 by Brian Aker
Remove all of uchar.
469
extern unsigned char  myisam_file_magic[], myisam_pack_file_magic[];
482 by Brian Aker
Remove uint.
470
extern uint32_t  myisam_read_vec[], myisam_readnext_vec[];
471
extern uint32_t myisam_quick_table_bits;
1 by brian
clean slate
472
extern ulong myisam_pid;
473
474
	/* This is used by _mi_calc_xxx_key_length och _mi_store_key */
475
476
typedef struct st_mi_s_param
477
{
478
  uint	ref_length,key_length,
479
	n_ref_length,
480
	n_length,
481
	totlength,
482
	part_of_prev_key,prev_length,pack_marker;
481 by Brian Aker
Remove all of uchar.
483
  unsigned char *key, *prev_key,*next_key_pos;
281 by Brian Aker
Converted myisam away from my_bool
484
  bool store_not_null;
1 by brian
clean slate
485
} MI_KEY_PARAM;
486
487
	/* Prototypes for intern functions */
488
481 by Brian Aker
Remove all of uchar.
489
extern int _mi_read_dynamic_record(MI_INFO *info,my_off_t filepos,unsigned char *buf);
490
extern int _mi_write_dynamic_record(MI_INFO*, const unsigned char*);
491
extern int _mi_update_dynamic_record(MI_INFO*, my_off_t, const unsigned char*);
1 by brian
clean slate
492
extern int _mi_delete_dynamic_record(MI_INFO *info);
481 by Brian Aker
Remove all of uchar.
493
extern int _mi_cmp_dynamic_record(MI_INFO *info,const unsigned char *record);
494
extern int _mi_read_rnd_dynamic_record(MI_INFO *, unsigned char *,my_off_t, bool);
495
extern int _mi_write_blob_record(MI_INFO*, const unsigned char*);
496
extern int _mi_update_blob_record(MI_INFO*, my_off_t, const unsigned char*);
497
extern int _mi_read_static_record(MI_INFO *info, my_off_t filepos,unsigned char *buf);
498
extern int _mi_write_static_record(MI_INFO*, const unsigned char*);
499
extern int _mi_update_static_record(MI_INFO*, my_off_t, const unsigned char*);
1 by brian
clean slate
500
extern int _mi_delete_static_record(MI_INFO *info);
481 by Brian Aker
Remove all of uchar.
501
extern int _mi_cmp_static_record(MI_INFO *info,const unsigned char *record);
502
extern int _mi_read_rnd_static_record(MI_INFO*, unsigned char *,my_off_t, bool);
482 by Brian Aker
Remove uint.
503
extern int _mi_ck_write(MI_INFO *info,uint32_t keynr,unsigned char *key,uint32_t length);
1 by brian
clean slate
504
extern int _mi_ck_real_write_btree(MI_INFO *info, MI_KEYDEF *keyinfo,
482 by Brian Aker
Remove uint.
505
                                   unsigned char *key, uint32_t key_length,
506
                                   my_off_t *root, uint32_t comp_flag);
481 by Brian Aker
Remove all of uchar.
507
extern int _mi_enlarge_root(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key, my_off_t *root);
508
extern int _mi_insert(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,
509
		      unsigned char *anc_buff,unsigned char *key_pos,unsigned char *key_buff,
510
		      unsigned char *father_buff, unsigned char *father_keypos,
281 by Brian Aker
Converted myisam away from my_bool
511
		      my_off_t father_page, bool insert_last);
481 by Brian Aker
Remove all of uchar.
512
extern int _mi_split_page(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,
513
			  unsigned char *buff,unsigned char *key_buff, bool insert_last);
482 by Brian Aker
Remove uint.
514
extern unsigned char *_mi_find_half_pos(uint32_t nod_flag,MI_KEYDEF *keyinfo,unsigned char *page,
515
				unsigned char *key,uint32_t *return_key_length,
481 by Brian Aker
Remove all of uchar.
516
				unsigned char **after_key);
482 by Brian Aker
Remove uint.
517
extern int _mi_calc_static_key_length(MI_KEYDEF *keyinfo,uint32_t nod_flag,
481 by Brian Aker
Remove all of uchar.
518
				      unsigned char *key_pos, unsigned char *org_key,
519
				      unsigned char *key_buff,
520
				      unsigned char *key, MI_KEY_PARAM *s_temp);
482 by Brian Aker
Remove uint.
521
extern int _mi_calc_var_key_length(MI_KEYDEF *keyinfo,uint32_t nod_flag,
481 by Brian Aker
Remove all of uchar.
522
				   unsigned char *key_pos, unsigned char *org_key,
523
				   unsigned char *key_buff,
524
				   unsigned char *key, MI_KEY_PARAM *s_temp);
482 by Brian Aker
Remove uint.
525
extern int _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint32_t nod_flag,
481 by Brian Aker
Remove all of uchar.
526
					unsigned char *key_pos, unsigned char *org_key,
527
					unsigned char *prev_key,
528
					unsigned char *key, MI_KEY_PARAM *s_temp);
482 by Brian Aker
Remove uint.
529
extern int _mi_calc_bin_pack_key_length(MI_KEYDEF *keyinfo,uint32_t nod_flag,
481 by Brian Aker
Remove all of uchar.
530
					unsigned char *key_pos,unsigned char *org_key,
531
					unsigned char *prev_key,
532
					unsigned char *key, MI_KEY_PARAM *s_temp);
533
void _mi_store_static_key(MI_KEYDEF *keyinfo,  unsigned char *key_pos,
1 by brian
clean slate
534
			   MI_KEY_PARAM *s_temp);
481 by Brian Aker
Remove all of uchar.
535
void _mi_store_var_pack_key(MI_KEYDEF *keyinfo,  unsigned char *key_pos,
1 by brian
clean slate
536
			     MI_KEY_PARAM *s_temp);
537
#ifdef NOT_USED
481 by Brian Aker
Remove all of uchar.
538
void _mi_store_pack_key(MI_KEYDEF *keyinfo,  unsigned char *key_pos,
1 by brian
clean slate
539
			 MI_KEY_PARAM *s_temp);
540
#endif
481 by Brian Aker
Remove all of uchar.
541
void _mi_store_bin_pack_key(MI_KEYDEF *keyinfo,  unsigned char *key_pos,
1 by brian
clean slate
542
			    MI_KEY_PARAM *s_temp);
543
482 by Brian Aker
Remove uint.
544
extern int _mi_ck_delete(MI_INFO *info,uint32_t keynr,unsigned char *key,uint32_t key_length);
598.1.1 by Super-User
Fixed solaris build crap.
545
int _mi_readinfo(MI_INFO *info,int lock_flag,int check_keybuffer);
482 by Brian Aker
Remove uint.
546
extern int _mi_writeinfo(MI_INFO *info,uint32_t options);
1 by brian
clean slate
547
extern int _mi_test_if_changed(MI_INFO *info);
548
extern int _mi_mark_file_changed(MI_INFO *info);
549
extern int _mi_decrement_open_count(MI_INFO *info);
550
extern int _mi_check_index(MI_INFO *info,int inx);
482 by Brian Aker
Remove uint.
551
extern int _mi_search(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,uint32_t key_len,
552
		      uint32_t nextflag,my_off_t pos);
1 by brian
clean slate
553
extern int _mi_bin_search(struct st_myisam_info *info,MI_KEYDEF *keyinfo,
482 by Brian Aker
Remove uint.
554
			  unsigned char *page,unsigned char *key,uint32_t key_len,uint32_t comp_flag,
481 by Brian Aker
Remove all of uchar.
555
			  unsigned char * *ret_pos,unsigned char *buff, bool *was_last_key);
556
extern int _mi_seq_search(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *page,
482 by Brian Aker
Remove uint.
557
			  unsigned char *key,uint32_t key_len,uint32_t comp_flag,
481 by Brian Aker
Remove all of uchar.
558
			  unsigned char **ret_pos,unsigned char *buff, bool *was_last_key);
559
extern int _mi_prefix_search(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *page,
482 by Brian Aker
Remove uint.
560
			  unsigned char *key,uint32_t key_len,uint32_t comp_flag,
481 by Brian Aker
Remove all of uchar.
561
			  unsigned char **ret_pos,unsigned char *buff, bool *was_last_key);
482 by Brian Aker
Remove uint.
562
extern my_off_t _mi_kpos(uint32_t nod_flag,unsigned char *after_key);
481 by Brian Aker
Remove all of uchar.
563
extern void _mi_kpointer(MI_INFO *info,unsigned char *buff,my_off_t pos);
482 by Brian Aker
Remove uint.
564
extern my_off_t _mi_dpos(MI_INFO *info, uint32_t nod_flag,unsigned char *after_key);
481 by Brian Aker
Remove all of uchar.
565
extern my_off_t _mi_rec_pos(MYISAM_SHARE *info, unsigned char *ptr);
598.1.1 by Super-User
Fixed solaris build crap.
566
void _mi_dpointer(MI_INFO *info, unsigned char *buff,my_off_t pos);
482 by Brian Aker
Remove uint.
567
extern uint32_t _mi_get_static_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char * *page,
481 by Brian Aker
Remove all of uchar.
568
			       unsigned char *key);
482 by Brian Aker
Remove uint.
569
extern uint32_t _mi_get_pack_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char * *page,
481 by Brian Aker
Remove all of uchar.
570
			     unsigned char *key);
482 by Brian Aker
Remove uint.
571
extern uint32_t _mi_get_binary_pack_key(MI_KEYDEF *keyinfo, uint32_t nod_flag,
481 by Brian Aker
Remove all of uchar.
572
				    unsigned char **page_pos, unsigned char *key);
573
extern unsigned char *_mi_get_last_key(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *keypos,
574
			       unsigned char *lastkey,unsigned char *endpos,
482 by Brian Aker
Remove uint.
575
			       uint32_t *return_key_length);
481 by Brian Aker
Remove all of uchar.
576
extern unsigned char *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, unsigned char *page,
482 by Brian Aker
Remove uint.
577
			  unsigned char *key, unsigned char *keypos, uint32_t *return_key_length);
578
extern uint32_t _mi_keylength(MI_KEYDEF *keyinfo,unsigned char *key);
579
extern uint32_t _mi_keylength_part(MI_KEYDEF *keyinfo, register unsigned char *key,
1 by brian
clean slate
580
			       HA_KEYSEG *end);
481 by Brian Aker
Remove all of uchar.
581
extern unsigned char *_mi_move_key(MI_KEYDEF *keyinfo,unsigned char *to,unsigned char *from);
582
extern int _mi_search_next(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,
482 by Brian Aker
Remove uint.
583
			   uint32_t key_length,uint32_t nextflag,my_off_t pos);
1 by brian
clean slate
584
extern int _mi_search_first(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos);
585
extern int _mi_search_last(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos);
481 by Brian Aker
Remove all of uchar.
586
extern unsigned char *_mi_fetch_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page,
587
				int level,unsigned char *buff,int return_buffer);
1 by brian
clean slate
588
extern int _mi_write_keypage(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t page,
481 by Brian Aker
Remove all of uchar.
589
			     int level, unsigned char *buff);
1 by brian
clean slate
590
extern int _mi_dispose(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos,
591
                      int level);
592
extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo,int level);
482 by Brian Aker
Remove uint.
593
extern uint32_t _mi_make_key(MI_INFO *info,uint32_t keynr,unsigned char *key,
481 by Brian Aker
Remove all of uchar.
594
			 const unsigned char *record,my_off_t filepos);
482 by Brian Aker
Remove uint.
595
extern uint32_t _mi_pack_key(register MI_INFO *info, uint32_t keynr, unsigned char *key,
481 by Brian Aker
Remove all of uchar.
596
                         unsigned char *old, key_part_map keypart_map,
1 by brian
clean slate
597
                         HA_KEYSEG **last_used_keyseg);
481 by Brian Aker
Remove all of uchar.
598
extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,unsigned char *buf);
599
extern int _mi_read_cache(IO_CACHE *info,unsigned char *buff,my_off_t pos,
482 by Brian Aker
Remove uint.
600
			  uint32_t length,int re_read_if_possibly);
481 by Brian Aker
Remove all of uchar.
601
extern uint64_t retrieve_auto_increment(MI_INFO *info,const unsigned char *record);
1 by brian
clean slate
602
656.1.39 by Monty Taylor
Removed my_seek, my_tell, my_fwrite, my_fseek.
603
unsigned char *mi_alloc_rec_buff(MI_INFO *info, size_t length, unsigned char **buf);
1 by brian
clean slate
604
#define mi_get_rec_buff_ptr(info,buf)                              \
605
        ((((info)->s->options & HA_OPTION_PACK_RECORD) && (buf)) ? \
606
        (buf) - MI_REC_BUFF_OFFSET : (buf))
607
#define mi_get_rec_buff_len(info,buf)                              \
205 by Brian Aker
uint32 -> uin32_t
608
        (*((uint32_t *)(mi_get_rec_buff_ptr(info,buf))))
1 by brian
clean slate
609
481 by Brian Aker
Remove all of uchar.
610
extern ulong _mi_rec_unpack(MI_INFO *info,unsigned char *to,unsigned char *from,
1 by brian
clean slate
611
			    ulong reclength);
481 by Brian Aker
Remove all of uchar.
612
extern bool _mi_rec_check(MI_INFO *info,const unsigned char *record, unsigned char *packpos,
281 by Brian Aker
Converted myisam away from my_bool
613
                             ulong packed_length, bool with_checkum);
1 by brian
clean slate
614
extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length,
481 by Brian Aker
Remove all of uchar.
615
				 my_off_t next_filepos,unsigned char **record,
1 by brian
clean slate
616
				 ulong *reclength,int *flag);
481 by Brian Aker
Remove all of uchar.
617
extern void _mi_print_key(FILE *stream,HA_KEYSEG *keyseg,const unsigned char *key,
482 by Brian Aker
Remove uint.
618
			  uint32_t length);
281 by Brian Aker
Converted myisam away from my_bool
619
extern bool _mi_read_pack_info(MI_INFO *info,bool fix_keys);
481 by Brian Aker
Remove all of uchar.
620
extern int _mi_read_pack_record(MI_INFO *info,my_off_t filepos,unsigned char *buf);
621
extern int _mi_read_rnd_pack_record(MI_INFO*, unsigned char *,my_off_t, bool);
1 by brian
clean slate
622
extern int _mi_pack_rec_unpack(MI_INFO *info, MI_BIT_BUFF *bit_buff,
481 by Brian Aker
Remove all of uchar.
623
                               unsigned char *to, unsigned char *from, ulong reclength);
151 by Brian Aker
Ulonglong to uint64_t
624
extern uint64_t mi_safe_mul(uint64_t a,uint64_t b);
1 by brian
clean slate
625
626
struct st_sort_info;
627
628
629
typedef struct st_mi_block_info {	/* Parameter to _mi_get_block_info */
481 by Brian Aker
Remove all of uchar.
630
  unsigned char header[MI_BLOCK_INFO_HEADER_LENGTH];
1 by brian
clean slate
631
  ulong rec_len;
632
  ulong data_len;
633
  ulong block_len;
634
  ulong blob_len;
635
  my_off_t filepos;
636
  my_off_t next_filepos;
637
  my_off_t prev_filepos;
482 by Brian Aker
Remove uint.
638
  uint32_t second_read;
639
  uint32_t offset;
1 by brian
clean slate
640
} MI_BLOCK_INFO;
641
642
	/* bits in return from _mi_get_block_info */
643
644
#define BLOCK_FIRST	1
645
#define BLOCK_LAST	2
646
#define BLOCK_DELETED	4
647
#define BLOCK_ERROR	8	/* Wrong data */
648
#define BLOCK_SYNC_ERROR 16	/* Right data at wrong place */
649
#define BLOCK_FATAL_ERROR 32	/* hardware-error */
650
651
#define NEED_MEM	((uint) 10*4*(IO_SIZE+32)+32) /* Nead for recursion */
652
#define MAXERR			20
653
#define BUFFERS_WHEN_SORTING	16		/* Alloc for sort-key-tree */
654
#define WRITE_COUNT		MY_HOW_OFTEN_TO_WRITE
655
#define INDEX_TMP_EXT		".TMM"
656
#define DATA_TMP_EXT		".TMD"
657
658
#define UPDATE_TIME		1
659
#define UPDATE_STAT		2
660
#define UPDATE_SORT		4
661
#define UPDATE_AUTO_INC		8
662
#define UPDATE_OPEN_COUNT	16
663
664
#define USE_BUFFER_INIT		(((1024L*512L-MALLOC_OVERHEAD)/IO_SIZE)*IO_SIZE)
665
#define READ_BUFFER_INIT	(1024L*256L-MALLOC_OVERHEAD)
666
#define SORT_BUFFER_INIT	(2048L*1024L-MALLOC_OVERHEAD)
667
#define MIN_SORT_BUFFER		(4096-MALLOC_OVERHEAD)
668
669
#define fast_mi_writeinfo(INFO) if (!(INFO)->s->tot_locks) (void) _mi_writeinfo((INFO),0)
670
#define fast_mi_readinfo(INFO) ((INFO)->lock_type == F_UNLCK) && _mi_readinfo((INFO),F_RDLCK,1)
671
482 by Brian Aker
Remove uint.
672
extern uint32_t _mi_get_block_info(MI_BLOCK_INFO *,File, my_off_t);
673
extern uint32_t _mi_rec_pack(MI_INFO *info,unsigned char *to,const unsigned char *from);
674
extern uint32_t _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
481 by Brian Aker
Remove all of uchar.
675
                                    MI_BLOCK_INFO *info, unsigned char **rec_buff_p,
1 by brian
clean slate
676
                                    File file, my_off_t filepos);
482 by Brian Aker
Remove uint.
677
extern void _my_store_blob_length(unsigned char *pos,uint32_t pack_length,uint32_t length);
1 by brian
clean slate
678
extern void mi_report_error(int errcode, const char *file_name);
481 by Brian Aker
Remove all of uchar.
679
extern size_t mi_mmap_pread(MI_INFO *info, unsigned char *Buffer,
1 by brian
clean slate
680
                            size_t Count, my_off_t offset, myf MyFlags);
481 by Brian Aker
Remove all of uchar.
681
extern size_t mi_mmap_pwrite(MI_INFO *info, const unsigned char *Buffer,
1 by brian
clean slate
682
                             size_t Count, my_off_t offset, myf MyFlags);
481 by Brian Aker
Remove all of uchar.
683
extern size_t mi_nommap_pread(MI_INFO *info, unsigned char *Buffer,
1 by brian
clean slate
684
                              size_t Count, my_off_t offset, myf MyFlags);
481 by Brian Aker
Remove all of uchar.
685
extern size_t mi_nommap_pwrite(MI_INFO *info, const unsigned char *Buffer,
1 by brian
clean slate
686
                               size_t Count, my_off_t offset, myf MyFlags);
687
482 by Brian Aker
Remove uint.
688
uint32_t mi_state_info_write(File file, MI_STATE_INFO *state, uint32_t pWrite);
481 by Brian Aker
Remove all of uchar.
689
unsigned char *mi_state_info_read(unsigned char *ptr, MI_STATE_INFO *state);
482 by Brian Aker
Remove uint.
690
uint32_t mi_state_info_read_dsk(File file, MI_STATE_INFO *state, bool pRead);
691
uint32_t mi_base_info_write(File file, MI_BASE_INFO *base);
481 by Brian Aker
Remove all of uchar.
692
unsigned char *my_n_base_info_read(unsigned char *ptr, MI_BASE_INFO *base);
1 by brian
clean slate
693
int mi_keyseg_write(File file, const HA_KEYSEG *keyseg);
481 by Brian Aker
Remove all of uchar.
694
unsigned char *mi_keyseg_read(unsigned char *ptr, HA_KEYSEG *keyseg);
482 by Brian Aker
Remove uint.
695
uint32_t mi_keydef_write(File file, MI_KEYDEF *keydef);
481 by Brian Aker
Remove all of uchar.
696
unsigned char *mi_keydef_read(unsigned char *ptr, MI_KEYDEF *keydef);
482 by Brian Aker
Remove uint.
697
uint32_t mi_uniquedef_write(File file, MI_UNIQUEDEF *keydef);
481 by Brian Aker
Remove all of uchar.
698
unsigned char *mi_uniquedef_read(unsigned char *ptr, MI_UNIQUEDEF *keydef);
482 by Brian Aker
Remove uint.
699
uint32_t mi_recinfo_write(File file, MI_COLUMNDEF *recinfo);
481 by Brian Aker
Remove all of uchar.
700
unsigned char *mi_recinfo_read(unsigned char *ptr, MI_COLUMNDEF *recinfo);
1 by brian
clean slate
701
extern int mi_disable_indexes(MI_INFO *info);
702
extern int mi_enable_indexes(MI_INFO *info);
703
extern int mi_indexes_are_disabled(MI_INFO *info);
481 by Brian Aker
Remove all of uchar.
704
ulong _my_calc_total_blob_length(MI_INFO *info, const unsigned char *record);
705
ha_checksum mi_checksum(MI_INFO *info, const unsigned char *buf);
706
ha_checksum mi_static_checksum(MI_INFO *info, const unsigned char *buf);
707
bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, unsigned char *record,
1 by brian
clean slate
708
		     ha_checksum unique_hash, my_off_t pos);
481 by Brian Aker
Remove all of uchar.
709
ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const unsigned char *buf);
1 by brian
clean slate
710
int _mi_cmp_static_unique(MI_INFO *info, MI_UNIQUEDEF *def,
481 by Brian Aker
Remove all of uchar.
711
			   const unsigned char *record, my_off_t pos);
1 by brian
clean slate
712
int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def,
481 by Brian Aker
Remove all of uchar.
713
			   const unsigned char *record, my_off_t pos);
714
int mi_unique_comp(MI_UNIQUEDEF *def, const unsigned char *a, const unsigned char *b,
281 by Brian Aker
Converted myisam away from my_bool
715
		   bool null_are_equal);
1 by brian
clean slate
716
void mi_get_status(void* param, int concurrent_insert);
717
void mi_update_status(void* param);
718
void mi_restore_status(void* param);
719
void mi_copy_status(void* to,void *from);
153 by Brian Aker
Merging Monty's code, I did remove error on compile though (since it does
720
bool mi_check_status(void* param);
1 by brian
clean slate
721
722
extern MI_INFO *test_if_reopen(char *filename);
281 by Brian Aker
Converted myisam away from my_bool
723
bool check_table_is_closed(const char *name, const char *where);
1 by brian
clean slate
724
int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup);
725
int mi_open_keyfile(MYISAM_SHARE *share);
726
void mi_setup_functions(register MYISAM_SHARE *share);
281 by Brian Aker
Converted myisam away from my_bool
727
bool mi_dynmap_file(MI_INFO *info, my_off_t size);
1 by brian
clean slate
728
void mi_remap_file(MI_INFO *info, my_off_t size);
729
482 by Brian Aker
Remove uint.
730
int mi_check_index_cond(register MI_INFO *info, uint32_t keynr, unsigned char *record);
1 by brian
clean slate
731
732
    /* Functions needed by mi_check */
733
volatile int *killed_ptr(MI_CHECK *param);
398.1.9 by Monty Taylor
Cleaned up stuff out of global.h.
734
void mi_check_print_error(MI_CHECK *param, const char *fmt,...);
735
void mi_check_print_warning(MI_CHECK *param, const char *fmt,...);
736
void mi_check_print_info(MI_CHECK *param, const char *fmt,...);
1 by brian
clean slate
737
int flush_pending_blocks(MI_SORT_PARAM *param);
738
int thr_write_keys(MI_SORT_PARAM *sort_param);
739
pthread_handler_t thr_find_all_keys(void *arg);
740
int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file);
741
742
int sort_write_record(MI_SORT_PARAM *sort_param);
629.4.1 by Monty Taylor
First step in support size_t sys_var stuff.
743
int _create_index_by_sort(MI_SORT_PARAM *info,bool no_messages, size_t);
1 by brian
clean slate
744
745
extern void mi_set_index_cond_func(MI_INFO *info, index_cond_func_t func,
746
                                   void *func_arg);
36 by Brian Aker
Moved pread over to just supporting myisam (someone can refactor from here
747
/* Just for myisam legacy */
481 by Brian Aker
Remove all of uchar.
748
extern size_t my_pwrite(File Filedes,const unsigned char *Buffer,size_t Count,
36 by Brian Aker
Moved pread over to just supporting myisam (someone can refactor from here
749
		      my_off_t offset,myf MyFlags);
481 by Brian Aker
Remove all of uchar.
750
extern size_t my_pread(File Filedes,unsigned char *Buffer,size_t Count,my_off_t offset,
36 by Brian Aker
Moved pread over to just supporting myisam (someone can refactor from here
751
		     myf MyFlags);
77 by Brian Aker
Resolved merge from Monty
752
753
/* Needed for handler */
754
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows);
51.1.127 by Monty Taylor
Fixed the _mi_report_crashed warning (and a couple of others)
755
void _mi_report_crashed(MI_INFO *file __attribute__((unused)),
756
                        const char *message __attribute__((unused)),
757
                        const char *sfile __attribute__((unused)),
482 by Brian Aker
Remove uint.
758
                        uint32_t sline __attribute__((unused)));
51.1.127 by Monty Taylor
Fixed the _mi_report_crashed warning (and a couple of others)
759
1 by brian
clean slate
760
#ifdef __cplusplus
761
}
762
#endif
763
51.1.127 by Monty Taylor
Fixed the _mi_report_crashed warning (and a couple of others)
764
243.1.11 by Jay Pipes
* Added include guards in a couple places, and removed unecessary
765
#endif /* MYISAMDEF_H */