summaryrefslogtreecommitdiff
path: root/client/mysqltest.c
diff options
context:
space:
mode:
authorunknown <aelkin/andrei@mysql1000.(none)>2008-03-29 14:19:53 +0200
committerunknown <aelkin/andrei@mysql1000.(none)>2008-03-29 14:19:53 +0200
commitcfc420976ec6739ebea4e09518dac4f79c693104 (patch)
treec1b581b2bfd6ae08e19aa2c724659e452677a0c8 /client/mysqltest.c
parentfdb9d02945e4e867bc3e862e41b9f2a5522ba76c (diff)
parent0cf83bbf56f13c4391e557cee5271259aff64d19 (diff)
downloadmariadb-git-cfc420976ec6739ebea4e09518dac4f79c693104.tar.gz
Merge mysql1000.(none):/home/andrei/MySQL/BARE/mysql-5.1
into mysql1000.(none):/home/andrei/MySQL/MERGE/5.1-main2rpl client/mysqltest.c: Auto merged mysql-test/t/disabled.def: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sql_class.cc: Auto merged
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r--client/mysqltest.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 37abc798bcd..fc513573962 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -536,6 +536,17 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len,
return 0;
}
+static void wait_query_thread_end(struct st_connection *con)
+{
+ if (!con->query_done)
+ {
+ pthread_mutex_lock(&con->mutex);
+ while (!con->query_done)
+ pthread_cond_wait(&con->cond, &con->mutex);
+ pthread_mutex_unlock(&con->mutex);
+ }
+}
+
#else /*EMBEDDED_LIBRARY*/
#define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len)
@@ -4085,7 +4096,14 @@ void do_close_connection(struct st_command *command)
con->mysql.net.vio = 0;
}
}
-#endif
+#else
+ /*
+ As query could be still executed in a separate theread
+ we need to check if the query's thread was finished and probably wait
+ (embedded-server specific)
+ */
+ wait_query_thread_end(con);
+#endif /*EMBEDDED_LIBRARY*/
if (con->stmt)
mysql_stmt_close(con->stmt);
con->stmt= 0;
@@ -4237,11 +4255,13 @@ int connect_n_handle_errors(struct st_command *command,
if (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
CLIENT_MULTI_STATEMENTS))
{
+ var_set_errno(mysql_errno(con));
handle_error(command, mysql_errno(con), mysql_error(con),
mysql_sqlstate(con), ds);
return 0; /* Not connected */
}
+ var_set_errno(0);
handle_no_error(command);
return 1; /* Connected */
}
@@ -4371,6 +4391,9 @@ void do_connect(struct st_command *command)
(int) (sizeof(connections)/sizeof(struct st_connection)));
}
+#ifdef EMBEDDED_LIBRARY
+ con_slot->query_done= 1;
+#endif
if (!mysql_init(&con_slot->mysql))
die("Failed on mysql_init()");
if (opt_compress || con_compress)
@@ -5872,16 +5895,11 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
}
#ifdef EMBEDDED_LIBRARY
/*
- Here we handle 'reap' command, so we need to check if the
- query's thread was finished and probably wait
+ Here we handle 'reap' command, so we need to check if the
+ query's thread was finished and probably wait
*/
else if (flags & QUERY_REAP_FLAG)
- {
- pthread_mutex_lock(&cn->mutex);
- while (!cn->query_done)
- pthread_cond_wait(&cn->cond, &cn->mutex);
- pthread_mutex_unlock(&cn->mutex);
- }
+ wait_query_thread_end(cn);
#endif /*EMBEDDED_LIBRARY*/
if (!(flags & QUERY_REAP_FLAG))
DBUG_VOID_RETURN;