summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-05-09 12:35:11 +0200
committerSergei Golubchik <sergii@pisem.net>2014-05-09 12:35:11 +0200
commitd3e2e1243bb0dae95ce35b0380dd4f8f476b254d (patch)
tree8779ad6b2059f181770cc07e2437925d7d5d5d04 /client
parent229dad1f9b12f8e9f64b6a605bdf8e31c339d018 (diff)
parent124428a9e28e59f98b25d8ee07b57d264f63cbe4 (diff)
downloadmariadb-git-d3e2e1243bb0dae95ce35b0380dd4f8f476b254d.tar.gz
5.5 merge
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc2
-rw-r--r--client/mysql_upgrade.c1
-rw-r--r--client/mysqldump.c31
-rw-r--r--client/mysqltest.cc53
4 files changed, 63 insertions, 24 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 22d9d84d582..b1570e32a80 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2000, 2014, Oracle and/or its affiliates.
Copyright (c) 2009, 2013, Monty Program Ab.
Copyright (c) 2013, 2014, SkySQL Ab
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index ec49134a111..80d57ce9faa 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -500,6 +500,7 @@ static void find_tool(char *tool_executable_name, const char *tool_name,
*/
if (run_tool(tool_executable_name,
&ds_tmp, /* Get output from command, discard*/
+ "--no-defaults",
"--help",
"2>&1",
IF_WIN("> NUL", "> /dev/null"),
diff --git a/client/mysqldump.c b/client/mysqldump.c
index b3a679261d7..cb4fa022d4f 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -604,12 +604,12 @@ static void print_version(void)
} /* print_version */
-static void short_usage_sub(void)
+static void short_usage_sub(FILE *f)
{
- printf("Usage: %s [OPTIONS] database [tables]\n", my_progname_short);
- printf("OR %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n",
- my_progname_short);
- printf("OR %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname_short);
+ fprintf(f, "Usage: %s [OPTIONS] database [tables]\n", my_progname_short);
+ fprintf(f, "OR %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n",
+ my_progname_short);
+ fprintf(f, "OR %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname_short);
}
@@ -618,18 +618,18 @@ static void usage(void)
print_version();
puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
puts("Dumping structure and contents of MySQL databases and tables.");
- short_usage_sub();
+ short_usage_sub(stdout);
print_defaults("my",load_default_groups);
puts("");
-my_print_help(my_long_options);
+ my_print_help(my_long_options);
my_print_variables(my_long_options);
} /* usage */
-static void short_usage(void)
+static void short_usage(FILE *f)
{
- short_usage_sub();
- printf("For more options, use %s --help\n", my_progname_short);
+ short_usage_sub(f);
+ fprintf(f, "For more options, use %s --help\n", my_progname_short);
}
@@ -1002,7 +1002,7 @@ static int get_options(int *argc, char ***argv)
exit(1);
if ((*argc < 1 && !opt_alldbs) || (*argc > 0 && opt_alldbs))
{
- short_usage();
+ short_usage(stderr);
return EX_USAGE;
}
if (tty_password)
@@ -1502,12 +1502,13 @@ static void free_resources()
static void maybe_exit(int error)
{
- if (opt_slave_data)
- do_start_slave_sql(mysql);
if (!first_error)
first_error= error;
if (ignore_errors)
return;
+ ignore_errors= 1; /* don't want to recurse, if something fails below */
+ if (opt_slave_data)
+ do_start_slave_sql(mysql);
if (mysql)
mysql_close(mysql);
free_resources();
@@ -5799,8 +5800,8 @@ int main(int argc, char **argv)
*/
err:
/* if --dump-slave , start the slave sql thread */
- if (opt_slave_data && do_start_slave_sql(mysql))
- goto err;
+ if (opt_slave_data)
+ do_start_slave_sql(mysql);
#ifdef HAVE_SMEM
my_free(shared_memory_base_name);
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 91bc531b2ae..efece866ef5 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -837,6 +837,8 @@ static void handle_no_active_connection(struct st_command* command,
#define EMB_SEND_QUERY 1
#define EMB_READ_QUERY_RESULT 2
#define EMB_END_CONNECTION 3
+#define EMB_PREPARE_STMT 4
+#define EMB_EXECUTE_STMT 5
/* workaround for MySQL BUG#57491 */
#undef MY_WME
@@ -872,11 +874,19 @@ pthread_handler_t connection_thread(void *arg)
case EMB_END_CONNECTION:
goto end_thread;
case EMB_SEND_QUERY:
- cn->result= mysql_send_query(cn->mysql, cn->cur_query, cn->cur_query_len);
+ cn->result= mysql_send_query(cn->mysql,
+ cn->cur_query, cn->cur_query_len);
break;
case EMB_READ_QUERY_RESULT:
cn->result= mysql_read_query_result(cn->mysql);
break;
+ case EMB_PREPARE_STMT:
+ cn->result= mysql_stmt_prepare(cn->stmt,
+ cn->cur_query, cn->cur_query_len);
+ break;
+ case EMB_EXECUTE_STMT:
+ cn->result= mysql_stmt_execute(cn->stmt);
+ break;
default:
DBUG_ASSERT(0);
}
@@ -946,6 +956,30 @@ static int do_read_query_result(struct st_connection *cn)
}
+static int do_stmt_prepare(struct st_connection *cn, const char *q, int q_len)
+{
+ /* The cn->stmt is already set. */
+ if (!cn->has_thread)
+ return mysql_stmt_prepare(cn->stmt, q, q_len);
+ cn->cur_query= q;
+ cn->cur_query_len= q_len;
+ signal_connection_thd(cn, EMB_PREPARE_STMT);
+ wait_query_thread_done(cn);
+ return cn->result;
+}
+
+
+static int do_stmt_execute(struct st_connection *cn)
+{
+ /* The cn->stmt is already set. */
+ if (!cn->has_thread)
+ return mysql_stmt_execute(cn->stmt);
+ signal_connection_thd(cn, EMB_EXECUTE_STMT);
+ wait_query_thread_done(cn);
+ return cn->result;
+}
+
+
static void emb_close_connection(struct st_connection *cn)
{
if (!cn->has_thread)
@@ -979,6 +1013,8 @@ static void init_connection_thd(struct st_connection *cn)
#define init_connection_thd(X) do { } while(0)
#define do_send_query(cn,q,q_len) mysql_send_query(cn->mysql, q, q_len)
#define do_read_query_result(cn) mysql_read_query_result(cn->mysql)
+#define do_stmt_prepare(cn, q, q_len) mysql_stmt_prepare(cn->stmt, q, q_len)
+#define do_stmt_execute(cn) mysql_stmt_execute(cn->stmt)
#endif /*EMBEDDED_LIBRARY*/
@@ -8078,11 +8114,12 @@ void handle_no_error(struct st_command *command)
error - function will not return
*/
-void run_query_stmt(MYSQL *mysql, struct st_command *command,
+void run_query_stmt(struct st_connection *cn, struct st_command *command,
char *query, int query_len, DYNAMIC_STRING *ds,
DYNAMIC_STRING *ds_warnings)
{
MYSQL_RES *res= NULL; /* Note that here 'res' is meta data result set */
+ MYSQL *mysql= cn->mysql;
MYSQL_STMT *stmt;
DYNAMIC_STRING ds_prepare_warnings;
DYNAMIC_STRING ds_execute_warnings;
@@ -8092,11 +8129,11 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
/*
Init a new stmt if it's not already one created for this connection
*/
- if(!(stmt= cur_con->stmt))
+ if(!(stmt= cn->stmt))
{
if (!(stmt= mysql_stmt_init(mysql)))
die("unable to init stmt structure");
- cur_con->stmt= stmt;
+ cn->stmt= stmt;
}
/* Init dynamic strings for warnings */
@@ -8109,7 +8146,7 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
/*
Prepare the query
*/
- if (mysql_stmt_prepare(stmt, query, query_len))
+ if (do_stmt_prepare(cn, query, query_len))
{
handle_error(command, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds);
@@ -8144,7 +8181,7 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
/*
Execute the query
*/
- if (mysql_stmt_execute(stmt))
+ if (do_stmt_execute(cn))
{
handle_error(command, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds);
@@ -8279,7 +8316,7 @@ end:
if (mysql->reconnect)
{
mysql_stmt_close(stmt);
- cur_con->stmt= NULL;
+ cn->stmt= NULL;
}
DBUG_VOID_RETURN;
@@ -8536,7 +8573,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
if (ps_protocol_enabled &&
complete_query &&
match_re(&ps_re, query))
- run_query_stmt(mysql, command, query, query_len, ds, &ds_warnings);
+ run_query_stmt(cn, command, query, query_len, ds, &ds_warnings);
else
run_query_normal(cn, command, flags, query, query_len,
ds, &ds_warnings);