summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2005-07-14 20:02:34 +0400
committerunknown <konstantin@mysql.com>2005-07-14 20:02:34 +0400
commit841f71b1db327d7471505e51b68086a56e5e2a79 (patch)
tree066201cc0fabb04a87c1c12631ed02bfe173d589
parent5858a8cd42392832a443e19ce12abb8aabad12e6 (diff)
parentbd44c99b853c07761554214f57c2a0700804ffc3 (diff)
downloadmariadb-git-841f71b1db327d7471505e51b68086a56e5e2a79.tar.gz
Merge mysql.com:/opt/local/work/mysql-4.1-root
into mysql.com:/opt/local/work/mysql-5.0-root libmysql/libmysql.c: Manual merge tests/mysql_client_test.c: Manual merge
-rw-r--r--libmysql/libmysql.c11
-rw-r--r--tests/mysql_client_test.c46
2 files changed, 57 insertions, 0 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index a896460beeb..f622b2d2fb2 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1869,6 +1869,16 @@ static void net_clear_error(NET *net)
}
}
+static void stmt_clear_error(MYSQL_STMT *stmt)
+{
+ if (stmt->last_errno)
+ {
+ stmt->last_errno= 0;
+ stmt->last_error[0]= '\0';
+ strmov(stmt->sqlstate, not_error_sqlstate);
+ }
+}
+
/*
Set statement error code, sqlstate, and error message
from given errcode and sqlstate.
@@ -4959,6 +4969,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
stmt->state= MYSQL_STMT_INIT_DONE;
return 1;
}
+ stmt_clear_error(stmt);
}
}
stmt->state= MYSQL_STMT_PREPARE_DONE;
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 55384daf015..a056814a153 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -13660,6 +13660,51 @@ static void test_bug9735()
myquery(rc);
}
+
+/* Bug#11183 "mysql_stmt_reset() doesn't reset information about error" */
+
+static void test_bug11183()
+{
+ int rc;
+ MYSQL_STMT *stmt;
+ char bug_statement[]= "insert into t1 values (1)";
+
+ myheader("test_bug11183");
+
+ mysql_query(mysql, "drop table t1 if exists");
+ mysql_query(mysql, "create table t1 (a int)");
+
+ stmt= mysql_stmt_init(mysql);
+ DIE_UNLESS(stmt != 0);
+
+ rc= mysql_stmt_prepare(stmt, bug_statement, strlen(bug_statement));
+ check_execute(stmt, rc);
+
+ rc= mysql_query(mysql, "drop table t1");
+ myquery(rc);
+
+ /* Trying to execute statement that should fail on execute stage */
+ rc= mysql_stmt_execute(stmt);
+ DIE_UNLESS(rc);
+
+ mysql_stmt_reset(stmt);
+ DIE_UNLESS(mysql_stmt_errno(stmt) == 0);
+
+ mysql_query(mysql, "create table t1 (a int)");
+
+ /* Trying to execute statement that should pass ok */
+ if (mysql_stmt_execute(stmt))
+ {
+ mysql_stmt_reset(stmt);
+ DIE_UNLESS(mysql_stmt_errno(stmt) == 0);
+ }
+
+ mysql_stmt_close(stmt);
+
+ rc= mysql_query(mysql, "drop table t1");
+ myquery(rc);
+}
+
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -13902,6 +13947,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug11656", test_bug11656 },
{ "test_bug10214", test_bug10214 },
{ "test_bug9735", test_bug9735 },
+ { "test_bug11183", test_bug11183 },
{ 0, 0 }
};