-
Notifications
You must be signed in to change notification settings - Fork 548
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
Fix a segmentation fault which Mysql2::Statement#fields causes. #860
Conversation
Good find! I wonder if the right answer is |
spec/mysql2/statement_spec.rb
Outdated
@@ -329,6 +329,7 @@ def stmt_count | |||
before(:each) do | |||
@client.query "USE test" | |||
@test_result = @client.prepare("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").execute | |||
@client.query 'CREATE TABLE IF NOT EXISTS fieldsTest (blah varchar(10))' |
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.
It doesn't need a new table, you can insert into the same mysql2_test
table.
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.
thanks! I fixed it.
Thank you for your review!
I think so too. |
Use `!metadata` instead of `metadata == NULL`.
Updates brianmario#860. Thanks to @naoki-k for the initial fix.
I spent some time with this, and decided that There were a few other issues to address, so I've committed a similar but broader change and credited you with the initial fix. Thank you! |
I found a bug(segmentation fault) about
Mysql2::Statement#fields
.environment
example
This is probably minimal example.
I think that it doesn't be passed the expected value for
mysql_fetch_fields
becausemysql_stmt_result_metadata
returns NULL forINSERT
,UPDATE
,DELETE
etc.(ref: https://dev.mysql.com/doc/refman/5.7/en/mysql-stmt-result-metadata.html)
And therefore, in case metadata is
NULL
, I changefields
function to return an empty array.Please review this 🙏