-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Change MySQL's number handling to be more permissive #2290
Merged
Merged
Commits on Jun 3, 2020
-
Change MySQL's number handling to be more permissive
MySQL is a bit more... lax with types than other backends. It's very easy to accidentally get a 64 bit integer or decimal when other backends would continue to give you a 32 bit integer. Right now we're relying on conversion happening in `libmysqlclient` for `query_by_index`. If we ever want to dump `libmysqlclient`, we will need to move those conversions into Diesel. However, I've opted to do this in such a way that it affects `sql_query` as well. Right now there are many differences between what our query builder says and what MySQL does. (32 bit addition/subtraction returns 64 bit, 32 bit multiplication/division/sum return decimal). Ideally you should be able to have a struct that derives both `Queryable` and `QueryableByName`, and have that work with the same query built using the query builder or `sql_query`. In order for that to happen, we can't do the conversions until we hit `FromSql`, since for `sql_query` that is the first and only time we learn what the expected type is.
Configuration menu - View commit details
-
Copy full SHA for 217dd1a - Browse repository at this point
Copy the full SHA 217dd1aView commit details -
Configuration menu - View commit details
-
Copy full SHA for a16c576 - Browse repository at this point
Copy the full SHA a16c576View commit details -
Improve type mapping in mysql backend
Also add some links to relevant mysql/mariadb documentation there
Configuration menu - View commit details
-
Copy full SHA for 5b80a18 - Browse repository at this point
Copy the full SHA 5b80a18View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3cc4192 - Browse repository at this point
Copy the full SHA 3cc4192View commit details -
Improve conversion of the received mysql value bytes to MYSQL_TIME
Clippy (rightful) complained that we read from a potential unaligned pointer, which would be undefined behaviour. The problem is: Clippy continues to complain about this, even if we use `read_unaligned()` here. This seems to be a clippy bug, see rust-lang/rust-clippy#2881
Configuration menu - View commit details
-
Copy full SHA for b285e5c - Browse repository at this point
Copy the full SHA b285e5cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4cd1db8 - Browse repository at this point
Copy the full SHA 4cd1db8View commit details -
Configuration menu - View commit details
-
Copy full SHA for de0b452 - Browse repository at this point
Copy the full SHA de0b452View commit details -
Try to cleanup mysql type metadata implementation
This commit adds a fake type layer above the types exposed by the mysql wire protocol as some of them are unused, can be used in the same context and some additional information are required to be read from the provided flags integer. I do not want to expose such a mess to potential users, better expose an clear type enum with all currently supported variants in diesel. If we hit later something that isn't supported yet we can just add it with an additional entry, because this enum is `#[non_exhaustive]`
Configuration menu - View commit details
-
Copy full SHA for 2facb24 - Browse repository at this point
Copy the full SHA 2facb24View commit details -
Configuration menu - View commit details
-
Copy full SHA for d1eed7c - Browse repository at this point
Copy the full SHA d1eed7cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0b6c61e - Browse repository at this point
Copy the full SHA 0b6c61eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2300231 - Browse repository at this point
Copy the full SHA 2300231View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6ea97a3 - Browse repository at this point
Copy the full SHA 6ea97a3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 67aceb2 - Browse repository at this point
Copy the full SHA 67aceb2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8325d51 - Browse repository at this point
Copy the full SHA 8325d51View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6ac48a7 - Browse repository at this point
Copy the full SHA 6ac48a7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 94e66ed - Browse repository at this point
Copy the full SHA 94e66edView commit details
Commits on Jun 4, 2020
-
This change fixes a out of buffer write in newer versions of libmysqlclient. That write was caused by a change in libmysqlclient around version 8.0.19 that added another field to `MYSQL_TIME` and by diesel using a statically generated binding (mysqlclient-sys). As consequence diesel would allocate a to small buffer for the struct while libmysql writes more bytes that expected, which results in a out of bound write. Interestingly this does not happen with a recent libmysqlclient version based on the sources in the mariadb source code. As a fix I move an updated version of `MYSQL_TIME` to diesel itself, as I do not have any control over `mysqlclient-sys`. This change is compatible with older libmysqlclient versions, because for them we just allocate a larger buffer than they actually use, which is fine.
Configuration menu - View commit details
-
Copy full SHA for 1b0453f - Browse repository at this point
Copy the full SHA 1b0453fView commit details
Commits on Jun 5, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 54ffbf3 - Browse repository at this point
Copy the full SHA 54ffbf3View commit details -
Configuration menu - View commit details
-
Copy full SHA for db56fce - Browse repository at this point
Copy the full SHA db56fceView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5668b75 - Browse repository at this point
Copy the full SHA 5668b75View commit details -
Configuration menu - View commit details
-
Copy full SHA for f94495a - Browse repository at this point
Copy the full SHA f94495aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1d46c44 - Browse repository at this point
Copy the full SHA 1d46c44View commit details
Commits on Jun 8, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 9ad9558 - Browse repository at this point
Copy the full SHA 9ad9558View commit details
Commits on Jun 10, 2020
-
Configuration menu - View commit details
-
Copy full SHA for f783850 - Browse repository at this point
Copy the full SHA f783850View commit details -
Configuration menu - View commit details
-
Copy full SHA for a1d71bb - Browse repository at this point
Copy the full SHA a1d71bbView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.