-
Notifications
You must be signed in to change notification settings - Fork 550
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 wrong value of type YEAR on big endian environment. #921
Fix wrong value of type YEAR on big endian environment. #921
Conversation
According to https://dev.mysql.com/doc/refman/5.7/en/c-api-prepared-statement-data-structures.html YEAR is an unsigned int field in the MYSQL_TIME structure. According to https://dev.mysql.com/doc/refman/5.7/en/c-api-prepared-statement-type-codes.html it's a short int, but should have type |
To make this PR internally consistent, please adjust https://github.com/junaruga/mysql2/blob/8ef0b8fd78b3b95b6e8afb154e931f316c2be40b/ext/mysql2/result.c#L236 as well. It looks like the right change, but it's not clear to me if this is another client library incompatibility. Let's one of us run down the equivalent code in the MySQL Connector/C to confirm. |
Thanks for the information.
That's interesting.
Okay, I will change the part too. And let me run it with mariadb-connector-c on big endian evironment at first.
You meant client logic for mysql-server? I found the C++ connector on MySQL right now, though I do not know "MySQL Connector/C". |
The download bundles for the MySQL Connector/C are here: https://dev.mysql.com/downloads/connector/c/ Looking for the source code repo. |
8ef0b8f
to
e40e7f7
Compare
Checked. that's okay! Let's proceed it. |
Remind myself to mark this for cherry-pick to 0.4.x as well. |
I tried to check "MySQL Connector/C" seeing below related issues on MySQL bug tracking system. |
Thanks for the merging! |
* master: GitHub is HTTPS by default (brianmario#922) Fix wrong value of type YEAR on big endian environment. (brianmario#921) Avoid 0 byte allocation call when statement takes no parameters Small spec improvement for RSpec style Travis CI for Mac OS X builds use the same steps again More specific exception classes (brianmario#911) Travis CI matrix add Ruby 2.5 and switch Mac OS X to Ruby 2.3 (ala High Sierra) README text for query options on Statement#execute Accept query options on Statement#execute (brianmario#912) Drop 1.9.3 support (brianmario#913)
This PR for #916 issue "1.2".
I checked it like this.
The result is like this on little endian. (MYSQL_TYPE_YEAR value is 13.)
The value is 131661824 on big endian environment as you know.
Seeing the source code in mariadb-connector-c v3.0.2 (v3.0.3 is not released yet), the type year looks defined as short int.
https://github.com/MariaDB/mariadb-connector-c/blob/v3.0.2/libmariadb/ma_stmt_codec.c#L443
https://github.com/MariaDB/mariadb-connector-c/blob/v3.0.2/libmariadb/ma_stmt_codec.c#L254
https://github.com/MariaDB/mariadb-connector-c/blob/v3.0.2/include/ma_global.h#L549-L551
unsigned YEAR: between 0 (0x00 0x00) and UINT_MAX16 (0xff 0xff) that is
unsigned int short
signed YEAR: (I am not sure signed YEAR is possible): between INT_MIN16 and INT_MAX16:
int short
I tested this patch on big endian environment. And that's okay.
But I want to know why it was "int" previously.
The definition of YEAR is different between mariadb-connector-c, MySQL server and Mariadb server?
Do you remember it?
Thank you.