MySQL 8.4.3
Source Code Documentation
mysqlslap.cc File Reference
#include "my_config.h"
#include <ctype.h>
#include <fcntl.h>
#include <mysqld_error.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/types.h>
#include "client/include/caching_sha2_passwordopt-vars.h"
#include "client/include/sslopt-vars.h"
#include "my_dir.h"
#include <sys/wait.h>
#include <sys/time.h>
#include <stdio.h>
#include "client/include/client_priv.h"
#include "compression.h"
#include "m_string.h"
#include "my_alloc.h"
#include "my_dbug.h"
#include "my_default.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_systime.h"
#include "mysql/service_mysql_alloc.h"
#include "nulls.h"
#include "print_version.h"
#include "thr_cond.h"
#include "typelib.h"
#include "welcome_copyright_notice.h"
#include "client/include/multi_factor_passwordopt-vars.h"
#include "client/include/multi_factor_passwordopt-longopts.h"
#include "client/include/caching_sha2_passwordopt-longopts.h"
#include "client/include/sslopt-longopts.h"
#include "client/include/sslopt-case.h"

Classes

struct  statement
 
struct  option_string
 
struct  stats
 
struct  thread_context
 
struct  conclusions
 

Macros

#define HUGE_STRING_LENGTH   8196
 
#define RAND_STRING_SIZE   126
 
#define SELECT_TYPE   0
 
#define UPDATE_TYPE   1
 
#define INSERT_TYPE   2
 
#define UPDATE_TYPE_REQUIRES_PREFIX   3
 
#define CREATE_TABLE_TYPE   4
 
#define SELECT_TYPE_REQUIRES_PREFIX   5
 
#define DELETE_TYPE_REQUIRES_PREFIX   6
 
#define RANDOM_FORMAT   "%ld"
 
#define ALPHANUMERICS_SIZE   (sizeof(ALPHANUMERICS) - 1)
 

Typedefs

typedef struct statement statement
 
typedef struct option_string option_string
 
typedef struct stats stats
 
typedef struct thread_context thread_context
 
typedef struct conclusions conclusions
 

Functions

static int get_options (int *argc, char ***argv)
 
void print_conclusions (conclusions *con)
 
void print_conclusions_csv (conclusions *con)
 
void generate_stats (conclusions *con, option_string *eng, stats *sptr)
 
uint parse_comma (const char *string, uint **range)
 
uint parse_delimiter (const char *script, statement **stmt, char delm)
 
int parse_option (const char *origin, option_string **stmt, char delm)
 
static int drop_schema (MYSQL *mysql, const char *db)
 
size_t get_random_string (char *buf)
 
static statementbuild_table_string (void)
 
static statementbuild_insert_string (void)
 
static statementbuild_update_string (void)
 
static statementbuild_select_string (bool key)
 
static int generate_primary_key_list (MYSQL *mysql, option_string *engine_stmt)
 
static int drop_primary_key_list (void)
 
static int create_schema (MYSQL *mysql, const char *db, statement *stmt, option_string *engine_stmt)
 
static void set_sql_mode (MYSQL *mysql)
 
static int run_scheduler (stats *sptr, statement *stmts, uint concur, ulonglong limit)
 
void * run_task (void *p)
 
void statement_cleanup (statement *stmt)
 
void option_cleanup (option_string *stmt)
 
void concurrency_loop (MYSQL *mysql, uint current, option_string *eptr)
 
static int run_statements (MYSQL *mysql, statement *stmt)
 
int slap_connect (MYSQL *mysql)
 
static int run_query (MYSQL *mysql, const char *query, size_t len)
 
static long int timedif (struct timeval a, struct timeval b)
 
int main (int argc, char **argv)
 
static void usage (void)
 
static bool get_one_option (int optid, const struct my_option *opt, char *argument)
 

Variables

uint thread_counter
 
native_mutex_t counter_mutex
 
native_cond_t count_threshold
 
uint master_wakeup
 
native_mutex_t sleeper_mutex
 
native_cond_t sleep_threshold
 
char ** primary_keys
 
unsigned long long primary_keys_number_of
 
static char * host = nullptr
 
static char * user_supplied_query = nullptr
 
static char * user_supplied_pre_statements = nullptr
 
static char * user_supplied_post_statements = nullptr
 
static char * default_engine = nullptr
 
static char * pre_system = nullptr
 
static char * post_system = nullptr
 
static char * opt_mysql_unix_port = nullptr
 
static const char * user = nullptr
 
static char * opt_plugin_dir = nullptr
 
static char * opt_default_auth = nullptr
 
static uint opt_enable_cleartext_plugin = 0
 
static bool using_opt_enable_cleartext_plugin = false
 
const char * delimiter = "\n"
 
const char * create_schema_string = "mysqlslap"
 
static bool opt_preserve = true
 
static bool opt_no_drop = false
 
static bool debug_info_flag = false
 
static bool debug_check_flag = false
 
static bool opt_only_print = false
 
static bool opt_compress = false
 
static bool opt_silent = false
 
static bool auto_generate_sql_autoincrement = false
 
static bool auto_generate_sql_guid_primary = false
 
static bool auto_generate_sql = false
 
const char * auto_generate_sql_type = "mixed"
 
static uint opt_zstd_compress_level = default_zstd_compression_level
 
static char * opt_compress_algorithm = nullptr
 
static unsigned long connect_flags
 
static int verbose
 
static uint commit_rate
 
static uint detach_rate
 
const char * num_int_cols_opt
 
const char * num_char_cols_opt
 
static unsigned int num_int_cols = 1
 
static unsigned int num_char_cols = 1
 
static unsigned int num_int_cols_index = 0
 
static unsigned int num_char_cols_index = 0
 
static unsigned int iterations
 
static uint my_end_arg = 0
 
static const char * default_charset = MYSQL_DEFAULT_CHARSET_NAME
 
static ulonglong actual_queries = 0
 
static ulonglong auto_actual_queries
 
static ulonglong auto_generate_sql_unique_write_number
 
static ulonglong auto_generate_sql_unique_query_number
 
static unsigned int auto_generate_sql_secondary_indexes
 
static ulonglong num_of_query
 
static ulonglong auto_generate_sql_number
 
static const char * sql_mode = nullptr
 
const char * concurrency_str = nullptr
 
static char * create_string
 
uint * concurrency
 
const char * default_dbug_option = "d:t:o,/tmp/mysqlslap.trace"
 
const char * opt_csv_str
 
File csv_file
 
static uint opt_protocol = 0
 
static uint opt_mysql_port = 0
 
static const char * load_default_groups [] = {"mysqlslap", "client", nullptr}
 
static option_stringengine_options = nullptr
 
static statementpre_statements = nullptr
 
static statementpost_statements = nullptr
 
static statementcreate_statements = nullptr
 
static statementquery_statements = nullptr
 
static const char ALPHANUMERICS []
 
static struct my_option my_long_options []
 

Macro Definition Documentation

◆ ALPHANUMERICS_SIZE

#define ALPHANUMERICS_SIZE   (sizeof(ALPHANUMERICS) - 1)

◆ CREATE_TABLE_TYPE

#define CREATE_TABLE_TYPE   4

◆ DELETE_TYPE_REQUIRES_PREFIX

#define DELETE_TYPE_REQUIRES_PREFIX   6

◆ HUGE_STRING_LENGTH

#define HUGE_STRING_LENGTH   8196

◆ INSERT_TYPE

#define INSERT_TYPE   2

◆ RAND_STRING_SIZE

#define RAND_STRING_SIZE   126

◆ RANDOM_FORMAT

#define RANDOM_FORMAT   "%ld"

◆ SELECT_TYPE

#define SELECT_TYPE   0

◆ SELECT_TYPE_REQUIRES_PREFIX

#define SELECT_TYPE_REQUIRES_PREFIX   5

◆ UPDATE_TYPE

#define UPDATE_TYPE   1

◆ UPDATE_TYPE_REQUIRES_PREFIX

#define UPDATE_TYPE_REQUIRES_PREFIX   3

Typedef Documentation

◆ conclusions

typedef struct conclusions conclusions

◆ option_string

typedef struct option_string option_string

◆ statement

typedef struct statement statement

◆ stats

typedef struct stats stats

◆ thread_context

Function Documentation

◆ build_insert_string()

static statement * build_insert_string ( void  )
static

◆ build_select_string()

static statement * build_select_string ( bool  key)
static

◆ build_table_string()

static statement * build_table_string ( void  )
static

◆ build_update_string()

static statement * build_update_string ( void  )
static

◆ concurrency_loop()

void concurrency_loop ( MYSQL mysql,
uint  current,
option_string eptr 
)

◆ create_schema()

static int create_schema ( MYSQL mysql,
const char *  db,
statement stmt,
option_string engine_stmt 
)
static

◆ drop_primary_key_list()

static int drop_primary_key_list ( void  )
static

◆ drop_schema()

static int drop_schema ( MYSQL mysql,
const char *  db 
)
static

◆ generate_primary_key_list()

static int generate_primary_key_list ( MYSQL mysql,
option_string engine_stmt 
)
static

◆ generate_stats()

void generate_stats ( conclusions con,
option_string eng,
stats sptr 
)

◆ get_one_option()

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

◆ get_options()

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

◆ get_random_string()

size_t get_random_string ( char *  buf)

◆ main()

int main ( int  argc,
char **  argv 
)

◆ option_cleanup()

void option_cleanup ( option_string stmt)

◆ parse_comma()

uint parse_comma ( const char *  string,
uint **  range 
)

◆ parse_delimiter()

uint parse_delimiter ( const char *  script,
statement **  stmt,
char  delm 
)

◆ parse_option()

int parse_option ( const char *  origin,
option_string **  stmt,
char  delm 
)

◆ print_conclusions()

void print_conclusions ( conclusions con)

◆ print_conclusions_csv()

void print_conclusions_csv ( conclusions con)

◆ run_query()

static int run_query ( MYSQL mysql,
const char *  query,
size_t  len 
)
static

◆ run_scheduler()

static int run_scheduler ( stats sptr,
statement stmts,
uint  concur,
ulonglong  limit 
)
static

◆ run_statements()

static int run_statements ( MYSQL mysql,
statement stmt 
)
static

◆ run_task()

void * run_task ( void *  p)

◆ set_sql_mode()

static void set_sql_mode ( MYSQL mysql)
static

◆ slap_connect()

int slap_connect ( MYSQL mysql)

◆ statement_cleanup()

void statement_cleanup ( statement stmt)

◆ timedif()

static long int timedif ( struct timeval  a,
struct timeval  b 
)
static

◆ usage()

static void usage ( void  )
static

Variable Documentation

◆ actual_queries

ulonglong actual_queries = 0
static

◆ ALPHANUMERICS

const char ALPHANUMERICS[]
static
Initial value:
=
"0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz"

◆ auto_actual_queries

ulonglong auto_actual_queries
static

◆ auto_generate_sql

bool auto_generate_sql = false
static

◆ auto_generate_sql_autoincrement

bool auto_generate_sql_autoincrement = false
static

◆ auto_generate_sql_guid_primary

bool auto_generate_sql_guid_primary = false
static

◆ auto_generate_sql_number

ulonglong auto_generate_sql_number
static

◆ auto_generate_sql_secondary_indexes

unsigned int auto_generate_sql_secondary_indexes
static

◆ auto_generate_sql_type

const char* auto_generate_sql_type = "mixed"

◆ auto_generate_sql_unique_query_number

ulonglong auto_generate_sql_unique_query_number
static

◆ auto_generate_sql_unique_write_number

ulonglong auto_generate_sql_unique_write_number
static

◆ commit_rate

uint commit_rate
static

◆ concurrency

uint* concurrency

◆ concurrency_str

const char* concurrency_str = nullptr

◆ connect_flags

unsigned long connect_flags
static
Initial value:
=
#define CLIENT_REMEMBER_OPTIONS
Don't reset the options after an unsuccessful connect.
Definition: mysql_com.h:774
#define CLIENT_MULTI_RESULTS
Enable/disable multi-results.
Definition: mysql_com.h:515
#define CLIENT_MULTI_STATEMENTS
Enable/disable multi-stmt support.
Definition: mysql_com.h:492

◆ count_threshold

native_cond_t count_threshold

◆ counter_mutex

native_mutex_t counter_mutex

◆ create_schema_string

const char* create_schema_string = "mysqlslap"

◆ create_statements

statement* create_statements = nullptr
static

◆ create_string

char* create_string
static

◆ csv_file

File csv_file

◆ debug_check_flag

bool debug_check_flag = false
static

◆ debug_info_flag

bool debug_info_flag = false
static

◆ default_charset

const char* default_charset = MYSQL_DEFAULT_CHARSET_NAME
static

◆ default_dbug_option

const char* default_dbug_option = "d:t:o,/tmp/mysqlslap.trace"

◆ default_engine

char * default_engine = nullptr
static

◆ delimiter

const char* delimiter = "\n"

◆ detach_rate

uint detach_rate
static

◆ engine_options

option_string* engine_options = nullptr
static

◆ host

char* host = nullptr
static

◆ iterations

unsigned int iterations
static

◆ load_default_groups

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

◆ master_wakeup

uint master_wakeup

◆ my_end_arg

uint my_end_arg = 0
static

◆ my_long_options

struct my_option my_long_options[]
static

◆ num_char_cols

unsigned int num_char_cols = 1
static

◆ num_char_cols_index

unsigned int num_char_cols_index = 0
static

◆ num_char_cols_opt

const char* num_char_cols_opt

◆ num_int_cols

unsigned int num_int_cols = 1
static

◆ num_int_cols_index

unsigned int num_int_cols_index = 0
static

◆ num_int_cols_opt

const char* num_int_cols_opt

◆ num_of_query

ulonglong num_of_query
static

◆ opt_compress

bool opt_compress = false
static

◆ opt_compress_algorithm

char* opt_compress_algorithm = nullptr
static

◆ opt_csv_str

const char* opt_csv_str

◆ opt_default_auth

char * opt_default_auth = nullptr
static

◆ opt_enable_cleartext_plugin

uint opt_enable_cleartext_plugin = 0
static

◆ opt_mysql_port

uint opt_mysql_port = 0
static

◆ opt_mysql_unix_port

char * opt_mysql_unix_port = nullptr
static

◆ opt_no_drop

bool opt_no_drop = false
static

◆ opt_only_print

bool opt_only_print = false
static

◆ opt_plugin_dir

char* opt_plugin_dir = nullptr
static

◆ opt_preserve

bool opt_preserve = true
static

◆ opt_protocol

uint opt_protocol = 0
static

◆ opt_silent

bool opt_silent = false
static

◆ opt_zstd_compress_level

uint opt_zstd_compress_level = default_zstd_compression_level
static

◆ post_statements

statement* post_statements = nullptr
static

◆ post_system

char * post_system = nullptr
static

◆ pre_statements

statement* pre_statements = nullptr
static

◆ pre_system

char * pre_system = nullptr
static

◆ primary_keys

char** primary_keys

◆ primary_keys_number_of

unsigned long long primary_keys_number_of

◆ query_statements

statement * query_statements = nullptr
static

◆ sleep_threshold

native_cond_t sleep_threshold

◆ sleeper_mutex

native_mutex_t sleeper_mutex

◆ sql_mode

const char* sql_mode = nullptr
static

◆ thread_counter

uint thread_counter

◆ user

const char* user = nullptr
static

◆ user_supplied_post_statements

char * user_supplied_post_statements = nullptr
static

◆ user_supplied_pre_statements

char * user_supplied_pre_statements = nullptr
static

◆ user_supplied_query

char * user_supplied_query = nullptr
static

◆ using_opt_enable_cleartext_plugin

bool using_opt_enable_cleartext_plugin = false
static

◆ verbose

int verbose
static