summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorunknown <kroki/tomash@moonlight.intranet>2006-11-17 12:21:32 +0300
committerunknown <kroki/tomash@moonlight.intranet>2006-11-17 12:21:32 +0300
commiteb3a54e6359a96b444aecb283948670da00a973d (patch)
tree592172c85c268458ccc191a7b7cfcc764879e8e8 /libmysql
parentc60d8fb1f20b60106afcd29d62f8a2d0e285cf74 (diff)
downloadmariadb-git-eb3a54e6359a96b444aecb283948670da00a973d.tar.gz
BUG#23383: mysql_affected_rows() returns different values than
mysql_stmt_affected_rows() The problem was that affected_rows for prepared statement wasn't updated in the client library on the error. The solution is to always update affected_rows, which will be equal to -1 on the error. libmysql/libmysql.c: Update status variables even in the case of an error. Some variables have a defined value on the error (like affected_rows is -1), others are undefined, so updating them won't harm. libmysqld/lib_sql.cc: Update status variables even in the case of an error. Some variables have a defined value on the error (like affected_rows is -1), others are undefined, so updating them won't harm. tests/mysql_client_test.c: Add test for bug#23383: mysql_affected_rows() returns different values than mysql_stmt_affected_rows().
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/libmysql.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 91c0b6b8864..a4dc382bc37 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -2496,6 +2496,8 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
NET *net= &mysql->net;
char buff[4 /* size of stmt id */ +
5 /* execution flags */];
+ my_bool res;
+
DBUG_ENTER("execute");
DBUG_PRINT("enter",("packet: %s, length :%d",packet ? packet :" ", length));
@@ -2503,15 +2505,17 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
int4store(buff, stmt->stmt_id); /* Send stmt id to server */
buff[4]= (char) 0; /* no flags */
int4store(buff+5, 1); /* iteration count */
- if (cli_advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff),
- packet, length, 1, NULL) ||
- (*mysql->methods->read_query_result)(mysql))
+
+ res= test(cli_advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff),
+ packet, length, 1, NULL) ||
+ (*mysql->methods->read_query_result)(mysql));
+ stmt->affected_rows= mysql->affected_rows;
+ stmt->insert_id= mysql->insert_id;
+ if (res)
{
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
DBUG_RETURN(1);
}
- stmt->affected_rows= mysql->affected_rows;
- stmt->insert_id= mysql->insert_id;
DBUG_RETURN(0);
}