Skip to content

Commit

Permalink
mx_mysql: export mx_mysql_statement_affected_rows() and use it in exe…
Browse files Browse the repository at this point in the history
…cute()
  • Loading branch information
mariux committed May 20, 2015
1 parent 29a6c83 commit 073860c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions mx_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -823,16 +837,20 @@ 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;
}
}

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);
}
Expand Down
1 change: 1 addition & 0 deletions mx_mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 073860c

Please sign in to comment.