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