diff --git a/mx_mysql.c b/mx_mysql.c index 593437a..df20452 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -412,6 +412,20 @@ static int mx__mysql_stmt_num_rows(struct mx_mysql_stmt *stmt, unsigned long lon return 0; } +static int mx__mysql_stmt_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long *count) +{ + my_ulonglong c; + + mx_assert_return_minus_errno(stmt, EINVAL); + mx_assert_return_minus_errno(stmt->stmt, EBADF); + + c = mysql_stmt_affected_rows(stmt->stmt); + + *count = (unsigned long long)c; + + return 0; +} + static int mx__mysql_stmt_close(struct mx_mysql_stmt *stmt) { my_bool res; @@ -823,9 +837,9 @@ int mx_mysql_statement_execute(struct mx_mysql_stmt *stmt, unsigned long long *c } if (count) { - res = mx__mysql_stmt_num_rows(stmt, count); + res = mx__mysql_stmt_affected_rows(stmt, count); if (res < 0) { - mx_log_debug("ERROR: mx__mysql_stmt_num_rows(): %m"); + mx_log_debug("ERROR: mx__mysql_stmt_affected_rows(): %m"); return res; } } @@ -833,6 +847,10 @@ int mx_mysql_statement_execute(struct mx_mysql_stmt *stmt, unsigned long long *c return 0; } +int mx_mysql_statement_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count) { + return mx__mysql_stmt_affected_rows(stmt, count); +} + int mx_mysql_statement_num_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count) { return mx__mysql_stmt_num_rows(stmt, count); } diff --git a/mx_mysql.h b/mx_mysql.h index a13aea9..c07096e 100644 --- a/mx_mysql.h +++ b/mx_mysql.h @@ -155,6 +155,7 @@ int mx_mysql_statement_init(struct mx_mysql *mysql, struct mx_mysql_stmt **stmt) int mx_mysql_statement_prepare(struct mx_mysql_stmt *stmt, char *statement); int mx_mysql_statement_execute(struct mx_mysql_stmt *stmt, unsigned long long *count); +int mx_mysql_statement_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count); int mx_mysql_statement_num_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count); int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt);