Commit 0eb21ee4 authored by unknown's avatar unknown

Merge mysql.com:/home/hf/work/w3475/my50-w3475

into  mysql.com:/home/hf/work/w3475/my51-w3475


client/mysqltest.c:
  Auto merged
BitKeeper/deleted/.del-bdb-deadlock.test:
  Auto merged
libmysql/libmysql.c:
  Auto merged
mysql-test/t/lock_multi.test:
  Auto merged
mysql-test/t/show_check.test:
  Auto merged
mysql-test/t/status.test:
  Auto merged
mysql-test/include/deadlock.inc:
  SCCS merged
parents 9852dfbc cc19246f
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* Matt Wagner <matt@mysql.com> * Matt Wagner <matt@mysql.com>
* Monty * Monty
* Jani * Jani
* Holyfoot
**/ **/
/********************************************************************** /**********************************************************************
...@@ -270,6 +271,12 @@ struct connection ...@@ -270,6 +271,12 @@ struct connection
MYSQL* util_mysql; MYSQL* util_mysql;
char *name; char *name;
MYSQL_STMT* stmt; MYSQL_STMT* stmt;
const char *cur_query;
int cur_query_len;
pthread_mutex_t mutex;
pthread_cond_t cond;
int query_done;
}; };
typedef struct typedef struct
...@@ -506,6 +513,58 @@ static void handle_error(const char *query, struct st_query *q, ...@@ -506,6 +513,58 @@ static void handle_error(const char *query, struct st_query *q,
const char *err_sqlstate, DYNAMIC_STRING *ds); const char *err_sqlstate, DYNAMIC_STRING *ds);
static void handle_no_error(struct st_query *q); static void handle_no_error(struct st_query *q);
#ifdef EMBEDDED_LIBRARY
/*
send_one_query executes query in separate thread what is
necessary in embedded library to run 'send' in proper way.
This implementation doesn't handle errors returned
by mysql_send_query. It's technically possible, though
i don't see where it is needed.
*/
pthread_handler_t send_one_query(void *arg)
{
struct connection *cn= (struct connection*)arg;
mysql_thread_init();
VOID(mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len));
mysql_thread_end();
pthread_mutex_lock(&cn->mutex);
cn->query_done= 1;
VOID(pthread_cond_signal(&cn->cond));
pthread_mutex_unlock(&cn->mutex);
pthread_exit(0);
return 0;
}
static int do_send_query(struct connection *cn, const char *q, int q_len,
int flags)
{
pthread_t tid;
if (flags & QUERY_REAP)
return mysql_send_query(&cn->mysql, q, q_len);
if (pthread_mutex_init(&cn->mutex, NULL) ||
pthread_cond_init(&cn->cond, NULL))
die("Error in the thread library");
cn->cur_query= q;
cn->cur_query_len= q_len;
cn->query_done= 0;
if (pthread_create(&tid, NULL, send_one_query, (void*)cn))
die("Cannot start new thread for query");
return 0;
}
#else /*EMBEDDED_LIBRARY*/
#define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len)
#endif /*EMBEDDED_LIBRARY*/
static void do_eval(DYNAMIC_STRING* query_eval, const char *query, static void do_eval(DYNAMIC_STRING* query_eval, const char *query,
my_bool pass_through_escape_chars) my_bool pass_through_escape_chars)
{ {
...@@ -4178,7 +4237,6 @@ static int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql) ...@@ -4178,7 +4237,6 @@ static int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
} }
/* /*
Run query using MySQL C API Run query using MySQL C API
...@@ -4195,11 +4253,12 @@ static int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql) ...@@ -4195,11 +4253,12 @@ static int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
error - function will not return error - function will not return
*/ */
static void run_query_normal(MYSQL *mysql, struct st_query *command, static void run_query_normal(struct connection *cn, struct st_query *command,
int flags, char *query, int query_len, int flags, char *query, int query_len,
DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings) DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings)
{ {
MYSQL_RES *res= 0; MYSQL_RES *res= 0;
MYSQL *mysql= &cn->mysql;
int err= 0, counter= 0; int err= 0, counter= 0;
DBUG_ENTER("run_query_normal"); DBUG_ENTER("run_query_normal");
DBUG_PRINT("enter",("flags: %d", flags)); DBUG_PRINT("enter",("flags: %d", flags));
...@@ -4210,13 +4269,26 @@ static void run_query_normal(MYSQL *mysql, struct st_query *command, ...@@ -4210,13 +4269,26 @@ static void run_query_normal(MYSQL *mysql, struct st_query *command,
/* /*
Send the query Send the query
*/ */
if (mysql_send_query(mysql, query, query_len)) if (do_send_query(cn, query, query_len, flags))
{ {
handle_error(query, command, mysql_errno(mysql), mysql_error(mysql), handle_error(query, command, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), ds); mysql_sqlstate(mysql), ds);
goto end; goto end;
} }
} }
#ifdef EMBEDDED_LIBRARY
/*
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)
{
pthread_mutex_lock(&cn->mutex);
while (!cn->query_done)
pthread_cond_wait(&cn->cond, &cn->mutex);
pthread_mutex_unlock(&cn->mutex);
}
#endif /*EMBEDDED_LIBRARY*/
if (!(flags & QUERY_REAP)) if (!(flags & QUERY_REAP))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -4707,8 +4779,10 @@ static int util_query(MYSQL* org_mysql, const char* query){ ...@@ -4707,8 +4779,10 @@ static int util_query(MYSQL* org_mysql, const char* query){
*/ */
static void run_query(MYSQL *mysql, struct st_query *command, int flags) static void run_query(struct connection *cn, struct st_query *command,
int flags)
{ {
MYSQL *mysql= &cn->mysql;
DYNAMIC_STRING *ds; DYNAMIC_STRING *ds;
DYNAMIC_STRING ds_result; DYNAMIC_STRING ds_result;
DYNAMIC_STRING ds_warnings; DYNAMIC_STRING ds_warnings;
...@@ -4861,7 +4935,7 @@ static void run_query(MYSQL *mysql, struct st_query *command, int flags) ...@@ -4861,7 +4935,7 @@ static void run_query(MYSQL *mysql, struct st_query *command, int flags)
match_re(&ps_re, query)) match_re(&ps_re, query))
run_query_stmt(mysql, command, query, query_len, ds, &ds_warnings); run_query_stmt(mysql, command, query, query_len, ds, &ds_warnings);
else else
run_query_normal(mysql, command, flags, query, query_len, run_query_normal(cn, command, flags, query, query_len,
ds, &ds_warnings); ds, &ds_warnings);
if (sp_created) if (sp_created)
...@@ -5359,7 +5433,7 @@ int main(int argc, char **argv) ...@@ -5359,7 +5433,7 @@ int main(int argc, char **argv)
q->require_file=require_file; q->require_file=require_file;
save_file[0]=0; save_file[0]=0;
} }
run_query(&cur_con->mysql, q, QUERY_REAP|QUERY_SEND); run_query(cur_con, q, QUERY_REAP|QUERY_SEND);
display_result_vertically= old_display_result_vertically; display_result_vertically= old_display_result_vertically;
q->last_argument= q->end; q->last_argument= q->end;
query_executed= 1; query_executed= 1;
...@@ -5394,7 +5468,7 @@ int main(int argc, char **argv) ...@@ -5394,7 +5468,7 @@ int main(int argc, char **argv)
{ {
q->query= q->first_argument; q->query= q->first_argument;
} }
run_query(&cur_con->mysql, q, flags); run_query(cur_con, q, flags);
query_executed= 1; query_executed= 1;
q->last_argument= q->end; q->last_argument= q->end;
break; break;
...@@ -5415,7 +5489,7 @@ int main(int argc, char **argv) ...@@ -5415,7 +5489,7 @@ int main(int argc, char **argv)
query and read the result some time later when reap instruction query and read the result some time later when reap instruction
is given on this connection. is given on this connection.
*/ */
run_query(&cur_con->mysql, q, QUERY_SEND); run_query(cur_con, q, QUERY_SEND);
query_executed= 1; query_executed= 1;
q->last_argument= q->end; q->last_argument= q->end;
break; break;
......
...@@ -4763,14 +4763,6 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) ...@@ -4763,14 +4763,6 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (result->data)
{
free_root(&result->alloc, MYF(MY_KEEP_PREALLOC));
result->data= NULL;
result->rows= 0;
stmt->data_cursor= NULL;
}
if (stmt->update_max_length && !stmt->bind_result_done) if (stmt->update_max_length && !stmt->bind_result_done)
{ {
/* /*
......
# This test doesn't work with the embedded version as this code
# assumes that one query is running while we are doing queries on
# a second connection.
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#
-- source include/not_embedded.inc
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
connect (con2,localhost,root,,); connect (con2,localhost,root,,);
connection con1; connection con1;
......
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
# We verify that we did not introduce a deadlock. # We verify that we did not introduce a deadlock.
# This is intended to mimick how mysqldump and innobackup work. # This is intended to mimick how mysqldump and innobackup work.
# This test doesn't work with the embedded server
-- source include/not_embedded.inc
# And it requires InnoDB # And it requires InnoDB
-- source include/have_innodb.inc -- source include/have_innodb.inc
......
-- source include/have_innodb.inc -- source include/have_innodb.inc
# Can't test this with embedded server
-- source include/not_embedded.inc
# #
# Check and select innodb lock type # Check and select innodb lock type
......
# This test doesn't work with the embedded version as this code
# assumes that one query is running while we are doing queries on
# a second connection.
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2;
--enable_warnings --enable_warnings
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
# Test of rename table # Test of rename table
# #
# Test requires concurrent connections, which can't be tested on embedded
# server
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t0,t1,t2,t3,t4; drop table if exists t0,t1,t2,t3,t4;
# Clear up from other tests (to ensure that SHOW TABLES below is right) # Clear up from other tests (to ensure that SHOW TABLES below is right)
......
# Requires use of multiple simultaneous connections, not supported with # Uses GRANT commands that usually disabled in embedded server
# embedded server testing
-- source include/not_embedded.inc -- source include/not_embedded.inc
# check that CSV engine was compiled in, as the result of the test # check that CSV engine was compiled in, as the result of the test
......
# This test doesn't work with the embedded version as this code
# assumes that one query is running while we are doing queries on
# a second connection.
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#
--source include/not_embedded.inc
# PS causes different statistics # PS causes different statistics
--disable_ps_protocol --disable_ps_protocol
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment