List:Commits« Previous MessageNext Message »
From:msvensson Date:July 21 2006 10:36am
Subject:bk commit into 5.0 tree (msvensson:1.2232) BUG#20072
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson 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-07-21 12:36:21+02:00, msvensson@neptunus.(none) +2 -0
  Bug#20072 sleep(1) makes protocol error go away, with multi-statement query
   - Don't allow a new query to be started without all result sets from the last one has been processed.

  sql-common/client.c@stripped, 2006-07-21 12:36:17+02:00, msvensson@neptunus.(none) +4 -1
    Check that no more result sets are waiting before sending new command to the server.
    Clear server_status when server reports error. 

  tests/mysql_client_test.c@stripped, 2006-07-21 12:36:17+02:00, msvensson@neptunus.(none) +83 -0
    Add test case for bug 

# 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:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/my50-bug20072

--- 1.94/sql-common/client.c	2006-07-21 12:36:28 +02:00
+++ 1.95/sql-common/client.c	2006-07-21 12:36:28 +02:00
@@ -630,6 +630,8 @@ net_safe_read(MYSQL *mysql)
 
     DBUG_PRINT("error",("Got error: %d/%s (%s)",
 			net->last_errno, net->sqlstate, net->last_error));
+    /* Clear server status, not valid after error */
+    mysql->server_status= 0;
     return(packet_error);
   }
   return len;
@@ -662,7 +664,8 @@ cli_advanced_command(MYSQL *mysql, enum 
     if (mysql_reconnect(mysql))
       DBUG_RETURN(1);
   }
-  if (mysql->status != MYSQL_STATUS_READY)
+  if (mysql->status != MYSQL_STATUS_READY ||
+      (mysql->server_status & SERVER_MORE_RESULTS_EXISTS))
   {
     DBUG_PRINT("error",("state: %d", mysql->status));
     set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);

--- 1.190/tests/mysql_client_test.c	2006-07-21 12:36:28 +02:00
+++ 1.191/tests/mysql_client_test.c	2006-07-21 12:36:28 +02:00
@@ -15027,6 +15027,88 @@ static void test_bug20152()
   }
 }
 
+/*
+  Bug#20072:
+*/
+
+static void test_bug20072()
+{
+  int rc;
+  MYSQL* mysql_local;
+
+  myheader("test_bug20072");
+
+  rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
+  myquery(rc);
+  rc= mysql_query(mysql,
+                  "CREATE TABLE t1 (f1 int, f2 varchar(100), " \
+                  "f3 varchar(100))");
+  myquery(rc);
+  rc= mysql_query(mysql,
+                  "INSERT INTO t1 values(0, \"f2 0\", \"f3 0\"), " \
+                  "(1, \"f2 1\", \"f3 1\");");
+  myquery(rc);
+
+  if (!(mysql_local= mysql_init(NULL)))
+    DIE("mysql_init() failed");
+
+  /* Create connection that supports multi statements */
+  if (!(mysql_real_connect(mysql_local, opt_host, opt_user,
+                           opt_password, current_db, opt_port,
+                           opt_unix_socket, CLIENT_MULTI_STATEMENTS)))
+    DIE("connection failed");
+
+  char buf[300];
+  snprintf(buf, sizeof(buf),
+           "update t1 set f2 = 'test f2 0' where f1 = '0';" \
+           "update t1 set f3 = 'test f3 0' where f1 = 0;");
+
+  /* First multi-statement update */
+  if ((rc= mysql_query(mysql_local, buf)))
+    DIE("query_failed");
+
+  /* Second multi-statement update should fail with 2014
+     as first doesn't take care of result */
+  rc= mysql_query(mysql_local, buf);
+  DIE_UNLESS(rc!= 0 && mysql_errno(mysql_local) == 2014);
+
+  do
+  {
+    printf("Statement affected %llu row(s)\n",
+           mysql_affected_rows(mysql_local));
+  }
+  while ((rc = mysql_next_result(mysql_local)) == 0);
+  DIE_UNLESS(rc == -1); /* No more results */
+
+
+  /* Test same thing with sleep between */
+  snprintf(buf, sizeof(buf),
+           "update t1 set f2 = 'test f2 1' where f1 = '0';" \
+           "update t1 set f3 = 'test f3 1' where f1 = 0;");
+
+  /* First multi-statement update */
+  if ((rc= mysql_query(mysql_local, buf)))
+    DIE("query_failed");
+
+  my_sleep(1);
+  /* Second multi-statement update should fail with 2014 */
+  rc= mysql_query(mysql_local, buf);
+  DIE_UNLESS(rc!= 0 && mysql_errno(mysql_local) == 2014);
+
+  do
+  {
+    printf("Statement affected %llu row(s)\n",
+           mysql_affected_rows(mysql_local));
+  }
+  while ((rc = mysql_next_result(mysql_local)) == 0);
+  DIE_UNLESS(rc == -1); /* No more results */
+
+  mysql_close(mysql_local);
+
+  rc= mysql_query(mysql, "DROP TABLE t1");
+  myquery(rc);
+}
+
 
 /*
   Read and parse arguments and MySQL options from my.cnf
@@ -15298,6 +15380,7 @@ static struct my_tests_st my_tests[]= {
   { "test_bug14169", test_bug14169 },
   { "test_bug17667", test_bug17667 },
   { "test_bug19671", test_bug19671},
+  { "test_bug20072", test_bug20072},
   { 0, 0 }
 };
 
Thread
bk commit into 5.0 tree (msvensson:1.2232) BUG#20072msvensson21 Jul