summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authormsvensson@neptunus.(none) <>2007-01-16 14:13:48 +0100
committermsvensson@neptunus.(none) <>2007-01-16 14:13:48 +0100
commit11ddeb693d7e47eff02ef55c8dd4a5220ff55ea0 (patch)
treedd2b0d3ae60fc3e0f6750e37a30682b4cb655dd9 /libmysql
parent47583ddf3e1aafb7e933146edce2236bfc2dde33 (diff)
parentf507bb2cb3d698435d13336a5ebd5ecf797a770e (diff)
downloadmariadb-git-11ddeb693d7e47eff02ef55c8dd4a5220ff55ea0.tar.gz
Merge neptunus.(none):/home/msvensson/mysql/bug15518/my50-bug15518
into neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/libmysql.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 304c20132ff..7e1ff92bce5 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -2042,6 +2042,13 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
DBUG_RETURN(1);
}
+ /*
+ Reset the last error in any case: that would clear the statement
+ if the previous prepare failed.
+ */
+ stmt->last_errno= 0;
+ stmt->last_error[0]= '\0';
+
if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE)
{
/* This is second prepare with another statement */
@@ -2055,23 +2062,24 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
*/
stmt->bind_param_done= stmt->bind_result_done= FALSE;
stmt->param_count= stmt->field_count= 0;
- stmt->last_errno= 0;
- stmt->last_error[0]= '\0';
free_root(&stmt->mem_root, MYF(MY_KEEP_PREALLOC));
int4store(buff, stmt->stmt_id);
+
/*
+ Close statement in server
+
If there was a 'use' result from another statement, or from
mysql_use_result it won't be freed in mysql_stmt_free_result and
we should get 'Commands out of sync' here.
*/
+ stmt->state= MYSQL_STMT_INIT_DONE;
if (stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt))
{
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
mysql->net.sqlstate);
DBUG_RETURN(1);
}
- stmt->state= MYSQL_STMT_INIT_DONE;
}
if (stmt_command(mysql, COM_STMT_PREPARE, query, length, stmt))