diff options
author | unknown <tsmith@siva.hindu.god> | 2007-01-18 08:41:52 -0700 |
---|---|---|
committer | unknown <tsmith@siva.hindu.god> | 2007-01-18 08:41:52 -0700 |
commit | 64b075e67777d20548ba46136fbf3c00d0782220 (patch) | |
tree | fa97f35dee68f54abce23ee236b0e1a371ba7c74 /libmysql | |
parent | 61430c77a43d2b9bf8f5a928ca7977e96df0d1da (diff) | |
parent | 9a765037043f62cc8dd419517b90d520fedc99dd (diff) | |
download | mariadb-git-64b075e67777d20548ba46136fbf3c00d0782220.tar.gz |
Merge siva.hindu.god:/home/tsmith/m/bk/mrg-jan17/maint/50
into siva.hindu.god:/home/tsmith/m/bk/mrg-jan17/maint/51
BUILD/check-cpu:
Auto merged
client/mysqltest.c:
Auto merged
include/my_global.h:
Auto merged
libmysql/libmysql.c:
Auto merged
mysql-test/Makefile.am:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
BitKeeper/deleted/.del-CMakeLists.txt~2f6eabb2f69cb33d:
Auto merged
mysql-test/lib/mtr_cases.pl:
Auto merged
mysql-test/lib/mtr_process.pl:
Auto merged
mysql-test/t/myisam.test:
Auto merged
mysql-test/t/mysql.test:
Auto merged
mysql-test/t/mysqladmin.test:
Auto merged
mysql-test/t/rpl_rotate_logs.test:
Auto merged
mysql-test/t/trigger.test:
Auto merged
mysys/mf_iocache.c:
Auto merged
mysys/my_read.c:
Auto merged
mysys/my_seek.c:
Auto merged
scripts/make_binary_distribution.sh:
Auto merged
scripts/mysqlbug.sh:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/item_sum.h:
Auto merged
sql/opt_range.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_parse.cc:
Auto merged
storage/myisam/mi_packrec.c:
Auto merged
tests/mysql_client_test.c:
Auto merged
Makefile.am:
Use local
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Use local
sql/mysqld.cc:
Use local
strings/ctype-extra.c:
SCCS merged
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 89460d7099d..0c1f28ab7ec 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2036,6 +2036,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 */ @@ -2049,23 +2056,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)) |