List:Commits« Previous MessageNext Message »
From:holyfoot Date:October 24 2006 10:43am
Subject:bk commit into 5.1 tree (holyfoot:1.2321)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-10-24 15:43:10+05:00, holyfoot@deer.(none) +7 -0
  Merge mysql.com:/home/hf/work/w3475/my50-w3475
  into  mysql.com:/home/hf/work/w3475/my51-w3475
  MERGE: 1.1810.2078.43

  BitKeeper/deleted/.del-bdb-deadlock.test@stripped, 2006-10-24 15:36:17+05:00, holyfoot@deer.(none) +0 -0
    Auto merged
    MERGE: 1.9.1.2

  BitKeeper/deleted/.del-bdb-deadlock.test@stripped, 2006-10-24 15:36:17+05:00, holyfoot@deer.(none) +0 -0
    Merge rename: mysql-test/t/bdb-deadlock.test -> BitKeeper/deleted/.del-bdb-deadlock.test

  client/mysqltest.c@stripped, 2006-10-24 15:36:17+05:00, holyfoot@deer.(none) +0 -0
    Auto merged
    MERGE: 1.155.9.55

  libmysql/libmysql.c@stripped, 2006-10-24 15:36:18+05:00, holyfoot@deer.(none) +0 -0
    Auto merged
    MERGE: 1.233.1.15

  mysql-test/include/deadlock.inc@stripped, 2006-10-24 15:43:07+05:00, holyfoot@deer.(none) +0 -0
    SCCS merged
    MERGE: 1.11.1.2

  mysql-test/include/deadlock.inc@stripped, 2006-10-24 15:36:17+05:00, holyfoot@deer.(none) +0 -0
    Merge rename: mysql-test/t/innodb-deadlock.test -> mysql-test/include/deadlock.inc

  mysql-test/t/lock_multi.test@stripped, 2006-10-24 15:36:18+05:00, holyfoot@deer.(none) +0 -0
    Auto merged
    MERGE: 1.13.1.5

  mysql-test/t/show_check.test@stripped, 2006-10-24 15:36:18+05:00, holyfoot@deer.(none) +0 -0
    Auto merged
    MERGE: 1.54.1.5

  mysql-test/t/status.test@stripped, 2006-10-24 15:36:18+05:00, holyfoot@deer.(none) +0 -0
    Auto merged
    MERGE: 1.15.1.1

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	holyfoot
# Host:	deer.(none)
# Root:	/home/hf/work/w3475/my51-w3475/RESYNC

--- 1.258/libmysql/libmysql.c	2006-10-24 15:43:18 +05:00
+++ 1.259/libmysql/libmysql.c	2006-10-24 15:43:18 +05:00
@@ -4763,14 +4763,6 @@ int STDCALL mysql_stmt_store_result(MYSQ
     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)
   {
     /*

--- 1.68/mysql-test/t/show_check.test	2006-10-24 15:43:18 +05:00
+++ 1.69/mysql-test/t/show_check.test	2006-10-24 15:43:18 +05:00
@@ -1,5 +1,4 @@
-# Requires use of multiple simultaneous connections, not supported with
-# embedded server testing
+# Uses GRANT commands that usually disabled in embedded server
 -- source include/not_embedded.inc
 
 # check that CSV engine was compiled in, as the result of the test

--- 1.21/mysql-test/t/lock_multi.test	2006-10-24 15:43:18 +05:00
+++ 1.22/mysql-test/t/lock_multi.test	2006-10-24 15:43:18 +05:00
@@ -1,11 +1,3 @@
-# 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
 drop table if exists t1,t2;
 --enable_warnings

--- 1.11.1.1/mysql-test/t/innodb-deadlock.test	2006-10-24 15:43:18 +05:00
+++ 1.14/mysql-test/include/deadlock.inc	2006-10-24 15:43:18 +05:00
@@ -1,6 +1,18 @@
--- source include/have_innodb.inc
+# include/deadlock.inc
+#
+# The variable
+#     $engine_type       -- storage engine to be tested
+# has to be set before sourcing this script.
+#
+# Last update:
+# 2006-07-26 ML refactoring + print when connection is switched
+#               old name was t/innodb-deadlock.test
+#               main code went into include/deadlock.inc
+#
 
+--echo # Establish connection con1 (user=root)
 connect (con1,localhost,root,,);
+--echo # Establish connection con2 (user=root)
 connect (con2,localhost,root,,);
 
 --disable_warnings
@@ -11,29 +23,34 @@ drop table if exists t1,t2;
 # Testing of FOR UPDATE
 #
 
+--echo # Switch to connection con1
 connection con1;
-create table t1 (id integer, x integer) engine=INNODB;
+eval create table t1 (id integer, x integer) engine = $engine_type;
 insert into t1 values(0, 0);
 set autocommit=0;
 SELECT * from t1 where id = 0 FOR UPDATE;
 
+--echo # Switch to connection con2
 connection con2;
 set autocommit=0;
 
-# The following query should hang because con1 is locking the page
+# The following query should hang because con1 is locking the record
 --send
 update t1 set x=2 where id = 0;
 --sleep 2
 
+--echo # Switch to connection con1
 connection con1;
 update t1 set x=1 where id = 0;
 select * from t1;
 commit;
 
+--echo # Switch to connection con2
 connection con2;
 reap;
 commit;
 
+--echo # Switch to connection con1
 connection con1;
 select * from t1;
 commit;
@@ -43,9 +60,10 @@ drop table t1;
 # Testing of FOR UPDATE
 #
 
+--echo # Switch to connection con1
 connection con1;
-create table t1 (id integer, x integer) engine=INNODB;
-create table t2 (b integer, a integer) engine=INNODB;
+eval create table t1 (id integer, x integer) engine = $engine_type;
+eval create table t2 (b integer, a integer) engine = $engine_type;
 insert into t1 values(0, 0), (300, 300);
 insert into t2 values(0, 10), (1, 20), (2, 30);
 commit;
@@ -55,61 +73,75 @@ update t2 set a=100 where b=(SELECT x fr
 select * from t2;
 select * from t1;
 
+--echo # Switch to connection con2
 connection con2;
 set autocommit=0;
 
-# The following query should hang because con1 is locking the page
+# The following query should hang because con1 is locking the record
 --send
 update t1 set x=2 where id = 0;
 --sleep 2
 
+--echo # Switch to connection con1
 connection con1;
 update t1 set x=1 where id = 0;
 select * from t1;
 commit;
 
+--echo # Switch to connection con2
 connection con2;
 reap;
 commit;
 
+--echo # Switch to connection con1
 connection con1;
 select * from t1;
 commit;
 
 drop table t1, t2;
-create table t1 (id integer, x integer) engine=INNODB;
-create table t2 (b integer, a integer) engine=INNODB;
+eval create table t1 (id integer, x integer) engine = $engine_type;
+eval create table t2 (b integer, a integer) engine = $engine_type;
 insert into t1 values(0, 0), (300, 300);
 insert into t2 values(0, 0), (1, 20), (2, 30);
 commit;
 
+--echo # Switch to connection con1
 connection con1;
 select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
 select * from t2;
 select * from t1;
 
+--echo # Switch to connection con2
 connection con2;
 
-# The following query should hang because con1 is locking the page
+# The following query should hang because con1 is locking the record
 update t2 set a=2 where b = 0;
 select * from t2;
 --send
 update t1 set x=2 where id = 0;
 --sleep 2
 
+--echo # Switch to connection con1
 connection con1;
 update t1 set x=1 where id = 0;
 select * from t1;
 commit;
 
+--echo # Switch to connection con2
 connection con2;
 reap;
 commit;
 
+--echo # Switch to connection con1
 connection con1;
 select * from t1;
 commit;
 
+# Cleanup
+--echo # Switch to connection default + disconnect con1 and con2
+connection default;
+disconnect con1;
+disconnect con2;
 drop table t1, t2;
 
 # End of 4.1 tests

--- 1.229/client/mysqltest.c	2006-10-24 15:43:18 +05:00
+++ 1.230/client/mysqltest.c	2006-10-24 15:43:18 +05:00
@@ -23,6 +23,7 @@
  *   Matt Wagner  <matt@stripped>
  *   Monty
  *   Jani
+ *   Holyfoot
  **/
 
 /**********************************************************************
@@ -270,6 +271,12 @@ struct connection
   MYSQL* util_mysql;
   char *name;
   MYSQL_STMT* stmt;
+
+  const char *cur_query;
+  int cur_query_len;
+  pthread_mutex_t mutex;
+  pthread_cond_t cond;
+  int query_done;
 };
 
 typedef struct
@@ -506,6 +513,58 @@ static void handle_error(const char *que
 			 const char *err_sqlstate, DYNAMIC_STRING *ds);
 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,
                     my_bool pass_through_escape_chars)
 {
@@ -4178,7 +4237,6 @@ static int append_warnings(DYNAMIC_STRIN
 }
 
 
-
 /*
   Run query using MySQL C API
 
@@ -4195,11 +4253,12 @@ static int append_warnings(DYNAMIC_STRIN
   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,
 			     DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings)
 {
   MYSQL_RES *res= 0;
+  MYSQL *mysql= &cn->mysql;
   int err= 0, counter= 0;
   DBUG_ENTER("run_query_normal");
   DBUG_PRINT("enter",("flags: %d", flags));
@@ -4210,13 +4269,26 @@ static void run_query_normal(MYSQL *mysq
     /*
        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),
 		   mysql_sqlstate(mysql), ds);
       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))
     DBUG_VOID_RETURN;
@@ -4707,8 +4779,10 @@ static int util_query(MYSQL* org_mysql, 
 
 */
 
-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_result;
   DYNAMIC_STRING ds_warnings;
@@ -4861,7 +4935,7 @@ static void run_query(MYSQL *mysql, stru
       match_re(&ps_re, query))
     run_query_stmt(mysql, command, query, query_len, ds, &ds_warnings);
   else
-    run_query_normal(mysql, command, flags, query, query_len,
+    run_query_normal(cn, command, flags, query, query_len,
 		     ds, &ds_warnings);
 
   if (sp_created)
@@ -5359,7 +5433,7 @@ int main(int argc, char **argv)
 	  q->require_file=require_file;
 	  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;
         q->last_argument= q->end;
         query_executed= 1;
@@ -5394,7 +5468,7 @@ int main(int argc, char **argv)
         {
           q->query= q->first_argument;
         }
-	run_query(&cur_con->mysql, q, flags);
+	run_query(cur_con, q, flags);
 	query_executed= 1;
         q->last_argument= q->end;
 	break;
@@ -5415,7 +5489,7 @@ int main(int argc, char **argv)
 	  query and read the result some time later when reap instruction
 	  is given on this connection.
 	 */
-	run_query(&cur_con->mysql, q, QUERY_SEND);
+	run_query(cur_con, q, QUERY_SEND);
 	query_executed= 1;
         q->last_argument= q->end;
 	break;

--- 1.17/mysql-test/t/status.test	2006-10-24 15:43:18 +05:00
+++ 1.18/mysql-test/t/status.test	2006-10-24 15:43:18 +05:00
@@ -1,10 +1,3 @@
-# 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
 --disable_ps_protocol
 
Thread
bk commit into 5.1 tree (holyfoot:1.2321)holyfoot24 Oct