MySQL  8.0.18
Source Code Documentation
myisam.h File Reference

This file should be included when using myisam functions. More...

#include "my_config.h"
#include <sys/types.h>
#include <time.h>
#include "keycache.h"
#include "m_ctype.h"
#include "m_string.h"
#include "my_base.h"
#include "my_check_opt.h"
#include "my_compare.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_macros.h"

Go to the source code of this file.


struct  MI_KEYDEF
struct  MI_CHECK
struct  SORT_FT_BUF
struct  SORT_INFO


#define MI_MAX_KEY   MAX_INDEXES /* Max allowed keys */
#define MI_MAX_KEY_LENGTH   1000 /* Max length in bytes */
#define MI_MAX_KEY_SEG   16 /* Max segments for key */
#define MI_MAX_KEY_BUFF   (MI_MAX_KEY_LENGTH + MI_MAX_KEY_SEG * 6 + 8 + 8)
#define MI_MAX_MSG_BUF   1024 /* used in CHECK TABLE, REPAIR TABLE */
#define MI_NAME_IEXT   ".MYI"
#define MI_NAME_DEXT   ".MYD"
#define MI_KEY_BLOCK_LENGTH   1024 /* default key block length */
#define MI_MIN_KEY_BLOCK_LENGTH   1024 /* Min key block length */
#define MI_MAX_KEY_BLOCK_LENGTH   16384
#define mi_get_mask_all_keys_active(_keys_)   (((_keys_) < MI_KEYMAP_BITS) ? ((1ULL << (_keys_)) - 1ULL) : (~0ULL))
#define mi_is_key_active(_keymap_, _keyno_)   MY_TEST((_keymap_) & (1ULL << (_keyno_)))
#define mi_set_key_active(_keymap_, _keyno_)   (_keymap_) |= (1ULL << (_keyno_))
#define mi_clear_key_active(_keymap_, _keyno_)   (_keymap_) &= (~(1ULL << (_keyno_)))
#define mi_is_any_key_active(_keymap_)   MY_TEST((_keymap_))
#define mi_is_all_keys_active(_keymap_, _keys_)   ((_keymap_) == mi_get_mask_all_keys_active(_keys_))
#define mi_set_all_keys_active(_keymap_, _keys_)   (_keymap_) = mi_get_mask_all_keys_active(_keys_)
#define mi_clear_all_keys_active(_keymap_)   (_keymap_) = 0
#define mi_intersect_keys_active(_to_, _from_)   (_to_) &= (_from_)
#define mi_is_any_intersect_keys_active(_keymap1_, _keys_, _keymap2_)   ((_keymap1_) & (_keymap2_)&mi_get_mask_all_keys_active(_keys_))
#define mi_copy_keys_active(_to_, _maxkeys_, _from_)   (_to_) = (mi_get_mask_all_keys_active(_maxkeys_) & (_from_))
#define mi_close(file)   mi_close_share(file, NULL)
#define mi_open(name, mode, wait_if_locked)   mi_open_share(name, NULL, mode, wait_if_locked)
#define MEMMAP_EXTRA_MARGIN   7 /* Write this as a suffix for mmap file */
#define MYISAMCHK_REPAIR   1 /* equivalent to myisamchk -r */
#define MYISAMCHK_VERIFY   2 /* Verify, run repair if failure */
#define TT_USEFRM   1
#define TT_FOR_UPGRADE   2
#define O_NEW_INDEX   1 /* Bits set in out_flag */
#define O_NEW_DATA   2
#define O_DATA_LOST   4




int mi_close_share (MI_INFO *file, bool *closed_share)
int mi_delete (MI_INFO *file, const uchar *buff)
MI_INFOmi_open_share (const char *name, MYISAM_SHARE *old_share, int mode, uint wait_if_locked)
int mi_panic (enum ha_panic_function function)
int mi_rfirst (MI_INFO *file, uchar *buf, int inx)
int mi_rkey (MI_INFO *info, uchar *buf, int inx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function search_flag)
int mi_rlast (MI_INFO *file, uchar *buf, int inx)
int mi_rnext (MI_INFO *file, uchar *buf, int inx)
int mi_rnext_same (MI_INFO *info, uchar *buf)
int mi_rprev (MI_INFO *file, uchar *buf, int inx)
int mi_rrnd (MI_INFO *file, uchar *buf, my_off_t pos)
int mi_scan_init (MI_INFO *file)
int mi_scan (MI_INFO *file, uchar *buf)
int mi_rsame (MI_INFO *file, uchar *record, int inx)
int mi_rsame_with_pos (MI_INFO *file, uchar *record, int inx, my_off_t pos)
int mi_update (MI_INFO *file, const uchar *old, uchar *new_record)
int mi_write (MI_INFO *file, uchar *buff)
my_off_t mi_position (MI_INFO *file)
int mi_status (MI_INFO *info, MI_ISAMINFO *x, uint flag)
int mi_lock_database (MI_INFO *file, int lock_type)
int mi_create (const char *name, uint keys, MI_KEYDEF *keydef, uint columns, MI_COLUMNDEF *columndef, uint uniques, MI_UNIQUEDEF *uniquedef, MI_CREATE_INFO *create_info, uint flags)
int mi_delete_table (const char *name)
int mi_rename (const char *from, const char *to)
int mi_extra (MI_INFO *file, enum ha_extra_function function, void *extra_arg)
int mi_reset (MI_INFO *file)
ha_rows mi_records_in_range (MI_INFO *info, int inx, key_range *min_key, key_range *max_key)
int mi_log (int activate_log)
int mi_is_changed (MI_INFO *info)
int mi_delete_all_rows (MI_INFO *info)
ulong _mi_calc_blob_length (uint length, const uchar *pos)
uint mi_get_pointer_length (ulonglong file_length, uint def)
void myisamchk_init (MI_CHECK *param)
int chk_status (MI_CHECK *param, MI_INFO *info)
int chk_del (MI_CHECK *param, MI_INFO *info, uint test_flag)
int chk_size (MI_CHECK *param, MI_INFO *info)
int chk_key (MI_CHECK *param, MI_INFO *info)
int chk_data_link (MI_CHECK *param, MI_INFO *info, int extend)
int mi_repair (MI_CHECK *param, MI_INFO *info, char *name, int rep_quick, bool no_copy_stat)
int mi_sort_index (MI_CHECK *param, MI_INFO *info, char *name, bool no_copy_stat)
int mi_repair_by_sort (MI_CHECK *param, MI_INFO *info, const char *name, int rep_quick, bool no_copy_stat)
int mi_repair_parallel (MI_CHECK *param, MI_INFO *info, const char *name, int rep_quick, bool no_copy_stat)
int change_to_newfile (const char *filename, const char *old_ext, const char *new_ext, myf myflags)
int lock_file (MI_CHECK *param, File file, int lock_type, const char *filetype, const char *filename)
void lock_memory (MI_CHECK *param)
void update_auto_increment_key (MI_CHECK *param, MI_INFO *info, bool repair)
int update_state_info (MI_CHECK *param, MI_INFO *info, uint update)
void update_key_parts (MI_KEYDEF *keyinfo, ulong *rec_per_key_part, ulonglong *unique, ulonglong *notnull, ulonglong records)
int filecopy (MI_CHECK *param, File to, File from, my_off_t start, my_off_t length, const char *type)
int movepoint (MI_INFO *info, uchar *record, my_off_t oldpos, my_off_t newpos, uint prot_key)
int write_data_suffix (SORT_INFO *sort_info, bool fix_datafile)
int test_if_almost_full (MI_INFO *info)
int recreate_table (MI_CHECK *param, MI_INFO **org_info, char *filename)
void mi_disable_non_unique_index (MI_INFO *info, ha_rows rows)
bool mi_test_if_sort_rep (MI_INFO *info, ha_rows rows, ulonglong key_map, bool force)
int mi_init_bulk_insert (MI_INFO *info, ulong cache_size, ha_rows rows)
void mi_flush_bulk_insert (MI_INFO *info, uint inx)
void mi_end_bulk_insert (MI_INFO *info)
int mi_assign_to_key_cache (MI_INFO *info, ulonglong key_map, KEY_CACHE *key_cache)
void mi_change_key_cache (KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache)
int mi_preload (MI_INFO *info, ulonglong key_map, bool ignore_leaves)
st_keycache_thread_varkeycache_thread_var ()


const char * myisam_log_filename
ulong myisam_block_size
ulong myisam_concurrent_insert
bool myisam_flush
bool myisam_delay_key_write
bool myisam_single_user
my_off_t myisam_max_temp_length
ulong myisam_data_pointer_size
int(* myisam_test_invalid_symlink )(const char *filename)
ulonglong myisam_mmap_size
ulonglong myisam_mmap_used
mysql_mutex_t THR_LOCK_myisam_mmap
st_keycache_thread_var main_thread_keycache_var

Detailed Description

This file should be included when using myisam functions.

Macro Definition Documentation


#define MEMMAP_EXTRA_MARGIN   7 /* Write this as a suffix for mmap file */

◆ mi_clear_all_keys_active

#define mi_clear_all_keys_active (   _keymap_)    (_keymap_) = 0

◆ mi_clear_key_active

#define mi_clear_key_active (   _keymap_,
)    (_keymap_) &= (~(1ULL << (_keyno_)))

◆ mi_close

#define mi_close (   file)    mi_close_share(file, NULL)

◆ mi_copy_keys_active

#define mi_copy_keys_active (   _to_,
)    (_to_) = (mi_get_mask_all_keys_active(_maxkeys_) & (_from_))

◆ mi_get_mask_all_keys_active

#define mi_get_mask_all_keys_active (   _keys_)    (((_keys_) < MI_KEYMAP_BITS) ? ((1ULL << (_keys_)) - 1ULL) : (~0ULL))

◆ mi_intersect_keys_active

#define mi_intersect_keys_active (   _to_,
)    (_to_) &= (_from_)

◆ mi_is_all_keys_active

#define mi_is_all_keys_active (   _keymap_,
)    ((_keymap_) == mi_get_mask_all_keys_active(_keys_))

◆ mi_is_any_intersect_keys_active

#define mi_is_any_intersect_keys_active (   _keymap1_,
)    ((_keymap1_) & (_keymap2_)&mi_get_mask_all_keys_active(_keys_))

◆ mi_is_any_key_active

#define mi_is_any_key_active (   _keymap_)    MY_TEST((_keymap_))

◆ mi_is_key_active

#define mi_is_key_active (   _keymap_,
)    MY_TEST((_keymap_) & (1ULL << (_keyno_)))


#define MI_KEY_BLOCK_LENGTH   1024 /* default key block length */






#define MI_MAX_KEY   MAX_INDEXES /* Max allowed keys */


#define MI_MAX_KEY_BLOCK_LENGTH   16384


#define MI_MAX_KEY_BUFF   (MI_MAX_KEY_LENGTH + MI_MAX_KEY_SEG * 6 + 8 + 8)


#define MI_MAX_KEY_LENGTH   1000 /* Max length in bytes */


#define MI_MAX_KEY_SEG   16 /* Max segments for key */


#define MI_MAX_MSG_BUF   1024 /* used in CHECK TABLE, REPAIR TABLE */




#define MI_MIN_KEY_BLOCK_LENGTH   1024 /* Min key block length */


#define MI_NAME_DEXT   ".MYD"


#define MI_NAME_IEXT   ".MYI"

◆ mi_open

#define mi_open (   name,
)    mi_open_share(name, NULL, mode, wait_if_locked)

◆ mi_set_all_keys_active

#define mi_set_all_keys_active (   _keymap_,
)    (_keymap_) = mi_get_mask_all_keys_active(_keys_)

◆ mi_set_key_active

#define mi_set_key_active (   _keymap_,
)    (_keymap_) |= (1ULL << (_keyno_))




#define MYISAMCHK_REPAIR   1 /* equivalent to myisamchk -r */


#define MYISAMCHK_VERIFY   2 /* Verify, run repair if failure */


#define O_DATA_LOST   4


#define O_NEW_DATA   2


#define O_NEW_INDEX   1 /* Bits set in out_flag */


#define TT_FOR_UPGRADE   2


#define TT_USEFRM   1

Enumeration Type Documentation

◆ enum_mi_stats_method


Function Documentation

◆ _mi_calc_blob_length()

ulong _mi_calc_blob_length ( uint  length,
const uchar pos 

◆ change_to_newfile()

int change_to_newfile ( const char *  filename,
const char *  old_ext,
const char *  new_ext,
myf  myflags 

◆ chk_data_link()

int chk_data_link ( MI_CHECK param,
MI_INFO info,
int  extend 

◆ chk_del()

int chk_del ( MI_CHECK param,
MI_INFO info,
uint  test_flag 

◆ chk_key()

int chk_key ( MI_CHECK param,
MI_INFO info 

◆ chk_size()

int chk_size ( MI_CHECK param,
MI_INFO info 

◆ chk_status()

int chk_status ( MI_CHECK param,
MI_INFO info 

◆ filecopy()

int filecopy ( MI_CHECK param,
File  to,
File  from,
my_off_t  start,
my_off_t  length,
const char *  type 

◆ keycache_thread_var()

st_keycache_thread_var* keycache_thread_var ( )

◆ lock_file()

int lock_file ( MI_CHECK param,
File  file,
int  lock_type,
const char *  filetype,
const char *  filename 

◆ lock_memory()

void lock_memory ( MI_CHECK param)

◆ mi_assign_to_key_cache()

int mi_assign_to_key_cache ( MI_INFO info,
ulonglong  key_map,
KEY_CACHE key_cache 

◆ mi_change_key_cache()

void mi_change_key_cache ( KEY_CACHE old_key_cache,
KEY_CACHE new_key_cache 

◆ mi_close_share()

int mi_close_share ( MI_INFO file,
bool closed_share 

◆ mi_create()

int mi_create ( const char *  name,
uint  keys,
MI_KEYDEF keydef,
uint  columns,
MI_COLUMNDEF columndef,
uint  uniques,
MI_UNIQUEDEF uniquedef,
MI_CREATE_INFO create_info,
uint  flags 

◆ mi_delete()

int mi_delete ( MI_INFO file,
const uchar buff 

◆ mi_delete_all_rows()

int mi_delete_all_rows ( MI_INFO info)

◆ mi_delete_table()

int mi_delete_table ( const char *  name)

◆ mi_disable_non_unique_index()

void mi_disable_non_unique_index ( MI_INFO info,
ha_rows  rows 

◆ mi_end_bulk_insert()

void mi_end_bulk_insert ( MI_INFO info)

◆ mi_extra()

int mi_extra ( MI_INFO file,
enum ha_extra_function  function,
void *  extra_arg 

◆ mi_flush_bulk_insert()

void mi_flush_bulk_insert ( MI_INFO info,
uint  inx 

◆ mi_get_pointer_length()

uint mi_get_pointer_length ( ulonglong  file_length,
uint  def 

◆ mi_init_bulk_insert()

int mi_init_bulk_insert ( MI_INFO info,
ulong  cache_size,
ha_rows  rows 

◆ mi_is_changed()

int mi_is_changed ( MI_INFO info)

◆ mi_lock_database()

int mi_lock_database ( MI_INFO file,
int  lock_type 

◆ mi_log()

int mi_log ( int  activate_log)

◆ mi_open_share()

MI_INFO* mi_open_share ( const char *  name,
MYISAM_SHARE old_share,
int  mode,
uint  wait_if_locked 

◆ mi_panic()

int mi_panic ( enum ha_panic_function  function)

◆ mi_position()

my_off_t mi_position ( MI_INFO file)

◆ mi_preload()

int mi_preload ( MI_INFO info,
ulonglong  key_map,
bool  ignore_leaves 

◆ mi_records_in_range()

ha_rows mi_records_in_range ( MI_INFO info,
int  inx,
key_range min_key,
key_range max_key 

◆ mi_rename()

int mi_rename ( const char *  from,
const char *  to 

◆ mi_repair()

int mi_repair ( MI_CHECK param,
MI_INFO info,
char *  name,
int  rep_quick,
bool  no_copy_stat 

◆ mi_repair_by_sort()

int mi_repair_by_sort ( MI_CHECK param,
MI_INFO info,
const char *  name,
int  rep_quick,
bool  no_copy_stat 

◆ mi_repair_parallel()

int mi_repair_parallel ( MI_CHECK param,
MI_INFO info,
const char *  name,
int  rep_quick,
bool  no_copy_stat 

◆ mi_reset()

int mi_reset ( MI_INFO file)

◆ mi_rfirst()

int mi_rfirst ( MI_INFO file,
uchar buf,
int  inx 

◆ mi_rkey()

int mi_rkey ( MI_INFO info,
uchar buf,
int  inx,
const uchar key,
key_part_map  keypart_map,
enum ha_rkey_function  search_flag 

◆ mi_rlast()

int mi_rlast ( MI_INFO file,
uchar buf,
int  inx 

◆ mi_rnext()

int mi_rnext ( MI_INFO file,
uchar buf,
int  inx 

◆ mi_rnext_same()

int mi_rnext_same ( MI_INFO info,
uchar buf 

◆ mi_rprev()

int mi_rprev ( MI_INFO file,
uchar buf,
int  inx 

◆ mi_rrnd()

int mi_rrnd ( MI_INFO file,
uchar buf,
my_off_t  pos 

◆ mi_rsame()

int mi_rsame ( MI_INFO file,
uchar record,
int  inx 

◆ mi_rsame_with_pos()

int mi_rsame_with_pos ( MI_INFO file,
uchar record,
int  inx,
my_off_t  pos 

◆ mi_scan()

int mi_scan ( MI_INFO file,
uchar buf 

◆ mi_scan_init()

int mi_scan_init ( MI_INFO file)

◆ mi_sort_index()

int mi_sort_index ( MI_CHECK param,
MI_INFO info,
char *  name,
bool  no_copy_stat 

◆ mi_status()

int mi_status ( MI_INFO info,
uint  flag 

◆ mi_test_if_sort_rep()

bool mi_test_if_sort_rep ( MI_INFO info,
ha_rows  rows,
ulonglong  key_map,
bool  force 

◆ mi_update()

int mi_update ( MI_INFO file,
const uchar old,
uchar new_record 

◆ mi_write()

int mi_write ( MI_INFO file,
uchar buff 

◆ movepoint()

int movepoint ( MI_INFO info,
uchar record,
my_off_t  oldpos,
my_off_t  newpos,
uint  prot_key 

◆ myisamchk_init()

void myisamchk_init ( MI_CHECK param)

◆ recreate_table()

int recreate_table ( MI_CHECK param,
MI_INFO **  org_info,
char *  filename 

◆ test_if_almost_full()

int test_if_almost_full ( MI_INFO info)

◆ update_auto_increment_key()

void update_auto_increment_key ( MI_CHECK param,
MI_INFO info,
bool  repair 

◆ update_key_parts()

void update_key_parts ( MI_KEYDEF keyinfo,
ulong rec_per_key_part,
ulonglong unique,
ulonglong notnull,
ulonglong  records 

◆ update_state_info()

int update_state_info ( MI_CHECK param,
MI_INFO info,
uint  update 

◆ write_data_suffix()

int write_data_suffix ( SORT_INFO sort_info,
bool  fix_datafile 

Variable Documentation

◆ main_thread_keycache_var

st_keycache_thread_var main_thread_keycache_var

◆ myisam_block_size

ulong myisam_block_size

◆ myisam_concurrent_insert

ulong myisam_concurrent_insert

◆ myisam_data_pointer_size

ulong myisam_data_pointer_size

◆ myisam_delay_key_write

bool myisam_delay_key_write

◆ myisam_flush

bool myisam_flush

◆ myisam_log_filename

const char* myisam_log_filename

◆ myisam_max_temp_length

my_off_t myisam_max_temp_length

◆ myisam_mmap_size

ulonglong myisam_mmap_size

◆ myisam_mmap_used

ulonglong myisam_mmap_used

◆ myisam_single_user

bool myisam_single_user

◆ myisam_test_invalid_symlink

int(* myisam_test_invalid_symlink) (const char *filename)

◆ THR_LOCK_myisam_mmap

mysql_mutex_t THR_LOCK_myisam_mmap