sf_leaking_memory=0; /* from now on we cleanup properly */
/* Seed the random number generator if we will be using it. */ if (auto_generate_sql)
srandom((uint)time(NULL));
if (argc > 2)
{
fprintf(stderr,"%s: Too many arguments\n",my_progname);
free_defaults(defaults_argv);
my_end(0); exit(1);
}
mysql_init(&mysql);
set_mysql_connect_options(&mysql);
if (opt_plugin_dir && *opt_plugin_dir)
mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
if (opt_default_auth && *opt_default_auth)
mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
mysql_options(&mysql, MYSQL_OPT_CONNECT_ATTR_RESET, 0);
mysql_options4(&mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "program_name", "mysqlslap"); if (!opt_only_print)
{ if (!(mysql_real_connect(&mysql, host, user, opt_password,
NULL, opt_mysql_port,
opt_mysql_unix_port, connect_flags)))
{
fprintf(stderr,"%s: Error when connecting to server: %s\n",
my_progname,mysql_error(&mysql));
mysql_close(&mysql);
free_defaults(defaults_argv);
my_end(0); exit(1);
}
}
for (x= 0, sptr= head_sptr; x < iterations; x++, sptr++)
{ /* Wemightnotwanttoloadanydata,suchaswhenwearecalling astored_procedurethatdoesn'tusedata,orweknowwealreadyhave datainthetable.
*/ if (!opt_preserve)
drop_schema(mysql, create_schema_string);
/* First we create */ if (create_statements)
{ /* Ifwehavean--engineoption,thenweindicate create_schema()toaddtheenginetypetotheDDL.
*/ if (eptr)
create_statements->type= CREATE_TABLE_TYPE;
if (post_statements)
run_statements(mysql, post_statements);
if (post_system && (sysret= system(post_system)) != 0)
fprintf(stderr, "Warning: Execution of post_system option returned %d.\n",
sysret); /* We are finished with this run */ if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)
drop_primary_key_list();
}
if (verbose >= 2)
printf("Generating stats\n");
generate_stats(&conclusion, eptr, head_sptr);
if (!opt_silent)
print_conclusions(&conclusion); if (opt_csv_str)
print_conclusions_csv(&conclusion);
my_free(head_sptr);
}
PRAGMA_REENABLE_CHECK_STACK_FRAME
staticstruct my_option my_long_options[] =
{
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql", 'a', "Generate SQL where not supplied by file or command line.",
&auto_generate_sql, &auto_generate_sql, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-add-autoincrement", 0, "Add an AUTO_INCREMENT column to auto-generated tables.",
&auto_generate_sql_autoincrement, &auto_generate_sql_autoincrement, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-execute-number", 0, "Set this number to generate a set number of queries to run.",
&auto_actual_queries, &auto_actual_queries, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-guid-primary", 0, "Add GUID based primary keys to auto-generated tables.",
&auto_generate_sql_guid_primary, &auto_generate_sql_guid_primary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-load-type", 0, "Specify test load type: mixed, update, write, key, or read; default is mixed.",
(char**) &auto_generate_sql_type, (char**) &auto_generate_sql_type, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-secondary-indexes", 0, "Number of secondary indexes to add to auto-generated tables.",
&auto_generate_sql_secondary_indexes,
&auto_generate_sql_secondary_indexes, 0,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-unique-query-number", 0, "Number of unique queries to generate for automatic tests.",
&auto_generate_sql_unique_query_number,
&auto_generate_sql_unique_query_number, 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0},
{"auto-generate-sql-unique-write-number", 0, "Number of unique queries to generate for auto-generate-sql-write-number.",
&auto_generate_sql_unique_write_number,
&auto_generate_sql_unique_write_number, 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0},
{"auto-generate-sql-write-number", 0, "Number of row inserts to perform for each thread (default is 100).",
&auto_generate_sql_number, &auto_generate_sql_number, 0, GET_ULL, REQUIRED_ARG, 100, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR, "Directory for character set files.", (char **)&charsets_dir,
(char **)&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"commit", 0, "Commit records every X number of statements.",
&commit_rate, &commit_rate, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compress", 'C', "Use compression in server/client protocol.",
&opt_compress, &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"concurrency", 'c', "Number of clients to simulate for query to run.",
(char**) &concurrency_str, (char**) &concurrency_str, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"create", 0, "File or string to use create tables.",
&create_string, &create_string, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"create-schema", 0, "Schema to run tests in.",
(char**) &create_schema_string, (char**) &create_schema_string, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"csv", OPT_SLAP_CSV, "Generate CSV output to named file or to stdout if no file is named.",
NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF
{"debug", '#', "This is a non-debug version. Catch this and exit.", 0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
(char**) &default_dbug_option, (char**) &default_dbug_option, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif
{"debug-check", 0, "Check memory and open file usage at exit.",
&debug_check_flag, &debug_check_flag, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag,
&debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"default_auth", 0, "Default authentication client-side plugin to use.",
&opt_default_auth, &opt_default_auth, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"delimiter", 'F', "Delimiter to use in SQL statements supplied in file or command line.",
(char**) &delimiter, (char**) &delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"detach", 0, "Detach (close and reopen) connections after X number of requests.",
&detach_rate, &detach_rate, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"engine", 'e', "Comma separated list of storage engines to use for creating the table." " The test is run for each engine. You can also specify an option for an " "engine after a `:', like memory:max_row=2300",
&default_engine, &default_engine, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host. Defaults in the following order: " "$MARIADB_HOST, and then localhost",
&host, &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"init-command", 0, "SQL Command to execute when connecting to MariaDB server. Will " "automatically be re-executed when reconnecting.",
&opt_init_command, &opt_init_command, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"iterations", 'i', "Number of times to run the tests.", &iterations,
&iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
{"no-drop", 0, "Do not drop the schema after the test.",
&opt_no_drop, &opt_no_drop, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"number-char-cols", 'x', "Number of VARCHAR columns to create in table if specifying --auto-generate-sql.",
(char**) &num_char_cols_opt, (char**) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"number-int-cols", 'y', "Number of INT columns to create in table if specifying --auto-generate-sql.",
(char**) &num_int_cols_opt, (char**) &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"number-of-queries", 0, "Limit each client to this number of queries (this is not exact).",
&num_of_query, &num_of_query, 0,
GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"only-print", 0, "Do not connect to the databases, but instead print out what would have " "been done.",
&opt_only_print, &opt_only_print, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', "Password to use when connecting to server. If password is not given it's " "asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, #endif
{"plugin_dir", 0, "Directory for client-side plugins.",
&opt_plugin_dir, &opt_plugin_dir, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", &opt_mysql_port,
&opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0},
{"post-query", 0, "Query to run or file containing query to execute after tests have completed.",
&user_supplied_post_statements, &user_supplied_post_statements, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"post-system", 0, "system() string to execute after tests have completed.",
&post_system, &post_system, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"pre-query", 0, "Query to run or file containing query to execute before running tests.",
&user_supplied_pre_statements, &user_supplied_pre_statements, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"pre-system", 0, "system() string to execute before running tests.",
&pre_system, &pre_system, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"query", 'q', "Query to run or file containing query to run.",
&user_supplied_query, &user_supplied_query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Run program in silent mode - no output.",
&opt_silent, &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "The socket file to use for connection.",
&opt_mysql_unix_port, &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include <sslopt-longopts.h> #ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", &user,
&user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif
{"verbose", 'v', "More verbose output; you can use this multiple times to get even more " "verbose output.", &verbose, &verbose, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
staticvoid usage(void)
{
print_version();
puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2005"));
puts("Run a query multiple times against the server.\n");
printf("Usage: %s [OPTIONS]\n",my_progname);
print_defaults("my",load_default_groups);
puts("");
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(conststruct my_option *opt, constchar *argument, constchar *filename)
{
DBUG_ENTER("get_one_option"); switch(opt->id) { case'v':
verbose++; break; case'p': if (argument == disabled_my_option)
argument= (char*) ""; /* Don't require password */ if (argument)
{ /* Oneshouldnotreallychangetheargument,butwemakean exceptionforpasswords
*/ char *start= (char*) argument;
my_free(opt_password);
opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument,MYF(MY_FAE)); while (*argument)
*(char*) argument++= 'x'; /* Destroy argument */ if (*start)
start[1]= 0; /* Cut length of argument */
tty_password= 0;
} else
tty_password= 1; break; case'W': #ifdef _WIN32
opt_protocol= MYSQL_PROTOCOL_PIPE; #endif break; case OPT_MYSQL_PROTOCOL: if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
opt->name)) <= 0)
{
sf_leaking_memory= 1; /* no memory leak reports here */ exit(1);
} break; case'P': if (filename[0] == '\0')
{ /* Port given on command line, switch protocol to use TCP */
opt_protocol= MYSQL_PROTOCOL_TCP;
} break; case'S': if (filename[0] == '\0')
{ /* Socketgivenoncommandline,switchprotocoltouseSOCKETSt ExceptonWindowsif'protocol=pipe'hasbeenprovidedin theconfigfileorcommandline.
*/ if (opt_protocol != MYSQL_PROTOCOL_PIPE)
{
opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
} break; case'#':
DBUG_PUSH(argument ? argument : default_dbug_option);
debug_check_flag= 1; break; case OPT_CHARSETS_DIR:
strmake_buf(mysql_charsets_dir, argument);
charsets_dir = mysql_charsets_dir; break; case OPT_SLAP_CSV: if (!argument)
argument= (char *)"-"; /* use stdout */
opt_csv_str= argument; break; #include <sslopt-case.h> case'V':
print_version(); exit(0); break; case'?': case'I': /* Info */
usage(); exit(0);
}
DBUG_RETURN(0);
}
uint
get_random_string(char *buf)
{ char *buf_ptr= buf; int x;
DBUG_ENTER("get_random_string"); for (x= RAND_STRING_SIZE; x > 0; x--)
*buf_ptr++= ALPHANUMERICS[random() % ALPHANUMERICS_SIZE];
DBUG_RETURN((uint)(buf_ptr - buf));
}
if (auto_generate_sql_autoincrement)
{
dynstr_append(&table_string, "id serial");
if (num_int_cols || num_char_cols)
dynstr_append(&table_string, ",");
}
if (auto_generate_sql_guid_primary)
{
dynstr_append(&table_string, "id varchar(36) primary key");
if (num_int_cols || num_char_cols || auto_generate_sql_guid_primary)
dynstr_append(&table_string, ",");
}
if (auto_generate_sql_secondary_indexes)
{ unsignedint count;
for (count= 0; count < auto_generate_sql_secondary_indexes; count++)
{ if (count) /* Except for the first pass we add a comma */
dynstr_append(&table_string, ",");
if (num_char_cols) for (col_count= 1; col_count <= num_char_cols; col_count++)
{ char rand_buffer[RAND_STRING_SIZE]; int buf_len= get_random_string(rand_buffer);
dynstr_append(&insert_string, "INSERT INTO t1 VALUES (");
if (auto_generate_sql_autoincrement)
{
dynstr_append(&insert_string, "NULL");
if (num_int_cols || num_char_cols)
dynstr_append(&insert_string, ",");
}
if (auto_generate_sql_guid_primary)
{
dynstr_append(&insert_string, "uuid()");
if (num_int_cols || num_char_cols)
dynstr_append(&insert_string, ",");
}
if (auto_generate_sql_secondary_indexes)
{ unsignedint count;
for (count= 0; count < auto_generate_sql_secondary_indexes; count++)
{ if (count) /* Except for the first pass we add a comma */
dynstr_append(&insert_string, ",");
dynstr_append(&insert_string, "uuid()");
}
if (num_int_cols || num_char_cols)
dynstr_append(&insert_string, ",");
}
if (num_int_cols) for (col_count= 1; col_count <= num_int_cols; col_count++)
{ if (snprintf(buf, HUGE_STRING_LENGTH, "%ld", random()) > HUGE_STRING_LENGTH)
{
fprintf(stderr, "Memory Allocation error in creating insert\n"); exit(1);
}
dynstr_append(&insert_string, buf);
if (auto_generate_sql && (create_string || user_supplied_query))
{
fprintf(stderr, "%s: Can't use --auto-generate-sql when create and query strings are specified!\n",
my_progname); exit(1);
}
if (auto_generate_sql && auto_generate_sql_guid_primary &&
auto_generate_sql_autoincrement)
{
fprintf(stderr, "%s: Either auto-generate-sql-guid-primary or auto-generate-sql-add-autoincrement can be used!\n",
my_progname); exit(1);
}
/* Wearetestingtomakesurethatifsomeonespecifiedakeysearch thatweactuallyaddedakey!
*/ if (auto_generate_sql && auto_generate_sql_type[0] == 'k') if ( auto_generate_sql_autoincrement == FALSE &&
auto_generate_sql_guid_primary == FALSE)
{
fprintf(stderr, "%s: Can't perform key test without a primary key!\n",
my_progname); exit(1);
}
if (auto_generate_sql && num_of_query && auto_actual_queries)
{
fprintf(stderr, "%s: Either auto-generate-sql-execute-number or number-of-queries can be used!\n",
my_progname); exit(1);
}
if (opt_csv_str[0] == '-')
{
csv_file= my_fileno(stdout);
} else
{ if ((csv_file= my_open(opt_csv_str, O_CREAT|O_WRONLY|O_APPEND, MYF(0)))
== -1)
{
fprintf(stderr,"%s: Could not open csv file: %sn\n",
my_progname, opt_csv_str); exit(1);
}
}
}
if (opt_only_print)
opt_silent= TRUE;
if (num_int_cols_opt)
{
option_string *str; if(parse_option(num_int_cols_opt, &str, ',') == -1)
{
fprintf(stderr, "Invalid value specified for the option " "'number-int-cols'\n");
option_cleanup(str); return1;
}
num_int_cols= atoi(str->string); if (str->option)
num_int_cols_index= atoi(str->option);
option_cleanup(str);
}
if (num_char_cols_opt)
{
option_string *str; if(parse_option(num_char_cols_opt, &str, ',') == -1)
{
fprintf(stderr, "Invalid value specified for the option " "'number-char-cols'\n");
option_cleanup(str); return1;
}
num_char_cols= atoi(str->string); if (str->option)
num_char_cols_index= atoi(str->option); else
num_char_cols_index= 0;
option_cleanup(str);
}
if (auto_generate_sql)
{ unsignedlonglong x= 0;
statement *ptr_statement;
if (verbose >= 2)
printf("Building Create Statements for Auto\n");
create_statements= build_table_string(); /* Pre-populatetable
*/ for (ptr_statement= create_statements, x= 0;
x < auto_generate_sql_unique_write_number;
x++, ptr_statement= ptr_statement->next)
{
ptr_statement->next= build_insert_string();
}
if (verbose >= 2)
printf("Building Query Statements for Auto\n");
if (auto_generate_sql_type[0] == 'r')
{ if (verbose >= 2)
printf("Generating SELECT Statements for Auto\n");
query_statements= build_select_string(FALSE); for (ptr_statement= query_statements, x= 0;
x < auto_generate_sql_unique_query_number;
x++, ptr_statement= ptr_statement->next)
{
ptr_statement->next= build_select_string(FALSE);
}
} elseif (auto_generate_sql_type[0] == 'k')
{ if (verbose >= 2)
printf("Generating SELECT for keys Statements for Auto\n");
query_statements= build_select_string(TRUE); for (ptr_statement= query_statements, x= 0;
x < auto_generate_sql_unique_query_number;
x++, ptr_statement= ptr_statement->next)
{
ptr_statement->next= build_select_string(TRUE);
}
} elseif (auto_generate_sql_type[0] == 'w')
{ /* Wegenerateanumberofstringsincasetheengineis Archive(sincestringswhichwereidenticaloneafteranother wouldbetooeasilyoptimized).
*/ if (verbose >= 2)
printf("Generating INSERT Statements for Auto\n");
query_statements= build_insert_string(); for (ptr_statement= query_statements, x= 0;
x < auto_generate_sql_unique_query_number;
x++, ptr_statement= ptr_statement->next)
{
ptr_statement->next= build_insert_string();
}
} elseif (auto_generate_sql_type[0] == 'u')
{
query_statements= build_update_string(); for (ptr_statement= query_statements, x= 0;
x < auto_generate_sql_unique_query_number;
x++, ptr_statement= ptr_statement->next)
{
ptr_statement->next= build_update_string();
}
} else/* Mixed mode is default */
{ int coin= 0;
query_statements= build_insert_string(); /* Thislogicshouldbeextendedtodoamoremixedload, atthemomentitresultsin"everyother".
*/ for (ptr_statement= query_statements, x= 0;
x < auto_generate_sql_unique_query_number;
x++, ptr_statement= ptr_statement->next)
{ if (coin)
{
ptr_statement->next= build_insert_string();
coin= 0;
} else
{
ptr_statement->next= build_select_string(TRUE);
coin= 1;
}
}
}
} else
{ if (create_string && my_stat(create_string, &sbuf, MYF(0)))
{
File data_file; if (!MY_S_ISREG(sbuf.st_mode))
{
fprintf(stderr,"%s: Create file was not a regular file\n",
my_progname); exit(1);
} if ((data_file= my_open(create_string, O_RDWR, MYF(0))) == -1)
{
fprintf(stderr,"%s: Could not open create file\n", my_progname); exit(1);
}
tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, (size_t)sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0));
parse_delimiter(tmp_string, &create_statements, delimiter[0]);
my_free(tmp_string);
} elseif (create_string)
{
parse_delimiter(create_string, &create_statements, delimiter[0]);
}
if (user_supplied_query && my_stat(user_supplied_query, &sbuf, MYF(0)))
{
File data_file; if (!MY_S_ISREG(sbuf.st_mode))
{
fprintf(stderr,"%s: User query supplied file was not a regular file\n",
my_progname); exit(1);
} if ((data_file= my_open(user_supplied_query, O_RDWR, MYF(0))) == -1)
{
fprintf(stderr,"%s: Could not open query supplied file\n", my_progname); exit(1);
}
tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, (size_t)sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0)); if (user_supplied_query)
actual_queries= parse_delimiter(tmp_string, &query_statements,
delimiter[0]);
my_free(tmp_string);
} elseif (user_supplied_query)
{
actual_queries= parse_delimiter(user_supplied_query, &query_statements,
delimiter[0]);
}
}
if (user_supplied_pre_statements && my_stat(user_supplied_pre_statements, &sbuf, MYF(0)))
{
File data_file; if (!MY_S_ISREG(sbuf.st_mode))
{
fprintf(stderr,"%s: User query supplied file was not a regular file\n",
my_progname); exit(1);
} if ((data_file= my_open(user_supplied_pre_statements, O_RDWR, MYF(0))) == -1)
{
fprintf(stderr,"%s: Could not open query supplied file\n", my_progname); exit(1);
}
tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, (size_t)sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0)); if (user_supplied_pre_statements)
(void)parse_delimiter(tmp_string, &pre_statements,
delimiter[0]);
my_free(tmp_string);
} elseif (user_supplied_pre_statements)
{
(void)parse_delimiter(user_supplied_pre_statements,
&pre_statements,
delimiter[0]);
}
if (user_supplied_post_statements && my_stat(user_supplied_post_statements, &sbuf, MYF(0)))
{
File data_file; if (!MY_S_ISREG(sbuf.st_mode))
{
fprintf(stderr,"%s: User query supplied file was not a regular file\n",
my_progname); exit(1);
} if ((data_file= my_open(user_supplied_post_statements, O_RDWR, MYF(0))) == -1)
{
fprintf(stderr,"%s: Could not open query supplied file\n", my_progname); exit(1);
}
tmp_string= (char *)my_malloc(PSI_NOT_INSTRUMENTED, (size_t)sbuf.st_size + 1,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
my_read(data_file, (uchar*) tmp_string, (size_t)sbuf.st_size, MYF(0));
tmp_string[sbuf.st_size]= '\0';
my_close(data_file,MYF(0)); if (user_supplied_post_statements)
(void)parse_delimiter(tmp_string, &post_statements,
delimiter[0]);
my_free(tmp_string);
} elseif (user_supplied_post_statements)
{
(void)parse_delimiter(user_supplied_post_statements, &post_statements,
delimiter[0]);
}
if (verbose >= 2)
printf("Parsing engines to use.\n");
if (default_engine)
{ if(parse_option(default_engine, &engine_options, ',') == -1)
{
fprintf(stderr, "Invalid value specified for the option 'engine'\n"); return1;
}
}
if (tty_password)
opt_password= my_get_tty_password(NullS);
if (auto_generate_sql && (auto_generate_sql_number > count ))
{ /* Special case for auto create, we don't want to create tables twice */
after_create= stmt->next; goto limit_not_met;
}
pthread_mutex_lock(&sleeper_mutex);
master_wakeup= 1;
pthread_mutex_unlock(&sleeper_mutex); for (x= 0; x < concur; x++)
{ /* now you create the thread */ if (pthread_create(&mainthread, &attr, run_task,
(void *)&con) != 0)
{
fprintf(stderr,"%s: Could not create thread\n",
my_progname); exit(0);
}
thread_counter++;
}
pthread_mutex_unlock(&counter_mutex);
pthread_attr_destroy(&attr);
void
print_conclusions(conclusions *con)
{
printf("Benchmark\n"); if (con->engine)
printf("\tRunning for engine %s\n", con->engine);
printf("\tAverage number of seconds to run all queries: %ld.%03ld seconds\n",
con->avg_timing / 1000, con->avg_timing % 1000);
printf("\tMinimum number of seconds to run all queries: %ld.%03ld seconds\n",
con->min_timing / 1000, con->min_timing % 1000);
printf("\tMaximum number of seconds to run all queries: %ld.%03ld seconds\n",
con->max_timing / 1000, con->max_timing % 1000);
printf("\tNumber of clients running queries: %d\n", con->users);
printf("\tAverage number of queries per client: %llu\n", con->avg_rows);
printf("\n");
}
/* At the moment we assume uniform */
con->users= sptr->users;
con->avg_rows= sptr->rows;
/* With no next, we know it is the last element that was malloced */ for (ptr= sptr, x= 0; x < iterations; ptr++, x++)
{
con->avg_timing+= ptr->timing;
if (ptr->timing > con->max_timing)
con->max_timing= ptr->timing; if (ptr->timing < con->min_timing)
con->min_timing= ptr->timing;
}
con->avg_timing= con->avg_timing/iterations;
}
void
option_cleanup(option_string *stmt)
{
option_string *ptr, *nptr; if (!stmt) return;
int
slap_connect(MYSQL *mysql)
{ /* Connect to server */ static ulong connection_retry_sleep= 100000; /* Microseconds */ int x, connect_error= 1; for (x= 0; x < 10; x++)
{
set_mysql_connect_options(mysql); if (opt_init_command)
mysql_options(mysql, MYSQL_INIT_COMMAND, opt_init_command); if (mysql_real_connect(mysql, host, user, opt_password,
create_schema_string,
opt_mysql_port,
opt_mysql_unix_port,
connect_flags))
{ /* Connect succeeded */
connect_error= 0; break;
}
my_sleep(connection_retry_sleep);
} if (connect_error)
{
fprintf(stderr,"%s: Error when connecting to server: %d %s\n",
my_progname, mysql_errno(mysql), mysql_error(mysql)); return1;
}
return0;
}
PRAGMA_REENABLE_CHECK_STACK_FRAME
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.58Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.