summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-06-07 00:30:00 +0400
committerunknown <evgen@moonbone.local>2007-06-07 00:30:00 +0400
commit8d0d27b5a45b8d6224e9d94f77baef7a334e5959 (patch)
tree92749916f69e5e09f6d4eccb290868f8ef26a387 /tests
parent64c6a91d40cd3885926a7706549cbfc7c3fe565c (diff)
downloadmariadb-git-8d0d27b5a45b8d6224e9d94f77baef7a334e5959.tar.gz
Bug#28505: mysql_affected_rows() may return wrong result if CLIENT_FOUND_ROWS
flag is set. When the CLIENT_FOUND_ROWS flag is set then the server should return found number of rows independently whether they were updated or not. But this wasn't the case for the INSERT statement which always returned number of rows that were actually changed thus providing wrong info to the user. Now the select_insert::send_eof method and the mysql_insert function are sending the number of touched rows if the CLIENT_FOUND_ROWS flag is set. tests/mysql_client_test.c: Added a test case for the bug#28505: mysql_affected_rows() may return wrong result if CLIENT_FOUND_ROWS flag is set. sql/sql_insert.cc: Bug#28505: mysql_affected_rows() may return wrong result if CLIENT_FOUND_ROWS flag is set. Now the select_insert::send_eof method and the mysql_insert function are sending the number of touched rows if the CLIENT_FOUND_ROWS flag is set.
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index e56dd693287..54d29dbd683 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -15624,6 +15624,69 @@ static void test_bug27876()
/*
+ Bug#28505: mysql_affected_rows() returns wrong value if CLIENT_FOUND_ROWS
+ flag is set.
+*/
+static void test_bug28505()
+{
+ MYSQL *l_mysql;
+ my_bool error= 0;
+ my_ulonglong res;
+
+ if (!(l_mysql= mysql_init(NULL)))
+ {
+ myerror("mysql_init() failed");
+ DIE_UNLESS(1);
+ }
+ if (!(mysql_real_connect(l_mysql, opt_host, opt_user,
+ opt_password, current_db, opt_port,
+ opt_unix_socket, CLIENT_FOUND_ROWS)))
+ {
+ myerror("connection failed");
+ error= 1;
+ goto end;
+ }
+ l_mysql->reconnect= 1;
+ if (mysql_query(l_mysql, "drop table if exists t1"))
+ {
+ myerror(NULL);
+ error= 1;
+ goto end;
+ }
+ if (mysql_query(l_mysql, "create table t1(f1 int primary key)"))
+ {
+ myerror(NULL);
+ error= 1;
+ goto end;
+ }
+ if (mysql_query(l_mysql, "insert into t1 values(1)"))
+ {
+ myerror(NULL);
+ error= 1;
+ goto end;
+ }
+ if (mysql_query(l_mysql,
+ "insert into t1 values(1) on duplicate key update f1=1"))
+ {
+ myerror(NULL);
+ error= 1;
+ goto end;
+ }
+ res= mysql_affected_rows(l_mysql);
+ if (!res)
+ error= 1;
+ if (mysql_query(l_mysql, "drop table t1"))
+ {
+ myerror(NULL);
+ error= 1;
+ }
+end:
+ mysql_close(l_mysql);
+ DIE_UNLESS(error == 0);
+}
+
+
+/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -15904,6 +15967,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug21635", test_bug21635 },
{ "test_bug24179", test_bug24179 },
{ "test_bug27876", test_bug27876 },
+ { "test_bug28505", test_bug28505 },
{ 0, 0 }
};