summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/client_priv.h1
-rw-r--r--client/get_password.c4
-rw-r--r--client/mysql.cc125
-rw-r--r--client/mysql_upgrade.c10
-rw-r--r--client/mysqladmin.cc4
-rw-r--r--client/mysqlbinlog.cc4
-rw-r--r--client/mysqlcheck.c3
-rw-r--r--client/mysqlslap.c153
-rw-r--r--client/mysqltest.cc248
9 files changed, 350 insertions, 202 deletions
diff --git a/client/client_priv.h b/client/client_priv.h
index 689f7277c2e..6a23af23594 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -89,6 +89,7 @@ enum options_client
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
OPT_WRITE_BINLOG, OPT_DUMP_DATE,
+ OPT_ABORT_SOURCE_ON_ERROR,
OPT_FIRST_SLAVE,
OPT_ALL,
OPT_MAX_CLIENT_OPTION
diff --git a/client/get_password.c b/client/get_password.c
index ea024f76fb6..c6653183f48 100644
--- a/client/get_password.c
+++ b/client/get_password.c
@@ -113,7 +113,7 @@ static void get_password(char *to,uint length,int fd, my_bool echo)
for (;;)
{
- char tmp;
+ uchar tmp;
if (my_read(fd,&tmp,1,MYF(0)) != 1)
break;
if (tmp == '\b' || (int) tmp == 127)
@@ -138,7 +138,7 @@ static void get_password(char *to,uint length,int fd, my_bool echo)
fputc('*',stderr);
fflush(stderr);
}
- *(pos++) = tmp;
+ *(pos++)= (char) tmp;
}
while (pos != to && isspace(pos[-1]) == ' ')
pos--; /* Allow dummy space at end */
diff --git a/client/mysql.cc b/client/mysql.cc
index 82a29816b8e..6203e51d73e 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2008 MySQL AB
+/* Copyright (C) 2000-2009 MySQL AB & Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -43,7 +43,7 @@
#include <locale.h>
#endif
-const char *VER= "14.14";
+const char *VER= "14.16";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
@@ -86,7 +86,7 @@ extern "C" {
#include <term.h>
#endif
#endif
-#endif
+#endif /* defined(HAVE_CURSES_H) && defined(HAVE_TERM_H) */
#undef bcmp // Fix problem with new readline
#if defined(__WIN__)
@@ -95,7 +95,6 @@ extern "C" {
#include <readline/readline.h>
#define HAVE_READLINE
#endif
- //int vidattr(long unsigned int attrs); // Was missing in sun curses
}
#if !defined(HAVE_VIDATTR)
@@ -148,7 +147,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
default_pager_set= 0, opt_sigint_ignore= 0,
show_warnings= 0, executing_query= 0, interrupted_query= 0,
ignore_spaces= 0;
-static my_bool debug_info_flag, debug_check_flag;
+static my_bool debug_info_flag, debug_check_flag, batch_abort_on_error;
static my_bool column_types_flag;
static my_bool preserve_comments= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
@@ -1027,7 +1026,7 @@ static const char *load_default_groups[]= { "mysql","client",0 };
static int embedded_server_arg_count= 0;
static char *embedded_server_args[MAX_SERVER_ARGS];
static const char *embedded_server_groups[]=
-{ "server", "embedded", "mysql_SERVER", 0 };
+{ "server", "embedded", "mysql_SERVER", "mariadb_SERVER", 0 };
#ifdef HAVE_READLINE
/*
@@ -1079,7 +1078,7 @@ int main(int argc,char *argv[])
delimiter_str= delimiter;
default_prompt = my_strdup(getenv("MYSQL_PS1") ?
getenv("MYSQL_PS1") :
- "mysql> ",MYF(MY_WME));
+ "\\N [\\d]> ",MYF(MY_WME));
current_prompt = my_strdup(default_prompt,MYF(MY_WME));
prompt_counter=0;
@@ -1159,10 +1158,11 @@ int main(int argc,char *argv[])
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
- put_info("Welcome to the MySQL monitor. Commands end with ; or \\g.",
+ put_info("Welcome to the MariaDB monitor. Commands end with ; or \\g.",
INFO_INFO);
sprintf((char*) glob_buffer.ptr(),
- "Your MySQL connection id is %lu\nServer version: %s\n",
+ "Your %s connection id is %lu\nServer version: %s\n",
+ mysql_get_server_name(&mysql),
mysql_thread_id(&mysql), server_version_string(&mysql));
put_info((char*) glob_buffer.ptr(),INFO_INFO);
@@ -1283,7 +1283,6 @@ sig_handler handle_sigint(int sig)
MYSQL *kill_mysql= NULL;
/* terminate if no query being executed, or we already tried interrupting */
- /* terminate if no query being executed, or we already tried interrupting */
if (!executing_query || (interrupted_query == 2))
{
tee_fprintf(stdout, "Ctrl-C -- exit!\n");
@@ -1298,6 +1297,7 @@ sig_handler handle_sigint(int sig)
goto err;
}
+ /* First time try to kill the query, second time the connection */
interrupted_query++;
/* mysqld < 5 does not understand KILL QUERY, skip to KILL CONNECTION */
@@ -1308,10 +1308,13 @@ sig_handler handle_sigint(int sig)
sprintf(kill_buffer, "KILL %s%lu",
(interrupted_query == 1) ? "QUERY " : "",
mysql_thread_id(&mysql));
- tee_fprintf(stdout, "Ctrl-C -- sending \"%s\" to server ...\n", kill_buffer);
+ if (verbose)
+ tee_fprintf(stdout, "Ctrl-C -- sending \"%s\" to server ...\n",
+ kill_buffer);
mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer));
mysql_close(kill_mysql);
- tee_fprintf(stdout, "Ctrl-C -- query aborted.\n");
+ tee_fprintf(stdout, "Ctrl-C -- query killed. Continuing normally.\n");
+ interrupted_query= 0;
return;
@@ -1324,7 +1327,6 @@ err:
handler called mysql_end().
*/
mysql_thread_end();
- return;
#else
mysql_end(sig);
#endif
@@ -1337,6 +1339,10 @@ static struct my_option my_long_options[] =
0, 0, 0, 0, 0},
{"help", 'I', "Synonym for -?", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0},
+ {"abort-source-on-error", OPT_ABORT_SOURCE_ON_ERROR,
+ "Abort 'source filename' operations in case of errors",
+ (uchar**) &batch_abort_on_error, (uchar**) &batch_abort_on_error, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __NETWARE__
{"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -1388,7 +1394,7 @@ static struct my_option my_long_options[] =
{"vertical", 'E', "Print the output of a query (rows) vertically.",
(uchar**) &vertical, (uchar**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0},
- {"force", 'f', "Continue even if we get an sql error.",
+ {"force", 'f', "Continue even if we get an sql error. Sets abort-source-on-error to 0",
(uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0},
{"named-commands", 'G',
@@ -1754,6 +1760,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#endif
break;
#include <sslopt-case.h>
+ case 'f':
+ batch_abort_on_error= 0;
+ break;
case 'V':
usage(1);
exit(0);
@@ -2024,12 +2033,12 @@ static COMMANDS *find_command(char *name,char cmd_char)
for (uint i= 0; commands[i].name; i++)
{
if (commands[i].func &&
- ((name &&
- !my_strnncoll(&my_charset_latin1, (uchar*)name, len,
- (uchar*)commands[i].name,len) &&
- !commands[i].name[len] &&
- (!end || (end && commands[i].takes_params))) ||
- (!name && commands[i].cmd_char == cmd_char)))
+ (((name &&
+ !my_strnncoll(&my_charset_latin1, (uchar*) name, len,
+ (uchar*) commands[i].name, len) &&
+ !commands[i].name[len] &&
+ (!end || (end && commands[i].takes_params)))) ||
+ (!name && commands[i].cmd_char == cmd_char)))
{
DBUG_PRINT("exit",("found command: %s", commands[i].name));
DBUG_RETURN(&commands[i]);
@@ -2187,16 +2196,18 @@ static bool add_line(String &buffer,char *line,char *in_string,
}
buffer.length(0);
}
- else if (!*ml_comment && (!*in_string && (inchar == '#' ||
- (inchar == '-' && pos[1] == '-' &&
- /*
- The third byte is either whitespace or is the
- end of the line -- which would occur only
- because of the user sending newline -- which is
- itself whitespace and should also match.
- */
- (my_isspace(charset_info,pos[2]) ||
- !pos[2])))))
+ else if (!*ml_comment &&
+ (!*in_string &&
+ (inchar == '#' ||
+ (inchar == '-' && pos[1] == '-' &&
+ /*
+ The third byte is either whitespace or is the end of
+ the line -- which would occur only because of the
+ user sending newline -- which is itself whitespace
+ and should also match.
+ */
+ (my_isspace(charset_info,pos[2]) ||
+ !pos[2])))))
{
// Flush previously accepted characters
if (out != line)
@@ -2881,13 +2892,8 @@ com_help(String *buffer __attribute__((unused)),
return com_server_help(buffer,line,help_arg);
}
- put_info("\nFor information about MySQL products and services, visit:\n"
- " http://www.mysql.com/\n"
- "For developer information, including the MySQL Reference Manual, "
- "visit:\n"
- " http://dev.mysql.com/\n"
- "To buy MySQL Enterprise support, training, or other products, visit:\n"
- " https://shop.mysql.com/\n", INFO_INFO);
+ put_info("\nGeneral information about MariaDB can be found at\n"
+ "http://askmonty.org/wiki/index.php/Manual:Contents\n", INFO_INFO);
put_info("List of all MySQL commands:", INFO_INFO);
if (!named_cmds)
put_info("Note that all text commands must be first on line and end with ';'",INFO_INFO);
@@ -3826,8 +3832,9 @@ static int
com_edit(String *buffer,char *line __attribute__((unused)))
{
char filename[FN_REFLEN],buff[160];
- int fd,tmp;
+ int fd,tmp,error;
const char *editor;
+ MY_STAT stat_arg;
if ((fd=create_temp_file(filename,NullS,"sql", O_CREAT | O_WRONLY,
MYF(MY_WME))) < 0)
@@ -3843,10 +3850,14 @@ com_edit(String *buffer,char *line __attribute__((unused)))
!(editor = (char *)getenv("VISUAL")))
editor = "vi";
strxmov(buff,editor," ",filename,NullS);
- if(system(buff) == -1)
+ if ((error= system(buff)))
+ {
+ char errmsg[100];
+ sprintf(errmsg, "Command '%.40s' failed", buff);
+ put_info(errmsg, INFO_ERROR, 0, NullS);
goto err;
+ }
- MY_STAT stat_arg;
if (!my_stat(filename,&stat_arg,MYF(MY_WME)))
goto err;
if ((fd = my_open(filename,O_RDONLY, MYF(MY_WME))) < 0)
@@ -3988,6 +3999,7 @@ static int com_source(String *buffer, char *line)
int error;
STATUS old_status;
FILE *sql_file;
+ my_bool save_ignore_errors;
/* Skip space from file name */
while (my_isspace(charset_info,*line))
@@ -4019,16 +4031,25 @@ static int com_source(String *buffer, char *line)
/* Save old status */
old_status=status;
+ save_ignore_errors= ignore_errors;
bfill((char*) &status,sizeof(status),(char) 0);
status.batch=old_status.batch; // Run in batch mode
status.line_buff=line_buff;
status.file_name=source_name;
glob_buffer.length(0); // Empty command buffer
+ ignore_errors= !batch_abort_on_error;
error= read_and_execute(false);
+ ignore_errors= save_ignore_errors;
status=old_status; // Continue as before
my_fclose(sql_file,MYF(0));
batch_readline_end(line_buff);
+ /*
+ If we got an error during source operation, don't abort the client
+ if ignore_errors is set
+ */
+ if (error && batch_abort_on_error && ignore_errors)
+ error= -1;
return error;
}
@@ -4375,6 +4396,7 @@ com_status(String *buffer __attribute__((unused)),
tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile : "");
#endif
tee_fprintf(stdout, "Using delimiter:\t%s\n", delimiter);
+ tee_fprintf(stdout, "Server:\t\t\t%s\n", mysql_get_server_name(&mysql));
tee_fprintf(stdout, "Server version:\t\t%s\n", server_version_string(&mysql));
tee_fprintf(stdout, "Protocol version:\t%d\n", mysql_get_proto_info(&mysql));
tee_fprintf(stdout, "Connection:\t\t%s\n", mysql_get_host_info(&mysql));
@@ -4543,12 +4565,19 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
if (error)
{
if (sqlstate)
- (void) tee_fprintf(file, "ERROR %d (%s): ", error, sqlstate);
+ (void) tee_fprintf(file, "ERROR %d (%s)", error, sqlstate);
else
- (void) tee_fprintf(file, "ERROR %d: ", error);
+ (void) tee_fprintf(file, "ERROR %d", error);
}
else
- tee_puts("ERROR: ", file);
+ tee_fputs("ERROR", file);
+ if (status.query_start_line && line_numbers)
+ {
+ (void) fprintf(file," at line %lu",status.query_start_line);
+ if (status.file_name)
+ (void) fprintf(file," in file: '%s'", status.file_name);
+ }
+ tee_fputs(": ", file);
}
else
vidattr(A_BOLD);
@@ -4557,7 +4586,7 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
}
if (unbuffered)
fflush(file);
- return info_type == INFO_ERROR ? -1 : 0;
+ return info_type == INFO_ERROR ? (ignore_errors ? -1 : 1): 0;
}
@@ -4697,7 +4726,7 @@ static void mysql_end_timer(ulong start_time,char *buff)
strmov(strend(buff),")");
}
-static const char* construct_prompt()
+static const char *construct_prompt()
{
processed_prompt.free(); // Erase the old prompt
time_t lclock = time(NULL); // Get the date struct
@@ -4726,6 +4755,12 @@ static const char* construct_prompt()
case 'd':
processed_prompt.append(current_db ? current_db : "(none)");
break;
+ case 'N':
+ if (connected)
+ processed_prompt.append(mysql_get_server_name(&mysql));
+ else
+ processed_prompt.append("unknown");
+ break;
case 'h':
{
const char *prompt;
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 81dcdaa71f1..24a006ce232 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -577,7 +577,6 @@ static int upgrade_already_done(void)
FILE *in;
char upgrade_info_file[FN_REFLEN]= {0};
char buf[sizeof(MYSQL_SERVER_VERSION)+1];
- char *res;
if (get_upgrade_info_file_name(upgrade_info_file))
return 0; /* Could not get filename => not sure */
@@ -585,12 +584,11 @@ static int upgrade_already_done(void)
if (!(in= my_fopen(upgrade_info_file, O_RDONLY, MYF(0))))
return 0; /* Could not open file => not sure */
- /*
- Read from file, don't care if it fails since it
- will be detected by the strncmp
- */
bzero(buf, sizeof(buf));
- res= fgets(buf, sizeof(buf), in);
+ if (!fgets(buf, sizeof(buf), in))
+ {
+ /* Ignore, will be detected by strncmp() below */
+ }
my_fclose(in, MYF(0));
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 04e25fcf1ff..015b81803f2 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -586,7 +586,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
If this behaviour is ever changed, Docs should be notified.
*/
- struct rand_struct rand_st;
+ struct my_rnd_struct rand_st;
for (; argc > 0 ; argv++,argc--)
{
@@ -906,7 +906,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
time_t start_time;
/* Do initialization the same way as we do in mysqld */
start_time=time((time_t*) 0);
- randominit(&rand_st,(ulong) start_time,(ulong) start_time/2);
+ my_rnd_init(&rand_st,(ulong) start_time,(ulong) start_time/2);
if (argc < 2)
{
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 1c0f6e5f96a..5ee34ca233e 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -1382,6 +1382,10 @@ static int parse_args(int *argc, char*** argv)
*/
static Exit_status safe_connect()
{
+ /* Close and old connections to MySQL */
+ if (mysql)
+ mysql_close(mysql);
+
mysql= mysql_init(NULL);
if (!mysql)
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 1533e602639..1a834e98035 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -857,7 +857,8 @@ int main(int argc, char **argv)
if (!opt_write_binlog)
{
- if (disable_binlog()) {
+ if (disable_binlog())
+ {
first_error= 1;
goto end;
}
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 5983b911866..c9c7e057202 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -292,6 +292,25 @@ static int gettimeofday(struct timeval *tp, void *tzp)
}
#endif
+void set_mysql_connect_options(MYSQL *mysql)
+{
+ if (opt_compress)
+ mysql_options(mysql,MYSQL_OPT_COMPRESS,NullS);
+#ifdef HAVE_OPENSSL
+ if (opt_use_ssl)
+ mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
+ opt_ssl_capath, opt_ssl_cipher);
+#endif
+ if (opt_protocol)
+ mysql_options(mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+#ifdef HAVE_SMEM
+ if (shared_memory_base_name)
+ mysql_options(mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
+#endif
+ mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset);
+}
+
+
int main(int argc, char **argv)
{
MYSQL mysql;
@@ -323,20 +342,7 @@ int main(int argc, char **argv)
exit(1);
}
mysql_init(&mysql);
- if (opt_compress)
- mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
-#ifdef HAVE_OPENSSL
- if (opt_use_ssl)
- mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
- opt_ssl_capath, opt_ssl_cipher);
-#endif
- if (opt_protocol)
- mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
-#ifdef HAVE_SMEM
- if (shared_memory_base_name)
- mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
-#endif
- mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
+ set_mysql_connect_options(&mysql);
if (!opt_only_print)
{
@@ -449,7 +455,16 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
/* First we create */
if (create_statements)
+ {
+ /*
+ If we have an --engine option, then we indicate
+ create_schema() to add the engine type to the DDL.
+ */
+ if (eptr)
+ create_statements->type= CREATE_TABLE_TYPE;
+
create_schema(mysql, create_schema_string, create_statements, eptr);
+ }
/*
If we generated GUID we need to build a list of them from creation that
@@ -463,10 +478,10 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
if (commit_rate)
run_query(mysql, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
- if (pre_system)
- if ((sysret= system(pre_system)) != 0)
- fprintf(stderr, "Warning: Execution of pre_system option returned %d.\n",
- sysret);
+ if (pre_system && (sysret= system(pre_system)) != 0)
+ fprintf(stderr,
+ "Warning: Execution of pre_system option returned %d.\n",
+ sysret);
/*
Pre statements are always run after all other logic so they can
@@ -480,11 +495,10 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
if (post_statements)
run_statements(mysql, post_statements);
- if (post_system)
- if ((sysret= system(post_system)) != 0)
- fprintf(stderr, "Warning: Execution of post_system option returned %d.\n",
- sysret);
-
+ 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();
@@ -592,7 +606,9 @@ static struct my_option my_long_options[] =
"Detach (close and reopen) connections after X number of requests.",
(uchar**) &detach_rate, (uchar**) &detach_rate, 0, GET_UINT, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
- {"engine", 'e', "Storage engine to use for creating the table.",
+ {"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",
(uchar**) &default_engine, (uchar**) &default_engine, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (uchar**) &host, (uchar**) &host, 0, GET_STR,
@@ -969,6 +985,7 @@ build_update_string(void)
ptr->type= UPDATE_TYPE_REQUIRES_PREFIX ;
else
ptr->type= UPDATE_TYPE;
+
strmov(ptr->string, update_string.str);
dynstr_free(&update_string);
DBUG_RETURN(ptr);
@@ -984,8 +1001,8 @@ build_update_string(void)
static statement *
build_insert_string(void)
{
- char buf[HUGE_STRING_LENGTH];
- unsigned int col_count;
+ char buf[HUGE_STRING_LENGTH];
+ unsigned int col_count;
statement *ptr;
DYNAMIC_STRING insert_string;
DBUG_ENTER("build_insert_string");
@@ -1075,8 +1092,8 @@ build_insert_string(void)
static statement *
build_select_string(my_bool key)
{
- char buf[HUGE_STRING_LENGTH];
- unsigned int col_count;
+ char buf[HUGE_STRING_LENGTH];
+ unsigned int col_count;
statement *ptr;
static DYNAMIC_STRING query_string;
DBUG_ENTER("build_select_string");
@@ -1128,6 +1145,7 @@ build_select_string(my_bool key)
ptr->type= SELECT_TYPE_REQUIRES_PREFIX;
else
ptr->type= SELECT_TYPE;
+
strmov(ptr->string, query_string.str);
dynstr_free(&query_string);
DBUG_RETURN(ptr);
@@ -1186,8 +1204,6 @@ get_options(int *argc,char ***argv)
exit(1);
}
-
-
if (auto_generate_sql && num_of_query && auto_actual_queries)
{
fprintf(stderr,
@@ -1228,6 +1244,7 @@ get_options(int *argc,char ***argv)
num_int_cols= atoi(str->string);
if (str->option)
num_int_cols_index= atoi(str->option);
+
option_cleanup(str);
}
@@ -1240,6 +1257,7 @@ get_options(int *argc,char ***argv)
num_char_cols_index= atoi(str->option);
else
num_char_cols_index= 0;
+
option_cleanup(str);
}
@@ -1474,6 +1492,7 @@ get_options(int *argc,char ***argv)
if (tty_password)
opt_password= get_tty_password(NullS);
+
DBUG_RETURN(0);
}
@@ -1488,6 +1507,7 @@ static int run_query(MYSQL *mysql, const char *query, int len)
if (verbose >= 3)
printf("%.*s;\n", len, query);
+
return mysql_real_query(mysql, query, len);
}
@@ -1603,18 +1623,6 @@ create_schema(MYSQL *mysql, const char *db, statement *stmt,
}
}
- if (engine_stmt)
- {
- len= snprintf(query, HUGE_STRING_LENGTH, "set storage_engine=`%s`",
- engine_stmt->string);
- if (run_query(mysql, query, len))
- {
- fprintf(stderr,"%s: Cannot set default engine: %s\n", my_progname,
- mysql_error(mysql));
- exit(1);
- }
- }
-
count= 0;
after_create= stmt;
@@ -1628,8 +1636,21 @@ limit_not_met:
{
char buffer[HUGE_STRING_LENGTH];
- snprintf(buffer, HUGE_STRING_LENGTH, "%s %s", ptr->string,
- engine_stmt->option);
+ snprintf(buffer, HUGE_STRING_LENGTH, "%s Engine = %s %s",
+ ptr->string, engine_stmt->string, engine_stmt->option);
+ if (run_query(mysql, buffer, strlen(buffer)))
+ {
+ fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
+ my_progname, (uint)ptr->length, ptr->string, mysql_error(mysql));
+ exit(1);
+ }
+ }
+ else if (engine_stmt && engine_stmt->string && ptr->type == CREATE_TABLE_TYPE)
+ {
+ char buffer[HUGE_STRING_LENGTH];
+
+ snprintf(buffer, HUGE_STRING_LENGTH, "%s Engine = %s",
+ ptr->string, engine_stmt->string);
if (run_query(mysql, buffer, strlen(buffer)))
{
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
@@ -1663,6 +1684,7 @@ drop_schema(MYSQL *mysql, const char *db)
{
char query[HUGE_STRING_LENGTH];
int len;
+
DBUG_ENTER("drop_schema");
len= snprintf(query, HUGE_STRING_LENGTH, "DROP SCHEMA IF EXISTS `%s`", db);
@@ -1799,6 +1821,7 @@ pthread_handler_t run_task(void *p)
my_progname, mysql_error(mysql));
exit(0);
}
+ set_mysql_connect_options(mysql);
if (mysql_thread_init())
{
@@ -1839,7 +1862,6 @@ limit_not_met:
my_progname, mysql_error(mysql));
exit(0);
}
-
if (slap_connect(mysql))
goto end;
}
@@ -1895,10 +1917,17 @@ limit_not_met:
{
if (mysql_field_count(mysql))
{
- result= mysql_store_result(mysql);
- while ((row = mysql_fetch_row(result)))
- counter++;
- mysql_free_result(result);
+ if ((result= mysql_store_result(mysql)))
+ {
+ while ((row = mysql_fetch_row(result)))
+ counter++;
+ mysql_free_result(result);
+ }
+ else
+ {
+ fprintf(stderr,"%s: Error in mysql_store_result(): %d %s\n",
+ my_progname, mysql_errno(mysql), mysql_error(mysql));
+ }
}
} while(mysql_next_result(mysql) == 0);
queries++;
@@ -1944,17 +1973,27 @@ parse_option(const char *origin, option_string **stmt, char delm)
uint count= 0; /* We know that there is always one */
for (tmp= *sptr= (option_string *)my_malloc(sizeof(option_string),
- MYF(MY_ZEROFILL|MY_FAE|MY_WME));
+ MYF(MY_ZEROFILL|MY_FAE|MY_WME));
(retstr= strchr(ptr, delm));
tmp->next= (option_string *)my_malloc(sizeof(option_string),
- MYF(MY_ZEROFILL|MY_FAE|MY_WME)),
+ MYF(MY_ZEROFILL|MY_FAE|MY_WME)),
tmp= tmp->next)
{
- char buffer[HUGE_STRING_LENGTH];
+ /*
+ Initialize buffer, because otherwise an
+ --engine=<storage_engine>:<option>,<eng1>,<eng2>
+ will crash.
+ */
+ char buffer[HUGE_STRING_LENGTH]= "";
char *buffer_ptr;
count++;
strncpy(buffer, ptr, (size_t)(retstr - ptr));
+ /*
+ Handle --engine=memory:max_row=200 cases, or more general speaking
+ --engine=<storage_engine>:<options>, which will be translated to
+ Engine = storage_engine option.
+ */
if ((buffer_ptr= strchr(buffer, ':')))
{
char *option_ptr;
@@ -1975,13 +2014,15 @@ parse_option(const char *origin, option_string **stmt, char delm)
tmp->length= (size_t)(retstr - ptr);
}
+ /* Skip delimiter delm */
ptr+= retstr - ptr + 1;
if (isspace(*ptr))
ptr++;
+
count++;
}
- if (ptr != origin+length)
+ if (ptr != origin + length)
{
char *origin_ptr;
@@ -1990,7 +2031,7 @@ parse_option(const char *origin, option_string **stmt, char delm)
char *option_ptr;
tmp->length= (size_t)(origin_ptr - ptr);
- tmp->string= my_strndup(origin, tmp->length, MYF(MY_FAE));
+ tmp->string= my_strndup(ptr, tmp->length, MYF(MY_FAE));
option_ptr= (char *)ptr + 1 + tmp->length;
@@ -2040,7 +2081,7 @@ parse_delimiter(const char *script, statement **stmt, char delm)
if (ptr != script+length)
{
tmp->string= my_strndup(ptr, (uint)((script + length) - ptr),
- MYF(MY_FAE));
+ MYF(MY_FAE));
tmp->length= (size_t)((script + length) - ptr);
count++;
}
@@ -2098,6 +2139,7 @@ print_conclusions_csv(conclusions *con)
{
char buffer[HUGE_STRING_LENGTH];
const char *ptr= auto_generate_sql_type ? auto_generate_sql_type : "query";
+
snprintf(buffer, HUGE_STRING_LENGTH,
"%s,%s,%ld.%03ld,%ld.%03ld,%ld.%03ld,%d,%llu\n",
con->engine ? con->engine : "", /* Storage engine we ran against */
@@ -2187,6 +2229,7 @@ slap_connect(MYSQL *mysql)
int x, connect_error= 1;
for (x= 0; x < 10; x++)
{
+ set_mysql_connect_options(mysql);
if (mysql_real_connect(mysql, host, user, opt_password,
create_schema_string,
opt_mysql_port,
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index e0cdec42a60..891dd72edfa 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -75,7 +75,8 @@
enum {
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
- OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES
+ OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES,
+ OPT_GLOBAL_SUBST, OPT_MY_CONNECT_TIMEOUT
};
static int record= 0, opt_sleep= -1;
@@ -89,6 +90,7 @@ const char *opt_include= 0, *opt_charsets_dir;
static int opt_port= 0;
static int opt_max_connect_retries;
static my_bool opt_compress= 0, silent= 0, verbose= 0;
+static int opt_connect_timeout= -1;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static my_bool tty_password= 0;
static my_bool opt_mark_progress= 0;
@@ -101,6 +103,7 @@ static my_bool display_result_vertically= FALSE,
display_metadata= FALSE, display_result_sorted= FALSE;
static my_bool disable_query_log= 0, disable_result_log= 0;
static my_bool disable_warnings= 0;
+static my_bool prepare_warnings_enabled= 0;
static my_bool disable_info= 1;
static my_bool abort_on_error= 1;
static my_bool server_initialized= 0;
@@ -119,6 +122,9 @@ static char delimiter[MAX_DELIMITER_LENGTH]= ";";
static uint delimiter_length= 1;
static char TMPDIR[FN_REFLEN];
+static char global_subst_from[200];
+static char global_subst_to[200];
+static char *global_subst= NULL;
/* Block stack */
enum block_cmd {
@@ -184,6 +190,10 @@ static void init_re(void);
static int match_re(my_regex_t *, char *);
static void free_re(void);
+static int replace(DYNAMIC_STRING *ds_str,
+ const char *search_str, ulong search_len,
+ const char *replace_str, ulong replace_len);
+
DYNAMIC_ARRAY q_lines;
#include "sslopt-vars.h"
@@ -283,7 +293,7 @@ enum enum_commands {
Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR,
Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
- Q_MOVE_FILE,
+ Q_MOVE_FILE, Q_ENABLE_PREPARE_WARNINGS, Q_DISABLE_PREPARE_WARNINGS,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
@@ -381,6 +391,8 @@ const char *command_names[]=
"send_shutdown",
"shutdown_server",
"move_file",
+ "enable_prepare_warnings",
+ "disable_prepare_warnings",
0
};
@@ -645,7 +657,9 @@ public:
}
while ((bytes= fread(buf, 1, sizeof(buf), m_file)) > 0)
- fwrite(buf, 1, bytes, stderr);
+ if (fwrite(buf, 1, bytes, stderr))
+ die("Failed to write to '%s', errno: %d",
+ m_file_name, errno);
if (!lines)
{
@@ -1255,6 +1269,7 @@ void abort_not_supported_test(const char *fmt, ...)
DBUG_ENTER("abort_not_supported_test");
/* Print include filestack */
+ fflush(stdout);
fprintf(stderr, "The test '%s' is not supported by this installation\n",
file_stack->file_name);
fprintf(stderr, "Detected in file %s at line %d\n",
@@ -1645,49 +1660,69 @@ enum compare_files_result_enum {
*/
-int compare_files2(File fd, const char* filename2)
+int compare_files2(File fd1, const char* filename2)
{
int error= RESULT_OK;
File fd2;
- size_t len, len2;
- char buff[512], buff2[512];
+ size_t fd1_length, fd2_length;
+ DYNAMIC_STRING fd1_result, fd2_result;
if ((fd2= my_open(filename2, O_RDONLY, MYF(0))) < 0)
{
- my_close(fd, MYF(0));
+ my_close(fd1, MYF(0));
die("Failed to open second file: '%s'", filename2);
}
- while((len= my_read(fd, (uchar*)&buff,
- sizeof(buff), MYF(0))) > 0)
- {
- if ((len2= my_read(fd2, (uchar*)&buff2,
- sizeof(buff2), MYF(0))) < len)
- {
- /* File 2 was smaller */
- error= RESULT_LENGTH_MISMATCH;
- break;
- }
- if (len2 > len)
- {
- /* File 1 was smaller */
- error= RESULT_LENGTH_MISMATCH;
- break;
- }
- if ((memcmp(buff, buff2, len)))
- {
- /* Content of this part differed */
- error= RESULT_CONTENT_MISMATCH;
- break;
- }
+
+ fd1_length= (size_t) my_seek(fd1, 0, SEEK_END, MYF(0));
+ fd2_length= (size_t) my_seek(fd2, 0, SEEK_END, MYF(0));
+
+ if (init_dynamic_string(&fd1_result, 0, fd1_length, 0) ||
+ init_dynamic_string(&fd2_result, 0, fd2_length, 0))
+ die("Out of memory when allocating data for result");
+
+ fd1_result.length= fd1_length;
+ fd2_result.length= fd2_length;
+
+ (void) my_seek(fd1, 0, SEEK_SET, MYF(0));
+ (void) my_seek(fd2, 0, SEEK_SET, MYF(0));
+ if (my_read(fd1, (uchar*) fd1_result.str, fd1_length, MYF(MY_WME | MY_NABP)))
+ die("Error when reading data from result file");
+ if (my_read(fd2, (uchar*) fd2_result.str, fd2_length, MYF(MY_WME | MY_NABP)))
+ die("Error when reading data from result file");
+
+ if (global_subst &&
+ (fd1_length != fd2_length ||
+ memcmp(fd1_result.str, fd2_result.str, fd1_length)))
+ {
+ /**
+ @todo MARIA_HACK
+ This serves for when a test is run with --default-storage-engine=X
+ where X is not MyISAM: tests using SHOW CREATE TABLE will always fail
+ because SHOW CREATE TABLE prints X instead of MyISAM. With
+ --global-subst=X,MyISAM , such trivial differences are eliminated and
+ test may be reported as passing.
+ --global-subst is only a quick way to run a lot of existing tests
+ with Maria and find bugs; it is not good enough for reaching the main
+ trees when Maria is merged into them.
+ --global-subst should be removed.
+ */
+ uint global_subst_from_len= strlen(global_subst_from);
+ uint global_subst_to_len= strlen(global_subst_to);
+ while (replace(&fd1_result,
+ global_subst_from, global_subst_from_len,
+ global_subst_to, global_subst_to_len) == 0)
+ /* do nothing */ ;
+ /* let's compare again to see if it is ok now */
}
- if (!error && my_read(fd2, (uchar*)&buff2,
- sizeof(buff2), MYF(0)) > 0)
- {
- /* File 1 was smaller */
+
+ if (fd1_result.length != fd2_result.length)
error= RESULT_LENGTH_MISMATCH;
- }
+ else if ((memcmp(fd1_result.str, fd2_result.str, fd1_result.length)))
+ error= RESULT_CONTENT_MISMATCH;
my_close(fd2, MYF(0));
+ dynstr_free(&fd1_result);
+ dynstr_free(&fd2_result);
return error;
}
@@ -3070,7 +3105,7 @@ void do_rmdir(struct st_command *command)
int error;
static DYNAMIC_STRING ds_dirname;
const struct command_arg rmdir_args[] = {
- {"dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to remove"}
+ { "dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to remove" }
};
DBUG_ENTER("do_rmdir");
@@ -3465,9 +3500,10 @@ void do_diff_files(struct st_command *command)
if ((error= compare_files(ds_filename.str, ds_filename2.str)) &&
match_expected_error(command, error, NULL) < 0)
{
- /* Compare of the two files failed, append them to output
- so the failure can be analyzed, but only if it was not
- expected to fail.
+ /*
+ Compare of the two files failed, append them to output
+ so the failure can be analyzed, but only if it was not
+ expected to fail.
*/
show_diff(&ds_res, ds_filename.str, ds_filename2.str);
log_file.write(&ds_res);
@@ -4634,7 +4670,7 @@ void select_connection(struct st_command *command)
void do_close_connection(struct st_command *command)
{
- DBUG_ENTER("close_connection");
+ DBUG_ENTER("do_close_connection");
struct st_connection *con;
static DYNAMIC_STRING ds_connection;
@@ -4695,7 +4731,7 @@ void do_close_connection(struct st_command *command)
var_set_int("$mysql_get_server_version", 0xFFFFFFFF);
var_set_string("$CURRENT_CONNECTION", con->name);
}
-
+ dynstr_free(&ds_connection);
DBUG_VOID_RETURN;
}
@@ -4981,7 +5017,8 @@ void do_connect(struct st_command *command)
con_options= ds_options.str;
while (*con_options)
{
- char* end;
+ size_t length;
+ char *end;
/* Step past any spaces in beginning of option*/
while (*con_options && my_isspace(charset_info, *con_options))
con_options++;
@@ -4989,13 +5026,14 @@ void do_connect(struct st_command *command)
end= con_options;
while (*end && !my_isspace(charset_info, *end))
end++;
- if (!strncmp(con_options, "SSL", 3))
+ length= (size_t) (end - con_options);
+ if (length == 3 && !strncmp(con_options, "SSL", 3))
con_ssl= 1;
- else if (!strncmp(con_options, "COMPRESS", 8))
+ else if (length == 8 && !strncmp(con_options, "COMPRESS", 8))
con_compress= 1;
- else if (!strncmp(con_options, "PIPE", 4))
+ else if (length == 4 && !strncmp(con_options, "PIPE", 4))
con_pipe= 1;
- else if (!strncmp(con_options, "SHM", 3))
+ else if (length == 3 && !strncmp(con_options, "SHM", 3))
con_shm= 1;
else
die("Illegal option to connect: %.*s",
@@ -5029,6 +5067,9 @@ void do_connect(struct st_command *command)
if (opt_charsets_dir)
mysql_options(&con_slot->mysql, MYSQL_SET_CHARSET_DIR,
opt_charsets_dir);
+ if (opt_connect_timeout >= 0)
+ mysql_options(&con_slot->mysql, MYSQL_OPT_CONNECT_TIMEOUT,
+ &opt_connect_timeout);
#ifdef HAVE_OPENSSL
if (opt_use_ssl || con_ssl)
@@ -5061,14 +5102,13 @@ void do_connect(struct st_command *command)
mysql_options(&con_slot->mysql, MYSQL_SHARED_MEMORY_BASE_NAME, ds_shm.str);
mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, &protocol);
}
- else if(shared_memory_base_name)
+ else if (shared_memory_base_name)
{
mysql_options(&con_slot->mysql, MYSQL_SHARED_MEMORY_BASE_NAME,
- shared_memory_base_name);
+ shared_memory_base_name);
}
#endif
-
/* Use default db name */
if (ds_database.length == 0)
dynstr_set(&ds_database, opt_db);
@@ -5732,6 +5772,11 @@ static struct my_option my_long_options[] =
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
(uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"global-subst", OPT_GLOBAL_SUBST, "argument should be 'X,Y' ;"
+ " substitute string X with another Y accross the whole test's current"
+ " result before comparing with expected result file",
+ (uchar**) &global_subst, (uchar**) &global_subst, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (uchar**) &opt_host, (uchar**) &opt_host, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"include", 'i', "Include SQL before each test case.", (uchar**) &opt_include,
@@ -5797,6 +5842,9 @@ static struct my_option my_long_options[] =
GET_INT, REQUIRED_ARG, 0, 0, 10000, 0, 0, 0},
{"test-file", 'x', "Read test from/in this file (default stdin).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"connect-timeout", OPT_MY_CONNECT_TIMEOUT, "Client connection timeout",
+ (uchar**) &opt_connect_timeout, (uchar**) &opt_connect_timeout, 0,
+ GET_INT, REQUIRED_ARG, -1, -1, 0, 0, 0, 0},
{"timer-file", 'm', "File where the timing in micro seconds is stored.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"tmpdir", 't', "Temporary directory where sockets are put.",
@@ -6003,6 +6051,15 @@ int parse_args(int argc, char **argv)
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
+ if (global_subst != NULL)
+ {
+ char *comma= strstr(global_subst, ",");
+ if (comma == NULL)
+ die("wrong --global-subst, must be X,Y");
+ memcpy(global_subst_from, global_subst, (comma-global_subst));
+ global_subst_from[comma-global_subst]= 0;
+ memcpy(global_subst_to, comma+1, strlen(comma));
+ }
if (!record)
{
@@ -6927,6 +6984,9 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
handle_no_error(command);
if (!disable_result_log)
{
+ ulonglong affected_rows;
+ LINT_INIT(affected_rows);
+
/*
Not all statements creates a result set. If there is one we can
now create another normal result set that contains the meta
@@ -6949,8 +7009,17 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
mysql_free_result(res); /* Free normal result set with meta data */
- /* Clear prepare warnings */
- dynstr_set(&ds_prepare_warnings, NULL);
+ /*
+ Normally, if there is a result set, we do not show warnings from the
+ prepare phase. This is because some warnings are generated both during
+ prepare and execute; this would generate different warning output
+ between normal and ps-protocol test runs.
+
+ The --enable_prepare_warnings command can be used to change this so
+ that warnings from both the prepare and execute phase are shown.
+ */
+ if (!disable_warnings && !prepare_warnings_enabled)
+ dynstr_set(&ds_prepare_warnings, NULL);
}
else
{
@@ -6963,38 +7032,33 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
Need to grab affected rows information before getting
warnings here
*/
- {
- ulonglong UNINIT_VAR(affected_rows);
+ if (!disable_info)
+ affected_rows= mysql_affected_rows(mysql);
- if (!disable_info)
- affected_rows= mysql_affected_rows(mysql);
+ if (!disable_warnings)
+ {
+ /* Get the warnings from execute */
- if (!disable_warnings)
+ /* Append warnings to ds - if there are any */
+ if (append_warnings(&ds_execute_warnings, mysql) ||
+ ds_execute_warnings.length ||
+ ds_prepare_warnings.length ||
+ ds_warnings->length)
{
- /* Get the warnings from execute */
-
- /* Append warnings to ds - if there are any */
- if (append_warnings(&ds_execute_warnings, mysql) ||
- ds_execute_warnings.length ||
- ds_prepare_warnings.length ||
- ds_warnings->length)
- {
- dynstr_append_mem(ds, "Warnings:\n", 10);
- if (ds_warnings->length)
- dynstr_append_mem(ds, ds_warnings->str,
- ds_warnings->length);
- if (ds_prepare_warnings.length)
- dynstr_append_mem(ds, ds_prepare_warnings.str,
- ds_prepare_warnings.length);
- if (ds_execute_warnings.length)
- dynstr_append_mem(ds, ds_execute_warnings.str,
- ds_execute_warnings.length);
- }
+ dynstr_append_mem(ds, "Warnings:\n", 10);
+ if (ds_warnings->length)
+ dynstr_append_mem(ds, ds_warnings->str,
+ ds_warnings->length);
+ if (ds_prepare_warnings.length)
+ dynstr_append_mem(ds, ds_prepare_warnings.str,
+ ds_prepare_warnings.length);
+ if (ds_execute_warnings.length)
+ dynstr_append_mem(ds, ds_execute_warnings.str,
+ ds_execute_warnings.length);
}
-
- if (!disable_info)
- append_info(ds, affected_rows, mysql_info(mysql));
}
+ if (!disable_info)
+ append_info(ds, affected_rows, mysql_info(mysql));
}
end:
@@ -7004,14 +7068,6 @@ end:
dynstr_free(&ds_execute_warnings);
}
-
- /* Close the statement if - no reconnect, need new prepare */
- if (mysql->reconnect)
- {
- mysql_stmt_close(stmt);
- cur_con->stmt= NULL;
- }
-
/*
We save the return code (mysql_stmt_errno(stmt)) from the last call sent
to the server into the mysqltest builtin variable $mysql_errno. This
@@ -7020,6 +7076,13 @@ end:
var_set_errno(mysql_stmt_errno(stmt));
+ /* Close the statement if reconnect, need new prepare */
+ if (mysql->reconnect)
+ {
+ mysql_stmt_close(stmt);
+ cur_con->stmt= NULL;
+ }
+
DBUG_VOID_RETURN;
}
@@ -7172,7 +7235,6 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
}
dynstr_free(&query_str);
-
}
if (sp_protocol_enabled &&
@@ -7588,7 +7650,6 @@ static void init_signal_handling(void)
#endif
sigaction(SIGILL, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
-
DBUG_VOID_RETURN;
}
@@ -7600,6 +7661,7 @@ int main(int argc, char **argv)
my_bool q_send_flag= 0, abort_flag= 0;
uint command_executed= 0, last_command_executed= 0;
char save_file[FN_REFLEN];
+ bool empty_result= FALSE;
MY_INIT(argv[0]);
save_file[0]= 0;
@@ -7757,6 +7819,7 @@ int main(int argc, char **argv)
verbose_msg("Start processing test commands from '%s' ...", cur_file->file_name);
while (!read_command(&command) && !abort_flag)
{
+ my_bool ok_to_do;
int current_line_inc = 1, processed = 0;
if (command->type == Q_UNKNOWN || command->type == Q_COMMENT_WITH_COMMAND)
get_command_type(command);
@@ -7769,7 +7832,7 @@ int main(int argc, char **argv)
command->type= Q_COMMENT;
}
- my_bool ok_to_do= cur_block->ok;
+ ok_to_do= cur_block->ok;
/*
Some commands need to be "done" the first time if they may get
re-iterated over in a true context. This can only happen if there's
@@ -7817,6 +7880,8 @@ int main(int argc, char **argv)
case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
case Q_ENABLE_WARNINGS: disable_warnings=0; break;
case Q_DISABLE_WARNINGS: disable_warnings=1; break;
+ case Q_ENABLE_PREPARE_WARNINGS: prepare_warnings_enabled=1; break;
+ case Q_DISABLE_PREPARE_WARNINGS: prepare_warnings_enabled=0; break;
case Q_ENABLE_INFO: disable_info=0; break;
case Q_DISABLE_INFO: disable_info=1; break;
case Q_ENABLE_METADATA: display_metadata=1; break;
@@ -8036,7 +8101,10 @@ int main(int argc, char **argv)
abort_flag= 1;
break;
case Q_SKIP:
- abort_not_supported_test("%s", command->first_argument);
+ /* Eval the query, thus replacing all environment variables */
+ dynstr_set(&ds_res, 0);
+ do_eval(&ds_res, command->first_argument, command->end, FALSE);
+ abort_not_supported_test("%s",ds_res.str);
break;
case Q_RESULT:
@@ -8103,8 +8171,6 @@ int main(int argc, char **argv)
if (parsing_disabled)
die("Test ended with parsing disabled");
- my_bool empty_result= FALSE;
-
/*
The whole test has been executed _sucessfully_.
Time to compare result or save it to record file.