dovecot-2.0: lib-sql: Fixed getting number of affected rows with...
dovecot at dovecot.org
dovecot at dovecot.org
Wed May 26 17:29:24 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/0c15a760dab8
changeset: 11375:0c15a760dab8
user: Timo Sirainen <tss at iki.fi>
date: Wed May 26 15:29:21 2010 +0100
description:
lib-sql: Fixed getting number of affected rows with MySQL.
diffstat:
src/lib-sql/driver-mysql.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
diffs (55 lines):
diff -r c23fb6cc5bb5 -r 0c15a760dab8 src/lib-sql/driver-mysql.c
--- a/src/lib-sql/driver-mysql.c Wed May 26 12:41:26 2010 +0100
+++ b/src/lib-sql/driver-mysql.c Wed May 26 15:29:21 2010 +0100
@@ -35,6 +35,8 @@
MYSQL_FIELD *fields;
unsigned int fields_count;
+
+ my_ulonglong affected_rows;
};
struct mysql_transaction_context {
@@ -290,6 +292,7 @@
break;
case 1:
/* query ok */
+ result->affected_rows = mysql_affected_rows(db->mysql);
result->result = mysql_store_result(db->mysql);
#ifdef CLIENT_MULTI_RESULTS
/* Because we've enabled CLIENT_MULTI_RESULTS, we need to read
@@ -463,26 +466,24 @@
transaction_send_query(struct mysql_transaction_context *ctx, const char *query,
unsigned int *affected_rows_r)
{
- struct sql_result *result;
- my_ulonglong rows;
+ struct sql_result *_result;
int ret = 0;
if (ctx->failed)
return -1;
- result = sql_query_s(ctx->ctx.db, query);
- if (sql_result_next_row(result) < 0) {
- ctx->error = sql_result_get_error(result);
+ _result = sql_query_s(ctx->ctx.db, query);
+ if (sql_result_next_row(_result) < 0) {
+ ctx->error = sql_result_get_error(_result);
ctx->failed = TRUE;
ret = -1;
} else if (affected_rows_r != NULL) {
- struct mysql_db *db = (struct mysql_db *)result->db;
+ struct mysql_result *result = (struct mysql_result *)_result;
- rows = mysql_affected_rows(db->mysql);
- i_assert(rows != (my_ulonglong)-1);
- *affected_rows_r = rows;
+ i_assert(result->affected_rows != (my_ulonglong)-1);
+ *affected_rows_r = result->affected_rows;
}
- sql_result_unref(result);
+ sql_result_unref(_result);
return ret;
}
More information about the dovecot-cvs
mailing list