List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:July 5 2005 4:47pm
Subject:bk commit into 5.0 tree (jimw:1.1889)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw 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
  1.1889 05/07/05 09:47:20 jimw@stripped +6 -0
  Merge mysql.com:/home/jimw/my/mysql-5.0-10214
  into  mysql.com:/home/jimw/my/mysql-5.0-clean

  tests/mysql_client_test.c
    1.130 05/07/05 09:47:17 jimw@stripped +0 -2
    Clean up merge of new tests

  sql/sql_class.cc
    1.192 05/07/05 09:46:01 jimw@stripped +0 -0
    Auto merged

  sql/set_var.cc
    1.123 05/07/05 09:46:01 jimw@stripped +0 -0
    Auto merged

  libmysql/libmysql.c
    1.220 05/07/05 09:46:01 jimw@stripped +0 -0
    Auto merged

  include/mysql_com.h
    1.100 05/07/05 09:46:01 jimw@stripped +0 -0
    Auto merged

  include/my_sys.h
    1.160 05/07/05 09:46:01 jimw@stripped +0 -0
    Auto merged

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-clean/RESYNC

--- 1.159/include/my_sys.h	2005-06-13 02:59:50 -07:00
+++ 1.160/include/my_sys.h	2005-07-05 09:46:01 -07:00
@@ -866,6 +866,9 @@
 extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
                                      char *to, ulong to_length,
                                      const char *from, ulong length);
+extern ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info,
+                                     char *to, ulong to_length,
+                                     const char *from, ulong length);
 
 extern void thd_increment_bytes_sent(ulong length);
 extern void thd_increment_bytes_received(ulong length);

--- 1.99/include/mysql_com.h	2005-06-23 18:29:50 -07:00
+++ 1.100/include/mysql_com.h	2005-07-05 09:46:01 -07:00
@@ -137,14 +137,14 @@
 #define SERVER_QUERY_NO_GOOD_INDEX_USED 16
 #define SERVER_QUERY_NO_INDEX_USED      32
 /*
-  The server was able to fulfill client request and open read-only
-  non-scrollable cursor for the query.  This flag comes in server
-  status with reply to COM_EXECUTE and COM_EXECUTE_DIRECT commands.
+  The server was able to fulfill the clients request and opened a
+  read-only non-scrollable cursor for a query. This flag comes
+  in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
 */
 #define SERVER_STATUS_CURSOR_EXISTS 64
 /*
-  This flag is sent with last row of read-only cursor, in reply to
-  COM_FETCH command.
+  This flag is sent when a read-only cursor is exhausted, in reply to
+  COM_STMT_FETCH command.
 */
 #define SERVER_STATUS_LAST_ROW_SENT 128
 #define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */

--- 1.219/libmysql/libmysql.c	2005-06-23 18:29:50 -07:00
+++ 1.220/libmysql/libmysql.c	2005-07-05 09:46:01 -07:00
@@ -2733,7 +2733,6 @@
       set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
       return 1;
     }
-    stmt->server_status= mysql->server_status;
     if (cli_read_binary_rows(stmt))
       return 1;
     stmt->server_status= mysql->server_status;

--- 1.191/sql/sql_class.cc	2005-06-23 18:29:51 -07:00
+++ 1.192/sql/sql_class.cc	2005-07-05 09:46:01 -07:00
@@ -786,7 +786,10 @@
   void *change_mem= alloc_root(runtime_memroot, sizeof(*change));
   if (change_mem == 0)
   {
-    fatal_error();
+    /*
+      OOM, thd->fatal_error() is called by the error handler of the
+      memroot. Just return.
+    */
     return;
   }
   change= new (change_mem) Item_change_record;
@@ -1453,17 +1456,16 @@
       (void)local_vars.push_back(new Item_splocal(mv->s, mv->offset));
     else
     {
-      Item_func_set_user_var *xx = new Item_func_set_user_var(mv->s, item);
+      Item_func_set_user_var *var= new Item_func_set_user_var(mv->s, item);
       /*
         Item_func_set_user_var can't substitute something else on its place =>
         0 can be passed as last argument (reference on item)
         Item_func_set_user_var can't be fixed after creation, so we do not
-        check xx->fixed
+        check var->fixed
       */
-      xx->fix_fields(thd, (TABLE_LIST*) thd->lex->select_lex.table_list.first,
-		     0);
-      xx->fix_length_and_dec();
-      vars.push_back(xx);
+      var->fix_fields(thd, 0);
+      var->fix_length_and_dec();
+      vars.push_back(var);
     }
   }
   return 0;
@@ -1540,15 +1542,19 @@
 void
 Statement::set_n_backup_statement(Statement *stmt, Statement *backup)
 {
+  DBUG_ENTER("Statement::set_n_backup_statement");
   backup->set_statement(this);
   set_statement(stmt);
+  DBUG_VOID_RETURN;
 }
 
 
 void Statement::restore_backup_statement(Statement *stmt, Statement *backup)
 {
+  DBUG_ENTER("Statement::restore_backup_statement");
   stmt->set_statement(this);
   set_statement(backup);
+  DBUG_VOID_RETURN;
 }
 
 
@@ -1571,6 +1577,7 @@
 {
   DBUG_ENTER("Query_arena::set_n_backup_item_arena");
   DBUG_ASSERT(backup->is_backup_arena == FALSE);
+
   backup->set_item_arena(this);
   set_item_arena(set);
 #ifndef DBUG_OFF

--- 1.122/sql/set_var.cc	2005-06-23 18:29:51 -07:00
+++ 1.123/sql/set_var.cc	2005-07-05 09:46:01 -07:00
@@ -1617,7 +1617,7 @@
   {
     if (!(res= var->value->val_str(&str)))
     {
-      strmake(buff, "NULL", 4);
+      strmov(buff, "NULL");
       goto err;
     }
     var->save_result.ulong_value= ((ulong)
@@ -2983,7 +2983,7 @@
   }
 
   if ((!value->fixed &&
-       value->fix_fields(thd, 0, &value)) || value->check_cols(1))
+       value->fix_fields(thd, &value)) || value->check_cols(1))
     return -1;
   if (var->check_update_type(value->result_type()))
   {
@@ -3017,7 +3017,7 @@
   if (type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL))
     return 1;
 
-  if (value && ((!value->fixed && value->fix_fields(thd, 0, &value)) ||
+  if (value && ((!value->fixed && value->fix_fields(thd, &value)) ||
                 value->check_cols(1)))
     return -1;
   return 0;
@@ -3046,7 +3046,7 @@
     Item_func_set_user_var can't substitute something else on its place =>
     0 can be passed as last argument (reference on item)
   */
-  return (user_var_item->fix_fields(thd, 0, (Item**) 0) ||
+  return (user_var_item->fix_fields(thd, (Item**) 0) ||
 	  user_var_item->check()) ? -1 : 0;
 }
 
@@ -3069,7 +3069,7 @@
     Item_func_set_user_var can't substitute something else on its place =>
     0 can be passed as last argument (reference on item)
   */
-  return (user_var_item->fix_fields(thd, 0, (Item**) 0));
+  return (user_var_item->fix_fields(thd, (Item**) 0));
 }
 
 

--- 1.129/tests/mysql_client_test.c	2005-06-23 18:29:51 -07:00
+++ 1.130/tests/mysql_client_test.c	2005-07-05 09:47:17 -07:00
@@ -13332,6 +13332,272 @@
   mysql_close(mysql1);
 }
 
+/* Bug#10736: cursors and subqueries, memroot management */
+
+static void test_bug10736()
+{
+  MYSQL_STMT *stmt;
+  MYSQL_BIND bind[1];
+  char a[21];
+  int rc;
+  const char *stmt_text;
+  int i= 0;
+  ulong type;
+
+  myheader("test_bug10736");
+
+  mysql_query(mysql, "drop table if exists t1");
+  mysql_query(mysql, "create table t1 (id integer not null primary key,"
+                                      "name VARCHAR(20) NOT NULL)");
+  rc= mysql_query(mysql, "insert into t1 (id, name) values "
+                         "(1, 'aaa'), (2, 'bbb'), (3, 'ccc')");
+  myquery(rc);
+
+  stmt= mysql_stmt_init(mysql);
+
+  type= (ulong) CURSOR_TYPE_READ_ONLY;
+  rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type);
+  check_execute(stmt, rc);
+  stmt_text= "select name from t1 where name=(select name from t1 where id=2)";
+  rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+  check_execute(stmt, rc);
+
+  bzero(bind, sizeof(bind));
+  bind[0].buffer_type= MYSQL_TYPE_STRING;
+  bind[0].buffer= (void*) a;
+  bind[0].buffer_length= sizeof(a);
+  mysql_stmt_bind_result(stmt, bind);
+
+  for (i= 0; i < 3; i++)
+  {
+    int row_no= 0;
+    rc= mysql_stmt_execute(stmt);
+    check_execute(stmt, rc);
+    while ((rc= mysql_stmt_fetch(stmt)) == 0)
+    {
+      if (!opt_silent)
+        printf("%d: %s\n", row_no, a);
+      ++row_no;
+    }
+    DIE_UNLESS(rc == MYSQL_NO_DATA);
+  }
+  rc= mysql_stmt_close(stmt);
+  DIE_UNLESS(rc == 0);
+
+  rc= mysql_query(mysql, "drop table t1");
+  myquery(rc);
+}
+
+/* Bug#10794: cursors, packets out of order */
+
+static void test_bug10794()
+{
+  MYSQL_STMT *stmt, *stmt1;
+  MYSQL_BIND bind[2];
+  char a[21];
+  int id_val;
+  ulong a_len;
+  int rc;
+  const char *stmt_text;
+  int i= 0;
+  ulong type;
+
+  myheader("test_bug10794");
+
+  mysql_query(mysql, "drop table if exists t1");
+  mysql_query(mysql, "create table t1 (id integer not null primary key,"
+                                      "name varchar(20) not null)");
+  stmt= mysql_stmt_init(mysql);
+  stmt_text= "insert into t1 (id, name) values (?, ?)";
+  rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+  check_execute(stmt, rc);
+  bzero(bind, sizeof(bind));
+  bind[0].buffer_type= MYSQL_TYPE_LONG;
+  bind[0].buffer= (void*) &id_val;
+  bind[1].buffer_type= MYSQL_TYPE_STRING;
+  bind[1].buffer= (void*) a;
+  bind[1].length= &a_len;
+  rc= mysql_stmt_bind_param(stmt, bind);
+  check_execute(stmt, rc);
+  for (i= 0; i < 34; i++)
+  {
+    id_val= (i+1)*10;
+    sprintf(a, "a%d", i);
+    a_len= strlen(a); /* safety against broken sprintf */
+    rc= mysql_stmt_execute(stmt);
+    check_execute(stmt, rc);
+  }
+  stmt_text= "select name from t1";
+  rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+  type= (ulong) CURSOR_TYPE_READ_ONLY;
+  mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
+  stmt1= mysql_stmt_init(mysql);
+  mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
+  bzero(bind, sizeof(bind));
+  bind[0].buffer_type= MYSQL_TYPE_STRING;
+  bind[0].buffer= (void*) a;
+  bind[0].buffer_length= sizeof(a);
+  bind[0].length= &a_len;
+  rc= mysql_stmt_bind_result(stmt, bind);
+  check_execute(stmt, rc);
+  rc= mysql_stmt_execute(stmt);
+  check_execute(stmt, rc);
+  rc= mysql_stmt_fetch(stmt);
+  check_execute(stmt, rc);
+  if (!opt_silent)
+    printf("Fetched row from stmt: %s\n", a);
+  /* Don't optimize: an attribute of the original test case */
+  mysql_stmt_free_result(stmt);
+  mysql_stmt_reset(stmt);
+  stmt_text= "select name from t1 where id=10";
+  rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text));
+  check_execute(stmt1, rc);
+  rc= mysql_stmt_bind_result(stmt1, bind);
+  check_execute(stmt1, rc);
+  rc= mysql_stmt_execute(stmt1);
+  while (1)
+  {
+    rc= mysql_stmt_fetch(stmt1);
+    if (rc == MYSQL_NO_DATA)
+    {
+      if (!opt_silent)
+        printf("End of data in stmt1\n");
+      break;
+    }
+    check_execute(stmt1, rc);
+    if (!opt_silent)
+      printf("Fetched row from stmt1: %s\n", a);
+  }
+  mysql_stmt_close(stmt);
+  mysql_stmt_close(stmt1);
+
+  rc= mysql_query(mysql, "drop table t1");
+  myquery(rc);
+}
+
+
+/* Bug#11172: cursors, crash on a fetch from a datetime column */
+
+static void test_bug11172()
+{
+  MYSQL_STMT *stmt;
+  MYSQL_BIND bind_in[1], bind_out[2];
+  MYSQL_TIME hired;
+  int rc;
+  const char *stmt_text;
+  int i= 0, id;
+  ulong type;
+
+  myheader("test_bug11172");
+
+  mysql_query(mysql, "drop table if exists t1");
+  mysql_query(mysql, "create table t1 (id integer not null primary key,"
+                                      "hired date not null)");
+  rc= mysql_query(mysql,
+                  "insert into t1 (id, hired) values (1, '1933-08-24'), "
+                  "(2, '1965-01-01'), (3, '1949-08-17'), (4, '1945-07-07'), "
+                  "(5, '1941-05-15'), (6, '1978-09-15'), (7, '1936-03-28')");
+  myquery(rc);
+  stmt= mysql_stmt_init(mysql);
+  stmt_text= "SELECT id, hired FROM t1 WHERE hired=?";
+  rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+  check_execute(stmt, rc);
+
+  type= (ulong) CURSOR_TYPE_READ_ONLY;
+  mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
+
+  bzero(bind_in, sizeof(bind_in));
+  bzero(bind_out, sizeof(bind_out));
+  bzero(&hired, sizeof(hired));
+  hired.year= 1965;
+  hired.month= 1;
+  hired.day= 1;
+  bind_in[0].buffer_type= MYSQL_TYPE_DATE;
+  bind_in[0].buffer= (void*) &hired;
+  bind_in[0].buffer_length= sizeof(hired);
+  bind_out[0].buffer_type= MYSQL_TYPE_LONG;
+  bind_out[0].buffer= (void*) &id;
+  bind_out[1]= bind_in[0];
+
+  for (i= 0; i < 3; i++)
+  {
+    rc= mysql_stmt_bind_param(stmt, bind_in);
+    check_execute(stmt, rc);
+    rc= mysql_stmt_bind_result(stmt, bind_out);
+    check_execute(stmt, rc);
+    rc= mysql_stmt_execute(stmt);
+    check_execute(stmt, rc);
+    while ((rc= mysql_stmt_fetch(stmt)) == 0)
+    {
+      if (!opt_silent)
+        printf("fetched data %d:%d-%d-%d\n", id,
+               hired.year, hired.month, hired.day);
+    }
+    DIE_UNLESS(rc == MYSQL_NO_DATA);
+    mysql_stmt_free_result(stmt) || mysql_stmt_reset(stmt);
+  }
+  mysql_stmt_close(stmt);
+  mysql_rollback(mysql);
+  mysql_rollback(mysql);
+
+  rc= mysql_query(mysql, "drop table t1");
+  myquery(rc);
+}
+
+
+/* Bug#11656: cursors, crash on a fetch from a query with distinct. */
+
+static void test_bug11656()
+{
+  MYSQL_STMT *stmt;
+  MYSQL_BIND bind[2];
+  int rc;
+  const char *stmt_text;
+  char buf[2][20];
+  int i= 0;
+  ulong type;
+
+  myheader("test_bug11656");
+
+  mysql_query(mysql, "drop table if exists t1");
+
+  rc= mysql_query(mysql, "create table t1 ("
+                  "server varchar(40) not null, "
+                  "test_kind varchar(1) not null, "
+                  "test_id varchar(30) not null , "
+                  "primary key (server,test_kind,test_id))");
+  myquery(rc);
+
+  stmt_text= "select distinct test_kind, test_id from t1 "
+             "where server in (?, ?)";
+  stmt= mysql_stmt_init(mysql);
+  rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+  check_execute(stmt, rc);
+  type= (ulong) CURSOR_TYPE_READ_ONLY;
+  mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
+
+  bzero(bind, sizeof(bind));
+  strcpy(buf[0], "pcint502_MY2");
+  strcpy(buf[1], "*");
+  for (i=0; i < 2; i++)
+  {
+    bind[i].buffer_type= MYSQL_TYPE_STRING;
+    bind[i].buffer= (gptr *)&buf[i];
+    bind[i].buffer_length= strlen(buf[i]);
+  }
+  mysql_stmt_bind_param(stmt, bind);
+
+  rc= mysql_stmt_execute(stmt);
+  check_execute(stmt, rc);
+
+  rc= mysql_stmt_fetch(stmt);
+  DIE_UNLESS(rc == MYSQL_NO_DATA);
+
+  mysql_stmt_close(stmt);
+  rc= mysql_query(mysql, "drop table t1");
+  myquery(rc);
+}
+
 
 /*
   Check that the server signals when NO_BACKSLASH_ESCAPES mode is in effect,
@@ -13596,6 +13862,10 @@
   { "test_bug10729", test_bug10729 },
   { "test_bug11111", test_bug11111 },
   { "test_bug9992", test_bug9992 },
+  { "test_bug10736", test_bug10736 },
+  { "test_bug10794", test_bug10794 },
+  { "test_bug11172", test_bug11172 },
+  { "test_bug11656", test_bug11656 },
   { "test_bug10214", test_bug10214 },
   { 0, 0 }
 };
Thread
bk commit into 5.0 tree (jimw:1.1889)Jim Winstead5 Jul