New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add prepared statements support for Mysql2Adapter
#22415
Add prepared statements support for Mysql2Adapter
#22415
Conversation
r? @matthewd (@rails-bot has picked a reviewer for you, use r? to override) |
…adapter Add prepared statements support for `Mysql2Adapter`
@kamipo Looks like this causes an intermittent test failure (possibly order dependent, unsure). I'm going to revert for now, can you look into it? It looks like it might even be a bug in the mysql2 gem. https://travis-ci.org/rails/rails/jobs/93407920 |
It seems that this is caused by brianmario/mysql2#694. I'll investigating the cause, thanks! |
affected_rows = stmt.affected_rows | ||
result = stmt.result_metadata | ||
ret = yield stmt, result | ||
result.free if result | ||
|
||
stmt.free_result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this freeing the result twice? Edit: no, for prepared statements, result is the result metadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
result.free
calls mysql_free_result
.
https://github.com/luislavena/mysql-gem/blob/master/ext/mysql_api/mysql.c#L1112-L1121
static VALUE res_free(VALUE obj)
{
struct mysql_res* resp = DATA_PTR(obj);
check_free(obj);
mysql_free_result(resp->res);
resp->freed = Qtrue;
store_result_count--;
return Qnil;
}
stmt.free_result
calls mysql_stmt_free_result
.
https://github.com/luislavena/mysql-gem/blob/master/ext/mysql_api/mysql.c#L1610-L1618
static VALUE stmt_free_result(VALUE obj)
{
struct mysql_stmt* s = DATA_PTR(obj);
check_stmt_closed(obj);
if (mysql_stmt_free_result(s->stmt))
mysql_stmt_raise(s->stmt);
return obj;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't see your reply before I edited my own comment :) I'd forgotten that the result set and the result metadata are separate items.
Reopen #22352 because mysql2 0.4.2 is released.