MySQL 8.4.3
Source Code Documentation
myisampack.cc File Reference
#include "my_config.h"
#include <assert.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>
#include <algorithm>
#include "m_string.h"
#include "my_byteorder.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_default.h"
#include "my_getopt.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_macros.h"
#include "my_pointer_arithmetic.h"
#include "my_tree.h"
#include "mysql/strings/int2str.h"
#include "mysys_err.h"
#include "print_version.h"
#include "sql/field.h"
#include "sql/mysqld_cs.h"
#include "storage/myisam/myisam_sys.h"
#include "storage/myisam/myisamdef.h"
#include "storage/myisam/queues.h"
#include "welcome_copyright_notice.h"
#include "storage/myisam/mi_extrafunc.h"

Classes

struct  st_file_buffer
 
struct  HUFF_COUNTS
 
struct  HUFF_ELEMENT
 
union  HUFF_ELEMENT::un_element
 
struct  HUFF_ELEMENT::un_element::st_nod
 
struct  HUFF_ELEMENT::un_element::st_leaf
 
struct  HUFF_TREE
 
struct  PACK_MRG_INFO
 

Macros

#define BITS_SAVED   64
 
#define IS_OFFSET   ((uint)32768) /* Bit if offset or char in tree */
 
#define HEAD_LENGTH   32
 
#define ALLOWED_JOIN_DIFF   256 /* Diff allowed to join trees */
 
#define DATA_TMP_EXT   ".TMD"
 
#define OLD_EXT   ".OLD"
 
#define FRM_EXT   ".frm"
 
#define WRITE_COUNT   MY_HOW_OFTEN_TO_WRITE
 

Enumerations

enum  options_mp { OPT_CHARSETS_DIR_MP = 256 }
 

Functions

int main (int argc, char **argv)
 
static void get_options (int *argc, char ***argv)
 
static MI_INFOopen_isam_file (char *name, int mode)
 
static bool open_isam_files (PACK_MRG_INFO *mrg, char **names, uint count)
 
static int compress (PACK_MRG_INFO *file, char *join_name)
 
static int create_dest_frm (char *source_table, char *dest_table)
 Create FRM for the destination table for –join operation Copy the first table FRM as the destination table FRM file. More...
 
static HUFF_COUNTSinit_huff_count (MI_INFO *info, my_off_t records)
 
static void free_counts_and_tree_and_queue (HUFF_TREE *huff_trees, uint trees, HUFF_COUNTS *huff_counts, uint fields)
 
static int compare_tree (const void *cmp_arg, const void *a, const void *b)
 
static int get_statistic (PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
 
static void check_counts (HUFF_COUNTS *huff_counts, uint trees, my_off_t records)
 
static int test_space_compress (HUFF_COUNTS *huff_counts, my_off_t records, uint max_space_length, my_off_t *space_counts, my_off_t tot_space_count, enum en_fieldtype field_type)
 
static HUFF_TREEmake_huff_trees (HUFF_COUNTS *huff_counts, uint trees)
 
static int make_huff_tree (HUFF_TREE *tree, HUFF_COUNTS *huff_counts)
 
static int compare_huff_elements (void *not_used, uchar *a, uchar *b)
 
static int save_counts_in_queue (void *v_key, element_count count, void *v_tree)
 
static my_off_t calc_packed_length (HUFF_COUNTS *huff_counts, uint flag)
 
static uint join_same_trees (HUFF_COUNTS *huff_counts, uint trees)
 
static int make_huff_decode_table (HUFF_TREE *huff_tree, uint trees)
 
static void make_traverse_code_tree (HUFF_TREE *huff_tree, HUFF_ELEMENT *element, uint size, ulonglong code)
 
static int write_header (PACK_MRG_INFO *isam_file, uint header_length, uint trees, my_off_t tot_elements, my_off_t filelength)
 
static void write_field_info (HUFF_COUNTS *counts, uint fields, uint trees)
 
static my_off_t write_huff_tree (HUFF_TREE *huff_tree, uint trees)
 
static uint * make_offset_code_tree (HUFF_TREE *huff_tree, HUFF_ELEMENT *element, uint *offset)
 
static uint max_bit (uint value)
 
static int compress_isam_file (PACK_MRG_INFO *file, HUFF_COUNTS *huff_counts)
 
static char * make_new_name (char *new_name, char *old_name)
 
static char * make_old_name (char *new_name, char *old_name)
 
static void init_file_buffer (File file, bool read_buffer)
 
static int flush_buffer (ulong neaded_length)
 
static void end_file_buffer (void)
 
static void write_bits (ulonglong value, uint bits)
 
static void flush_bits (void)
 
static int save_state (MI_INFO *isam_file, PACK_MRG_INFO *mrg, my_off_t new_length, ha_checksum crc)
 
static int save_state_mrg (File file, PACK_MRG_INFO *isam_file, my_off_t new_length, ha_checksum crc)
 
static int mrg_close (PACK_MRG_INFO *mrg)
 
static int mrg_rrnd (PACK_MRG_INFO *info, uchar *buf)
 
static void mrg_reset (PACK_MRG_INFO *mrg)
 
static void fakebigcodes (HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count)
 
st_keycache_thread_varkeycache_thread_var ()
 
static void usage (void)
 
static bool get_one_option (int optid, const struct my_option *opt, char *argument)
 
static char * bindigits (ulonglong value, uint bits)
 
static char * hexdigits (ulonglong value)
 

Variables

static int error_on_write = 0
 
static int test_only = 0
 
static int verbose = 0
 
static int silent = 0
 
static int write_loop = 0
 
static int force_pack = 0
 
static int isamchk_neaded = 0
 
static int tmpfile_createflag = O_RDWR | O_TRUNC | O_EXCL
 
static bool backup
 
static bool opt_wait
 
static uint tree_buff_length = 65536 - MALLOC_OVERHEAD
 
static char tmp_dir [FN_REFLEN] = {0}
 
static char * join_table
 
static my_off_t intervall_length
 
static ha_checksum glob_crc
 
static struct st_file_buffer file_buffer
 
static QUEUE queue
 
static HUFF_COUNTSglobal_count
 
static char zero_string [] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
 
static const char * load_default_groups [] = {"myisampack", nullptr}
 
static struct my_option my_long_options []
 

Macro Definition Documentation

◆ ALLOWED_JOIN_DIFF

#define ALLOWED_JOIN_DIFF   256 /* Diff allowed to join trees */

◆ BITS_SAVED

#define BITS_SAVED   64

◆ DATA_TMP_EXT

#define DATA_TMP_EXT   ".TMD"

◆ FRM_EXT

#define FRM_EXT   ".frm"

◆ HEAD_LENGTH

#define HEAD_LENGTH   32

◆ IS_OFFSET

#define IS_OFFSET   ((uint)32768) /* Bit if offset or char in tree */

◆ OLD_EXT

#define OLD_EXT   ".OLD"

◆ WRITE_COUNT

#define WRITE_COUNT   MY_HOW_OFTEN_TO_WRITE

Enumeration Type Documentation

◆ options_mp

enum options_mp
Enumerator
OPT_CHARSETS_DIR_MP 

Function Documentation

◆ bindigits()

static char * bindigits ( ulonglong  value,
uint  bits 
)
static

◆ calc_packed_length()

static my_off_t calc_packed_length ( HUFF_COUNTS huff_counts,
uint  flag 
)
static

◆ check_counts()

static void check_counts ( HUFF_COUNTS huff_counts,
uint  trees,
my_off_t  records 
)
static

◆ compare_huff_elements()

static int compare_huff_elements ( void *  not_used,
uchar a,
uchar b 
)
static

◆ compare_tree()

static int compare_tree ( const void *  cmp_arg,
const void *  a,
const void *  b 
)
static

◆ compress()

static int compress ( PACK_MRG_INFO file,
char *  join_name 
)
static

◆ compress_isam_file()

static int compress_isam_file ( PACK_MRG_INFO file,
HUFF_COUNTS huff_counts 
)
static

◆ create_dest_frm()

static int create_dest_frm ( char *  source_table,
char *  dest_table 
)
static

Create FRM for the destination table for –join operation Copy the first table FRM as the destination table FRM file.

Doing so will help the mysql server to recognize the newly created table. See Bug#36573.

Parameters
source_tableName of the source table
dest_tableName of the destination table
Return values
0Successful copy operation
Note
We always return 0 because we don't want myisampack to report error even if the copy operation fails.

◆ end_file_buffer()

static void end_file_buffer ( void  )
static

◆ fakebigcodes()

static void fakebigcodes ( HUFF_COUNTS huff_counts,
HUFF_COUNTS end_count 
)
static

◆ flush_bits()

static void flush_bits ( void  )
static

◆ flush_buffer()

static int flush_buffer ( ulong  neaded_length)
static

◆ free_counts_and_tree_and_queue()

static void free_counts_and_tree_and_queue ( HUFF_TREE huff_trees,
uint  trees,
HUFF_COUNTS huff_counts,
uint  fields 
)
static

◆ get_one_option()

static bool get_one_option ( int  optid,
const struct my_option opt,
char *  argument 
)
static

◆ get_options()

static void get_options ( int *  argc,
char ***  argv 
)
static

◆ get_statistic()

static int get_statistic ( PACK_MRG_INFO mrg,
HUFF_COUNTS huff_counts 
)
static

◆ hexdigits()

static char * hexdigits ( ulonglong  value)
static

◆ init_file_buffer()

static void init_file_buffer ( File  file,
bool  read_buffer 
)
static

◆ init_huff_count()

static HUFF_COUNTS * init_huff_count ( MI_INFO info,
my_off_t  records 
)
static

◆ join_same_trees()

static uint join_same_trees ( HUFF_COUNTS huff_counts,
uint  trees 
)
static

◆ keycache_thread_var()

st_keycache_thread_var * keycache_thread_var ( )

◆ main()

int main ( int  argc,
char **  argv 
)

◆ make_huff_decode_table()

static int make_huff_decode_table ( HUFF_TREE huff_tree,
uint  trees 
)
static

◆ make_huff_tree()

static int make_huff_tree ( HUFF_TREE tree,
HUFF_COUNTS huff_counts 
)
static

◆ make_huff_trees()

static HUFF_TREE * make_huff_trees ( HUFF_COUNTS huff_counts,
uint  trees 
)
static

◆ make_new_name()

static char * make_new_name ( char *  new_name,
char *  old_name 
)
static

◆ make_offset_code_tree()

static uint * make_offset_code_tree ( HUFF_TREE huff_tree,
HUFF_ELEMENT element,
uint *  offset 
)
static

◆ make_old_name()

static char * make_old_name ( char *  new_name,
char *  old_name 
)
static

◆ make_traverse_code_tree()

static void make_traverse_code_tree ( HUFF_TREE huff_tree,
HUFF_ELEMENT element,
uint  size,
ulonglong  code 
)
static

◆ max_bit()

static uint max_bit ( uint  value)
static

◆ mrg_close()

static int mrg_close ( PACK_MRG_INFO mrg)
static

◆ mrg_reset()

static void mrg_reset ( PACK_MRG_INFO mrg)
static

◆ mrg_rrnd()

static int mrg_rrnd ( PACK_MRG_INFO info,
uchar buf 
)
static

◆ open_isam_file()

static MI_INFO * open_isam_file ( char *  name,
int  mode 
)
static

◆ open_isam_files()

static bool open_isam_files ( PACK_MRG_INFO mrg,
char **  names,
uint  count 
)
static

◆ save_counts_in_queue()

static int save_counts_in_queue ( void *  v_key,
element_count  count,
void *  v_tree 
)
static

◆ save_state()

static int save_state ( MI_INFO isam_file,
PACK_MRG_INFO mrg,
my_off_t  new_length,
ha_checksum  crc 
)
static

◆ save_state_mrg()

static int save_state_mrg ( File  file,
PACK_MRG_INFO isam_file,
my_off_t  new_length,
ha_checksum  crc 
)
static

◆ test_space_compress()

static int test_space_compress ( HUFF_COUNTS huff_counts,
my_off_t  records,
uint  max_space_length,
my_off_t space_counts,
my_off_t  tot_space_count,
enum en_fieldtype  field_type 
)
static

◆ usage()

static void usage ( void  )
static

◆ write_bits()

static void write_bits ( ulonglong  value,
uint  bits 
)
static

◆ write_field_info()

static void write_field_info ( HUFF_COUNTS counts,
uint  fields,
uint  trees 
)
static

◆ write_header()

static int write_header ( PACK_MRG_INFO isam_file,
uint  header_length,
uint  trees,
my_off_t  tot_elements,
my_off_t  filelength 
)
static

◆ write_huff_tree()

static my_off_t write_huff_tree ( HUFF_TREE huff_tree,
uint  trees 
)
static

Variable Documentation

◆ backup

bool backup
static

◆ error_on_write

int error_on_write = 0
static

◆ file_buffer

struct st_file_buffer file_buffer
static

◆ force_pack

int force_pack = 0
static

◆ glob_crc

ha_checksum glob_crc
static

◆ global_count

HUFF_COUNTS* global_count
static

◆ intervall_length

my_off_t intervall_length
static

◆ isamchk_neaded

int isamchk_neaded = 0
static

◆ join_table

char * join_table
static

◆ load_default_groups

const char* load_default_groups[] = {"myisampack", nullptr}
static

◆ my_long_options

struct my_option my_long_options[]
static

◆ opt_wait

bool opt_wait
static

◆ queue

QUEUE queue
static

◆ silent

int silent = 0
static

◆ test_only

int test_only = 0
static

◆ tmp_dir

char tmp_dir[FN_REFLEN] = {0}
static

◆ tmpfile_createflag

int tmpfile_createflag = O_RDWR | O_TRUNC | O_EXCL
static

◆ tree_buff_length

uint tree_buff_length = 65536 - MALLOC_OVERHEAD
static

◆ verbose

int verbose = 0
static

◆ write_loop

int write_loop = 0
static

◆ zero_string

char zero_string[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
static