Below is the list of changes that have just been committed into a local
5.0 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, 2007-11-30 19:16:13+04:00, holyfoot@stripped +2 -0
Bug #26921 Problem in mysql_insert_id() Embedded C API function.
client library only sets mysql->insert_id when query returned
no recordset. So the embedded library should behave the same way
libmysqld/lib_sql.cc@stripped, 2007-11-30 19:16:12+04:00, holyfoot@stripped +5 -3
Bug #26921 Problem in mysql_insert_id() Embedded C API function.
only set 'affected_rows' and 'insert_id' fields when query
didn't return a recordset
tests/mysql_client_test.c@stripped, 2007-11-30 19:16:12+04:00, holyfoot@stripped +11 -0
Bug #26921 Problem in mysql_insert_id() Embedded C API function.
testcase added
diff -Nrup a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
--- a/libmysqld/lib_sql.cc 2007-06-13 16:48:49 +05:00
+++ b/libmysqld/lib_sql.cc 2007-11-30 19:16:12 +04:00
@@ -251,9 +251,11 @@ static my_bool emb_read_query_result(MYS
mysql->warning_count= res->embedded_info->warning_count;
mysql->server_status= res->embedded_info->server_status;
mysql->field_count= res->fields;
- mysql->fields= res->embedded_info->fields_list;
- mysql->affected_rows= res->embedded_info->affected_rows;
- mysql->insert_id= res->embedded_info->insert_id;
+ if (!(mysql->fields= res->embedded_info->fields_list))
+ {
+ mysql->affected_rows= res->embedded_info->affected_rows;
+ mysql->insert_id= res->embedded_info->insert_id;
+ }
mysql->net.last_errno= 0;
mysql->net.last_error[0]= 0;
mysql->info= 0;
diff -Nrup a/tests/mysql_client_test.c b/tests/mysql_client_test.c
--- a/tests/mysql_client_test.c 2007-11-22 15:53:37 +04:00
+++ b/tests/mysql_client_test.c 2007-11-30 19:16:12 +04:00
@@ -15358,6 +15358,8 @@ static void test_bug21206()
Test that client gets updated value of insert_id on UPDATE that uses
LAST_INSERT_ID(expr).
+ select_query added to test for bug
+ #26921 Problem in mysql_insert_id() Embedded C API function
*/
static void test_bug21726()
{
@@ -15370,6 +15372,8 @@ static void test_bug21726()
const char *update_query= "UPDATE t1 SET i= LAST_INSERT_ID(i + 1)";
int rc;
my_ulonglong insert_id;
+ const char *select_query= "SELECT * FROM t1";
+ MYSQL_RES *result;
DBUG_ENTER("test_bug21726");
myheader("test_bug21726");
@@ -15385,6 +15389,13 @@ static void test_bug21726()
myquery(rc);
insert_id= mysql_insert_id(mysql);
DIE_UNLESS(insert_id == 3);
+
+ rc= mysql_query(mysql, select_query);
+ myquery(rc);
+ insert_id= mysql_insert_id(mysql);
+ DIE_UNLESS(insert_id == 3);
+ result= mysql_store_result(mysql);
+ mysql_free_result(result);
DBUG_VOID_RETURN;
}