MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Georg Richter Date:July 15 2005 12:30pm
Subject:bk commit into 5.0 tree (georg:1.1940) BUG#11037
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of georg. When georg 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.1940 05/07/15 14:30:47 georg@stripped +2 -0
  Fix for bug #11037.
  
  When all rows are fetched subsequent calls to mysql_stmt_fetch return
  now MYSQL_NO_DATA instead of errorcode 1.

  tests/mysql_client_test.c
    1.138 05/07/15 14:30:42 georg@stripped +47 -1
    added new testcase for bug #11037

  libmysql/libmysql.c
    1.225 05/07/15 14:30:41 georg@stripped +12 -3
    fix for bug#11037
    

# 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:	georg
# Host:	lmy002.wdf.sap.corp
# Root:	/home/georg/work/mysql-5.0

--- 1.224/libmysql/libmysql.c	2005-07-14 17:05:17 +02:00
+++ 1.225/libmysql/libmysql.c	2005-07-15 14:30:41 +02:00
@@ -1774,6 +1774,7 @@
 static int stmt_read_row_buffered(MYSQL_STMT *stmt, unsigned char **row);
 static int stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row);
 static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row);
+static int stmt_read_row_no_result_set(MYSQL_STMT *stmt, unsigned char **row);
 
 /*
   This function is used in mysql_stmt_store_result if
@@ -2036,7 +2037,7 @@
   stmt->list.data= stmt;
   stmt->state= MYSQL_STMT_INIT_DONE;
   stmt->mysql= mysql;
-  stmt->read_row_func= stmt_read_row_no_data;
+  stmt->read_row_func= stmt_read_row_no_result_set;
   stmt->prefetch_rows= DEFAULT_PREFETCH_ROWS;
   /* The rest of statement members was bzeroed inside malloc */
 
@@ -2779,6 +2780,13 @@
 stmt_read_row_no_data(MYSQL_STMT *stmt  __attribute__((unused)),
                       unsigned char **row  __attribute__((unused)))
 {
+  return MYSQL_NO_DATA;
+}
+
+static int
+stmt_read_row_no_result_set(MYSQL_STMT *stmt  __attribute__((unused)),
+                      unsigned char **row  __attribute__((unused)))
+{
   set_stmt_error(stmt, CR_NO_RESULT_SET, unknown_sqlstate);
   return 1;
 }
@@ -4600,7 +4608,8 @@
       ((rc= stmt_fetch_row(stmt, row)) && rc != MYSQL_DATA_TRUNCATED))
   {
     stmt->state= MYSQL_STMT_PREPARE_DONE;       /* XXX: this is buggy */
-    stmt->read_row_func= stmt_read_row_no_data;
+    stmt->read_row_func= (rc == MYSQL_NO_DATA) ? 
+      stmt_read_row_no_data : stmt_read_row_no_result_set;
   }
   else
   {
@@ -4937,7 +4946,7 @@
       for (; param < param_end; param++)
         param->long_data_used= 0;
     }
-    stmt->read_row_func= stmt_read_row_no_data;
+    stmt->read_row_func= stmt_read_row_no_result_set;
     if (mysql)
     {
       if ((int) stmt->state > (int) MYSQL_STMT_PREPARE_DONE)

--- 1.137/tests/mysql_client_test.c	2005-07-14 17:05:17 +02:00
+++ 1.138/tests/mysql_client_test.c	2005-07-15 14:30:42 +02:00
@@ -13315,7 +13315,7 @@
   DIE_UNLESS(rc == 1);                         /* Got errors, as expected */
 
   if (!opt_silent)
-    fprintf(stdout, "Got error, sa expected:\n [%d] %s\n",
+    fprintf(stdout, "Got error, as expected:\n [%d] %s\n",
             mysql_errno(mysql1), mysql_error(mysql1));
 
   mysql_close(mysql1);
@@ -13705,6 +13705,51 @@
   myquery(rc);
 }
 
+static void test_bug11037()
+{
+  MYSQL_STMT *stmt;
+  int rc;
+  const char *stmt_text;
+
+  myheader("test_bug11037");
+
+  mysql_query(mysql, "drop table if exists t1");
+
+  rc= mysql_query(mysql, "create table t1 (id int not null)");
+  myquery(rc);
+
+  rc= mysql_query(mysql, "insert into t1 values (1)");
+  myquery(rc);
+
+  stmt_text= "select id FROM t1";
+  stmt= mysql_stmt_init(mysql);
+  rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+
+  /* expected error */
+  rc = mysql_stmt_fetch(stmt);
+  DIE_UNLESS(rc==1);
+  if (!opt_silent)
+    fprintf(stdout, "Got error, as expected:\n [%d] %s\n",
+            mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
+
+  rc = mysql_stmt_execute(stmt);
+  check_execute(stmt, rc);
+
+  rc = mysql_stmt_fetch(stmt);
+  DIE_UNLESS(rc==0);
+
+  rc = mysql_stmt_fetch(stmt);
+  DIE_UNLESS(rc==MYSQL_NO_DATA);
+
+  rc = mysql_stmt_fetch(stmt);
+  DIE_UNLESS(rc==MYSQL_NO_DATA);
+
+  mysql_stmt_close(stmt);
+  rc= mysql_query(mysql, "drop table t1");
+  myquery(rc);
+}
+
+
 /*
   Read and parse arguments and MySQL options from my.cnf
 */
@@ -13948,6 +13993,7 @@
   { "test_bug10214", test_bug10214 },
   { "test_bug9735", test_bug9735 },
   { "test_bug11183", test_bug11183 },
+  { "test_bug11037", test_bug11037 },
   { 0, 0 }
 };
 
Thread
bk commit into 5.0 tree (georg:1.1940) BUG#11037Georg Richter15 Jul