MySQL 9.1.0
Source Code Documentation
ha_myisam.cc File Reference
#include "storage/myisam/ha_myisam.h"
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <algorithm>
#include <bit>
#include <new>
#include "lex_string.h"
#include "m_string.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_io.h"
#include "my_psi_config.h"
#include "myisam.h"
#include "myisampack.h"
#include "mysql/plugin.h"
#include "mysql/strings/int2str.h"
#include "mysql/strings/m_ctype.h"
#include "nulls.h"
#include "sql/current_thd.h"
#include "sql/derror.h"
#include "sql/field.h"
#include "sql/key.h"
#include "sql/log.h"
#include "sql/mysqld.h"
#include "sql/protocol.h"
#include "sql/sql_class.h"
#include "sql/sql_lex.h"
#include "sql/sql_plugin.h"
#include "sql/sql_table.h"
#include "sql/system_variables.h"
#include "storage/myisam/myisamdef.h"
#include "storage/myisam/rt_index.h"
#include "strxmov.h"
#include "mysql/components/services/log_builtins.h"

Macros

#define MYSQL_SERVER   1
 
#define MB   (1024 * 1024)
 

Functions

static bool myisam_is_supported_system_table (const char *db, const char *table_name, bool is_sql_layer_system_table)
 Check if the given db.tablename is a system table for this SE. More...
 
static MYSQL_SYSVAR_ULONG (block_size, opt_myisam_block_size, PLUGIN_VAR_NOSYSVAR|PLUGIN_VAR_RQCMDARG, "Block size to be used for MyISAM index pages", nullptr, nullptr, MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH)
 
static MYSQL_SYSVAR_ULONG (data_pointer_size, myisam_data_pointer_size, PLUGIN_VAR_RQCMDARG, "Default pointer size to be used for MyISAM tables", nullptr, nullptr, 6, 2, 7, 1)
 
static MYSQL_SYSVAR_ULONGLONG (max_sort_file_size, myisam_max_temp_length, PLUGIN_VAR_RQCMDARG, "Don't use the fast sort index method to created " "index if the temporary file would get bigger than this", nullptr, nullptr, LONG_MAX/MB *MB, 0, MAX_FILE_SIZE, MB)
 
static MYSQL_SYSVAR_SET (recover_options, myisam_recover_options, PLUGIN_VAR_OPCMDARG|PLUGIN_VAR_READONLY, "Syntax: myisam-recover-options[=option[,option...]], where option can be " "DEFAULT, BACKUP, FORCE, QUICK, or OFF", nullptr, nullptr, 0, &myisam_recover_typelib)
 
static MYSQL_THDVAR_ULONGLONG (sort_buffer_size, PLUGIN_VAR_RQCMDARG, "The buffer that is allocated when sorting the index when doing " "a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE", nullptr, nullptr, 8192 *1024,(long)(MIN_SORT_BUFFER+MALLOC_OVERHEAD), SIZE_T_MAX, 1)
 
static MYSQL_SYSVAR_BOOL (use_mmap, opt_myisam_use_mmap, PLUGIN_VAR_NOCMDARG, "Use memory mapping for reading and writing MyISAM tables", nullptr, nullptr, false)
 
static MYSQL_SYSVAR_ULONGLONG (mmap_size, myisam_mmap_size, PLUGIN_VAR_RQCMDARG|PLUGIN_VAR_READONLY, "Restricts the total memory " "used for memory mapping of MySQL tables", nullptr, nullptr, SIZE_T_MAX, MEMMAP_EXTRA_MARGIN, SIZE_T_MAX, 1)
 
static MYSQL_THDVAR_ENUM (stats_method, PLUGIN_VAR_RQCMDARG, "Specifies how MyISAM index statistics collection code should " "treat NULLs. Possible values of name are NULLS_UNEQUAL (default " "behavior for 4.1 and later), NULLS_EQUAL (emulate 4.0 behavior), " "and NULLS_IGNORED", nullptr, nullptr, MI_STATS_METHOD_NULLS_NOT_EQUAL, &myisam_stats_method_typelib)
 
static void debug_wait_for_kill (const char *info)
 Causes the thread to wait in a spin lock for a query kill signal. More...
 
static handlermyisam_create_handler (handlerton *hton, TABLE_SHARE *table, bool, MEM_ROOT *mem_root)
 
static void mi_check_print_msg (MI_CHECK *param, const char *msg_type, const char *fmt, va_list args)
 
int table2myisam (TABLE *table_arg, MI_KEYDEF **keydef_out, MI_COLUMNDEF **recinfo_out, uint *records_out)
 
int check_definition (MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, uint t1_keys, uint t1_recs, MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, uint t2_keys, uint t2_recs, bool strict)
 
volatile int * killed_ptr (MI_CHECK *param)
 
void mi_check_print_error (MI_CHECK *param, const char *fmt,...)
 
void mi_check_print_info (MI_CHECK *param, const char *fmt,...)
 
void mi_check_print_warning (MI_CHECK *param, const char *fmt,...)
 
void _mi_report_crashed (MI_INFO *file, const char *message, const char *sfile, uint sline)
 Report list of threads (and queries) accessing a table, thread_id of a thread that detected corruption, ource file name and line number where this corruption was detected, optional extra information (string). More...
 
ICP_RESULT index_cond_func_myisam (void *arg)
 
static int myisam_panic (handlerton *, ha_panic_function flag)
 
st_keycache_thread_varkeycache_thread_var ()
 
static int myisam_close_connection (handlerton *hton, THD *thd)
 
static int myisam_init (void *p)
 
static int myisam_deinit (void *)
 
 mysql_declare_plugin (myisam)
 

Variables

ulonglong myisam_recover_options
 
static ulong opt_myisam_block_size
 
const char * myisam_recover_names []
 
TYPELIB myisam_recover_typelib
 
const char * myisam_stats_method_names []
 
TYPELIB myisam_stats_method_typelib
 
static const char * ha_myisam_exts [] = {".MYI", ".MYD", NullS}
 
static SYS_VARmyisam_sysvars []
 
struct st_mysql_storage_engine myisam_storage_engine
 
 mysql_declare_plugin_end
 

Macro Definition Documentation

◆ MB

#define MB   (1024 * 1024)

◆ MYSQL_SERVER

#define MYSQL_SERVER   1

Function Documentation

◆ _mi_report_crashed()

void _mi_report_crashed ( MI_INFO file,
const char *  message,
const char *  sfile,
uint  sline 
)

Report list of threads (and queries) accessing a table, thread_id of a thread that detected corruption, ource file name and line number where this corruption was detected, optional extra information (string).

This function is intended to be used when table corruption is detected.

Parameters
[in]fileMI_INFO object.
[in]messageOptional error message.
[in]sfileName of source file.
[in]slineLine number in source file.

◆ check_definition()

int check_definition ( MI_KEYDEF t1_keyinfo,
MI_COLUMNDEF t1_recinfo,
uint  t1_keys,
uint  t1_recs,
MI_KEYDEF t2_keyinfo,
MI_COLUMNDEF t2_recinfo,
uint  t2_keys,
uint  t2_recs,
bool  strict 
)

◆ debug_wait_for_kill()

static void debug_wait_for_kill ( const char *  info)
static

Causes the thread to wait in a spin lock for a query kill signal.

This function is used by the test frame work to identify race conditions.

The signal is caught and ignored and the thread is not killed.

◆ index_cond_func_myisam()

ICP_RESULT index_cond_func_myisam ( void *  arg)

◆ keycache_thread_var()

st_keycache_thread_var * keycache_thread_var ( )

◆ killed_ptr()

volatile int * killed_ptr ( MI_CHECK param)

◆ mi_check_print_error()

void mi_check_print_error ( MI_CHECK param,
const char *  fmt,
  ... 
)

◆ mi_check_print_info()

void mi_check_print_info ( MI_CHECK param,
const char *  fmt,
  ... 
)

◆ mi_check_print_msg()

static void mi_check_print_msg ( MI_CHECK param,
const char *  msg_type,
const char *  fmt,
va_list  args 
)
static

◆ mi_check_print_warning()

void mi_check_print_warning ( MI_CHECK param,
const char *  fmt,
  ... 
)

◆ myisam_close_connection()

static int myisam_close_connection ( handlerton hton,
THD thd 
)
static

◆ myisam_create_handler()

static handler * myisam_create_handler ( handlerton hton,
TABLE_SHARE table,
bool  ,
MEM_ROOT mem_root 
)
static

◆ myisam_deinit()

static int myisam_deinit ( void *  )
static

◆ myisam_init()

static int myisam_init ( void *  p)
static

◆ myisam_is_supported_system_table()

static bool myisam_is_supported_system_table ( const char *  db,
const char *  table_name,
bool  is_sql_layer_system_table 
)
static

Check if the given db.tablename is a system table for this SE.

Parameters
dbdatabase name.
table_nametable name to check.
is_sql_layer_system_tableif the supplied db.table_name is a SQL layer system table.
Note
As for 8.0, MySQL doesn't support MyISAM as an engine for the system tables. Altering engine of system table to MyISAM is not allowed. Creating system tables in MyISAM is allowed to upgrade from older versions through mysqldump.
In case there is a need to define MYISAM specific system database, then please see reference implementation in ha_example.cc.
Return values
trueGiven db.table_name is supported system table.
falseGiven db.table_name is not a supported system table.

◆ myisam_panic()

static int myisam_panic ( handlerton ,
ha_panic_function  flag 
)
static

◆ mysql_declare_plugin()

mysql_declare_plugin ( myisam  )

◆ MYSQL_SYSVAR_BOOL()

static MYSQL_SYSVAR_BOOL ( use_mmap  ,
opt_myisam_use_mmap  ,
PLUGIN_VAR_NOCMDARG  ,
"Use memory mapping for reading and writing MyISAM tables"  ,
nullptr  ,
nullptr  ,
false   
)
static

◆ MYSQL_SYSVAR_SET()

static MYSQL_SYSVAR_SET ( recover_options  ,
myisam_recover_options  ,
PLUGIN_VAR_OPCMDARG PLUGIN_VAR_READONLY,
"Syntax: myisam-recover-options [=option[, option...],
where option can be " "  DEFAULT,
BACKUP  ,
FORCE  ,
QUICK  ,
or OFF"  ,
nullptr  ,
nullptr  ,
,
myisam_recover_typelib 
)
static

◆ MYSQL_SYSVAR_ULONG() [1/2]

static MYSQL_SYSVAR_ULONG ( block_size  ,
opt_myisam_block_size  ,
PLUGIN_VAR_NOSYSVAR PLUGIN_VAR_RQCMDARG,
"Block size to be used for MyISAM index pages"  ,
nullptr  ,
nullptr  ,
MI_KEY_BLOCK_LENGTH  ,
MI_MIN_KEY_BLOCK_LENGTH  ,
MI_MAX_KEY_BLOCK_LENGTH  ,
MI_MIN_KEY_BLOCK_LENGTH   
)
static

◆ MYSQL_SYSVAR_ULONG() [2/2]

static MYSQL_SYSVAR_ULONG ( data_pointer_size  ,
myisam_data_pointer_size  ,
PLUGIN_VAR_RQCMDARG  ,
"Default pointer size to be used for MyISAM tables"  ,
nullptr  ,
nullptr  ,
,
,
,
 
)
static

◆ MYSQL_SYSVAR_ULONGLONG() [1/2]

static MYSQL_SYSVAR_ULONGLONG ( max_sort_file_size  ,
myisam_max_temp_length  ,
PLUGIN_VAR_RQCMDARG  ,
"Don't use the fast sort index method to created " "index if the temporary file would get bigger than this"  ,
nullptr  ,
nullptr  ,
LONG_MAX/MB MB,
,
MAX_FILE_SIZE  ,
MB   
)
static

◆ MYSQL_SYSVAR_ULONGLONG() [2/2]

static MYSQL_SYSVAR_ULONGLONG ( mmap_size  ,
myisam_mmap_size  ,
PLUGIN_VAR_RQCMDARG PLUGIN_VAR_READONLY,
"Restricts the total memory " "used for memory mapping of MySQL tables"  ,
nullptr  ,
nullptr  ,
SIZE_T_MAX  ,
MEMMAP_EXTRA_MARGIN  ,
SIZE_T_MAX  ,
 
)
static

◆ MYSQL_THDVAR_ENUM()

static MYSQL_THDVAR_ENUM ( stats_method  ,
PLUGIN_VAR_RQCMDARG  ,
"Specifies how MyISAM index statistics collection code should " "treat NULLs. Possible values of name are NULLS_UNEQUAL   default " "behavior for 4.1 and later,
NULLS_EQUAL(emulate 4.0 behavior)  ,
" "and NULLS_IGNORED"  ,
nullptr  ,
nullptr  ,
MI_STATS_METHOD_NULLS_NOT_EQUAL  ,
myisam_stats_method_typelib 
)
static

◆ MYSQL_THDVAR_ULONGLONG()

static MYSQL_THDVAR_ULONGLONG ( sort_buffer_size  ,
PLUGIN_VAR_RQCMDARG  ,
"The buffer that is allocated when sorting the index when doing " "a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE ,
nullptr  ,
nullptr  ,
8192 *  1024,
(long)(MIN_SORT_BUFFER+MALLOC_OVERHEAD ,
SIZE_T_MAX  ,
 
)
static

◆ table2myisam()

int table2myisam ( TABLE table_arg,
MI_KEYDEF **  keydef_out,
MI_COLUMNDEF **  recinfo_out,
uint *  records_out 
)

Variable Documentation

◆ ha_myisam_exts

const char* ha_myisam_exts[] = {".MYI", ".MYD", NullS}
static

◆ myisam_recover_names

const char* myisam_recover_names[]
Initial value:
= {"DEFAULT", "BACKUP", "FORCE",
"QUICK", "OFF", NullS}
#define NullS
Definition of the null string (a null pointer of type char *), used in some of our string handling co...
Definition: nulls.h:33

◆ myisam_recover_options

ulonglong myisam_recover_options

◆ myisam_recover_typelib

TYPELIB myisam_recover_typelib
Initial value:
const char * myisam_recover_names[]
Definition: ha_myisam.cc:77
#define array_elements(A)
Definition: validate_password_imp.cc:50

◆ myisam_stats_method_names

const char* myisam_stats_method_names[]
Initial value:
= {"nulls_unequal", "nulls_equal",
"nulls_ignored", NullS}

◆ myisam_stats_method_typelib

TYPELIB myisam_stats_method_typelib
Initial value:
= {
const char * myisam_stats_method_names[]
Definition: ha_myisam.cc:82

◆ myisam_storage_engine

struct st_mysql_storage_engine myisam_storage_engine
Initial value:
= {
#define MYSQL_HANDLERTON_INTERFACE_VERSION
Definition: plugin.h:704

◆ myisam_sysvars

SYS_VAR* myisam_sysvars[]
static
Initial value:
= {MYSQL_SYSVAR(block_size),
MYSQL_SYSVAR(data_pointer_size),
MYSQL_SYSVAR(max_sort_file_size),
MYSQL_SYSVAR(recover_options),
MYSQL_SYSVAR(sort_buffer_size),
MYSQL_SYSVAR(use_mmap),
MYSQL_SYSVAR(mmap_size),
MYSQL_SYSVAR(stats_method),
nullptr}
#define MYSQL_SYSVAR(name)
Definition: plugin.h:255

◆ mysql_declare_plugin_end

mysql_declare_plugin_end

◆ opt_myisam_block_size

ulong opt_myisam_block_size
static